Skip to content

Commit da3372c

Browse files
committed
v0.1.0
Added extra error descriptors. Fixed out of bound read error for non-existsing items in the assembly. Made remaining OtherError messages contain much more info.
1 parent 907063b commit da3372c

14 files changed

+260
-65
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ TestResults/
1111
.vs/
1212
MigrationBackup/
1313
*.dll
14+
*.zip

CompatibilityChecker/Analyzer.cs

+86-52
Large diffs are not rendered by default.

CompatibilityChecker/CompatibilityChecker.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22

33
<PropertyGroup>
44
<TargetFrameworks>net48;netstandard2.1</TargetFrameworks>
5-
<Version>0.0.5</Version>
5+
<Version>0.1.0</Version>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
10-
<PackageReference Include="System.Reflection.Metadata" Version="1.6.0" />
9+
<PackageReference Include="System.Collections.Immutable" Version="1.7.0" />
10+
<PackageReference Include="System.Reflection.Metadata" Version="1.8.0" />
1111
</ItemGroup>
1212

1313
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' ">
1414
<Reference Include="Microsoft.CSharp" />
1515
</ItemGroup>
1616

1717
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
18-
<PackageReference Include="Microsoft.CSharp" Version="4.7.0"/>
18+
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
1919
</ItemGroup>
2020

2121
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace CompatibilityChecker.Descriptors
2+
{
3+
using System.Reflection.Metadata;
4+
using System.Runtime.CompilerServices;
5+
6+
/// <summary>
7+
/// Base types cannot be moved out of the assembly.
8+
/// </summary>
9+
internal class BaseTypeMustStayInAssembly : CompatibilityDescriptor
10+
{
11+
private const string Id = nameof(BaseTypeMustStayInAssembly);
12+
private static readonly string _title = TitleHelper.GenerateTitle(Id);
13+
private static readonly string _messageFormat = "Base type of '{0}' must not be moved outside the assembly.";
14+
private static readonly string _category = Categories.Type;
15+
private static readonly Severity _defaultSeverity = Severity.Error;
16+
private static readonly string _description = null;
17+
18+
private static readonly BaseTypeMustStayInAssembly Instance = new BaseTypeMustStayInAssembly();
19+
20+
private BaseTypeMustStayInAssembly()
21+
: base(Id, _title, _messageFormat, _category, _defaultSeverity, _description)
22+
{
23+
}
24+
25+
internal static Message CreateMessage(string typeName)
26+
{
27+
return new Message(Instance, typeName);
28+
}
29+
}
30+
}

CompatibilityChecker/Descriptors/OtherError.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ internal class OtherError : CompatibilityDescriptor
1010
private const string Id = nameof(OtherError);
1111
private static readonly string _title = TitleHelper.GenerateTitle(Id);
1212

13-
private static readonly string _messageFormat = "Unknown error occured. {0}";
13+
private static readonly string _messageFormat = "Other error occured. {0}";
1414
private static readonly string _category = Categories.Other;
1515
private static readonly Severity _defaultSeverity = Severity.Error;
1616
private static readonly string _description = null;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace CompatibilityChecker.Descriptors
2+
{
3+
using System.Reflection.Metadata;
4+
using System.Runtime.CompilerServices;
5+
6+
/// <summary>
7+
/// Publicly-accessible property getter cannot be removed.
8+
/// </summary>
9+
internal class PropertyGetterMustNotBeRemoved : CompatibilityDescriptor
10+
{
11+
private const string Id = nameof(PropertyGetterMustNotBeRemoved);
12+
private static readonly string _title = TitleHelper.GenerateTitle(Id);
13+
private static readonly string _messageFormat = "Publicly-accessible property getter '{0}' cannot be removed.";
14+
private static readonly string _category = Categories.Event;
15+
private static readonly Severity _defaultSeverity = Severity.Error;
16+
private static readonly string _description = null;
17+
18+
private static readonly PropertyGetterMustNotBeRemoved Instance = new PropertyGetterMustNotBeRemoved();
19+
20+
private PropertyGetterMustNotBeRemoved()
21+
: base(Id, _title, _messageFormat, _category, _defaultSeverity, _description)
22+
{
23+
}
24+
25+
internal static Message CreateMessage(string name)
26+
{
27+
return new Message(Instance, name);
28+
}
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace CompatibilityChecker.Descriptors
2+
{
3+
using System.Reflection.Metadata;
4+
using System.Runtime.CompilerServices;
5+
6+
/// <summary>
7+
/// Publicly-accessible property setter cannot be removed.
8+
/// </summary>
9+
internal class PropertySetterMustNotBeRemoved : CompatibilityDescriptor
10+
{
11+
private const string Id = nameof(PropertySetterMustNotBeRemoved);
12+
private static readonly string _title = TitleHelper.GenerateTitle(Id);
13+
private static readonly string _messageFormat = "Publicly-accessible property setter '{0}' cannot be removed.";
14+
private static readonly string _category = Categories.Event;
15+
private static readonly Severity _defaultSeverity = Severity.Error;
16+
private static readonly string _description = null;
17+
18+
private static readonly PropertySetterMustNotBeRemoved Instance = new PropertySetterMustNotBeRemoved();
19+
20+
private PropertySetterMustNotBeRemoved()
21+
: base(Id, _title, _messageFormat, _category, _defaultSeverity, _description)
22+
{
23+
}
24+
25+
internal static Message CreateMessage(string name)
26+
{
27+
return new Message(Instance, name);
28+
}
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace CompatibilityChecker.Descriptors
2+
{
3+
using System.Reflection.Metadata;
4+
using System.Runtime.CompilerServices;
5+
6+
/// <summary>
7+
/// Signature of publicly-accessible property cannot be changed or removed.
8+
/// </summary>
9+
internal class PropertySignatureMustNotBeChanged : CompatibilityDescriptor
10+
{
11+
private const string Id = nameof(PropertySignatureMustNotBeChanged);
12+
private static readonly string _title = TitleHelper.GenerateTitle(Id);
13+
private static readonly string _messageFormat = "Signature of publicly-accessible property '{0}' was renamed or removed.";
14+
private static readonly string _category = Categories.Property;
15+
private static readonly Severity _defaultSeverity = Severity.Error;
16+
private static readonly string _description = null;
17+
18+
private static readonly PropertySignatureMustNotBeChanged Instance = new PropertySignatureMustNotBeChanged();
19+
20+
private PropertySignatureMustNotBeChanged()
21+
: base(Id, _title, _messageFormat, _category, _defaultSeverity, _description)
22+
{
23+
}
24+
25+
internal static Message CreateMessage(string propertyName)
26+
{
27+
return new Message(Instance, propertyName);
28+
}
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace CompatibilityChecker.Descriptors
2+
{
3+
using System.Reflection.Metadata;
4+
using System.Runtime.CompilerServices;
5+
6+
/// <summary>
7+
/// Resolution scope assembly references cannot be changed.
8+
/// </summary>
9+
internal class ResolutionScopeAssemblyReferenceMustNotChange : CompatibilityDescriptor
10+
{
11+
private const string Id = nameof(ResolutionScopeAssemblyReferenceMustNotChange);
12+
private static readonly string _title = TitleHelper.GenerateTitle(Id);
13+
private static readonly string _messageFormat = "Resolution scope assembly reference for '{0}' must not be changed.";
14+
private static readonly string _category = Categories.Type;
15+
private static readonly Severity _defaultSeverity = Severity.Error;
16+
private static readonly string _description = null;
17+
18+
private static readonly ResolutionScopeAssemblyReferenceMustNotChange Instance = new ResolutionScopeAssemblyReferenceMustNotChange();
19+
20+
private ResolutionScopeAssemblyReferenceMustNotChange()
21+
: base(Id, _title, _messageFormat, _category, _defaultSeverity, _description)
22+
{
23+
}
24+
25+
internal static Message CreateMessage(string assemblyName)
26+
{
27+
return new Message(Instance, assemblyName);
28+
}
29+
}
30+
}

CompatibilityCheckerCLI/CompatibilityCheckerCLI.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<ApplicationIcon />
99
<StartupObject />
1010
<LangVersion>latest</LangVersion>
11-
<Version>0.0.5</Version>
11+
<Version>0.1.0</Version>
1212
</PropertyGroup>
1313

1414
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
@@ -17,8 +17,8 @@
1717
</PropertyGroup>
1818

1919
<ItemGroup>
20-
<PackageReference Include="CommandLineParser" Version="2.5.0" />
21-
<PackageReference Include="System.Reflection.Metadata" Version="1.6.0" />
20+
<PackageReference Include="CommandLineParser" Version="2.7.82" />
21+
<PackageReference Include="System.Reflection.Metadata" Version="1.8.0" />
2222
</ItemGroup>
2323

2424
<ItemGroup>

CompatibilityCheckerCLI/Properties/launchSettings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"profiles": {
33
"CompatibilityCheckerCoreExample": {
44
"commandName": "Project",
5-
"commandLineArgs": "\"..\\..\\..\\..\\MediaBrowser.Common_nuget.dll\" \"..\\..\\..\\..\\MediaBrowser.Common_artifact.dll\" --azure-pipelines --warnings-only"
5+
"commandLineArgs": "\"..\\..\\..\\..\\Emby.Naming_10.4.3.dll\" \"..\\..\\..\\..\\Emby.Naming_error.dll\" --azure-pipelines --warnings-only"
66
}
77
}
88
}

CompatibilityCheckerTests/CompatibilityCheckerTests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
</ItemGroup>
6565
<ItemGroup>
6666
<PackageReference Include="System.Reflection.Metadata">
67-
<Version>1.6.0</Version>
67+
<Version>1.8.0</Version>
6868
</PackageReference>
6969
</ItemGroup>
7070
<Choose>

build-for-ci.bat

-3
This file was deleted.

build-release-package-for-ci.bat

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@ECHO OFF
2+
3+
dotnet publish -c Release --framework netcoreapp3.1 --self-contained false -r linux-x64 -o CompatibilityCheckerCLI-ci CompatibilityCheckerCLI\CompatibilityCheckerCLI.csproj
4+
5+
del /Q ".\CompatibilityCheckerCLI-ci.zip"
6+
7+
pushd CompatibilityCheckerCLI-ci
8+
9+
zip -r -p "..\CompatibilityCheckerCLI-ci.zip" ".\*"
10+
11+
popd
12+
13+
RMDIR /S /Q ".\CompatibilityCheckerCLI-ci"

0 commit comments

Comments
 (0)