diff --git a/Weingartner.Json.Migration.Roslyn/AnalyzerReleases.Shipped.md b/Weingartner.Json.Migration.Roslyn/AnalyzerReleases.Shipped.md new file mode 100644 index 0000000..e48a015 --- /dev/null +++ b/Weingartner.Json.Migration.Roslyn/AnalyzerReleases.Shipped.md @@ -0,0 +1,9 @@ +## Release 1.0.2 + +### New Rules + +Rule ID | Category | Severity | Notes +--------|----------|----------|------- +DataContractAnalyzer | DataMigration | Error | DataContractAnalyzer +MigrationHashAnalyzer | DataMigration | Error | MigrationHashAnalyzer +MigrationMethodAnalyzer | DataMigration | Error | MigrationMethodAnalyzer diff --git a/Weingartner.Json.Migration.Roslyn/AnalyzerReleases.Unshipped.md b/Weingartner.Json.Migration.Roslyn/AnalyzerReleases.Unshipped.md new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Weingartner.Json.Migration.Roslyn/AnalyzerReleases.Unshipped.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Weingartner.Json.Migration.Roslyn/DataContractAnalyzer.cs b/Weingartner.Json.Migration.Roslyn/DataContractAnalyzer.cs index e51f819..6aedb11 100644 --- a/Weingartner.Json.Migration.Roslyn/DataContractAnalyzer.cs +++ b/Weingartner.Json.Migration.Roslyn/DataContractAnalyzer.cs @@ -12,7 +12,7 @@ public class DataContractAnalyzer : DiagnosticAnalyzer { public const string DiagnosticId = "DataContractAnalyzer"; private static readonly LocalizableString Title = "Migratable type should have `DataContract` and `DataMember` attributes"; - public static readonly LocalizableString MessageFormat = "Type '{0}' is migratable but is missing either `DataContract` or `DataMember` attributes."; + public static readonly LocalizableString MessageFormat = "Type '{0}' is migratable but is missing either `DataContract` or `DataMember` attributes"; private const string Category = "DataMigration"; private static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, Category, DiagnosticSeverity.Error, true); @@ -21,6 +21,8 @@ public class DataContractAnalyzer : DiagnosticAnalyzer public override void Initialize(AnalysisContext context) { + context.EnableConcurrentExecution(); + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics); context.RegisterCompilationStartAction(OnCompilationStart); } diff --git a/Weingartner.Json.Migration.Roslyn/MigrationHashAnalyzer.cs b/Weingartner.Json.Migration.Roslyn/MigrationHashAnalyzer.cs index 8fe94fa..bde91af 100644 --- a/Weingartner.Json.Migration.Roslyn/MigrationHashAnalyzer.cs +++ b/Weingartner.Json.Migration.Roslyn/MigrationHashAnalyzer.cs @@ -26,7 +26,7 @@ public class MigrationHashAnalyzer : DiagnosticAnalyzer { public const string DiagnosticId = "MigrationHashAnalyzer"; private static readonly LocalizableString Title = "Should have correct migration hash"; - public static readonly LocalizableString MessageFormat = "Expected migration hash of type '{0}' to be '{1}'."; + public static readonly LocalizableString MessageFormat = "Expected migration hash of type '{0}' to be '{1}'"; private static readonly LocalizableString Description = "An incorrect migration hash is a hint that you may have forgotten to add a migration. " + "The hash is calculated from all properties with a `DataMember` attribute " + @@ -40,6 +40,8 @@ public class MigrationHashAnalyzer : DiagnosticAnalyzer public override void Initialize(AnalysisContext context) { + context.EnableConcurrentExecution(); + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics); context.RegisterCompilationStartAction(OnCompilationStart); } diff --git a/Weingartner.Json.Migration.Roslyn/MigrationHashHelper.cs b/Weingartner.Json.Migration.Roslyn/MigrationHashHelper.cs index 1923d7d..18401cc 100644 --- a/Weingartner.Json.Migration.Roslyn/MigrationHashHelper.cs +++ b/Weingartner.Json.Migration.Roslyn/MigrationHashHelper.cs @@ -92,7 +92,7 @@ private static AttributeSyntax GetAttribute(SyntaxList attr { var ctorSymbol = semanticModel.GetSymbolInfo(a, ct).Symbol; var typeSymbol = ctorSymbol?.ContainingSymbol; - return typeSymbol?.Equals(attributeType) ?? false; + return typeSymbol?.Equals(attributeType, SymbolEqualityComparer.Default) ?? false; }); } diff --git a/Weingartner.Json.Migration.Roslyn/MigrationMethodAnalyzer.cs b/Weingartner.Json.Migration.Roslyn/MigrationMethodAnalyzer.cs index e65bcea..9653de0 100644 --- a/Weingartner.Json.Migration.Roslyn/MigrationMethodAnalyzer.cs +++ b/Weingartner.Json.Migration.Roslyn/MigrationMethodAnalyzer.cs @@ -25,8 +25,11 @@ public class MigrationMethodAnalyzer : DiagnosticAnalyzer public override void Initialize(AnalysisContext context) { + context.EnableConcurrentExecution(); + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics); context.RegisterCompilationStartAction(OnCompilationStart); } + private static void OnCompilationStart(CompilationStartAnalysisContext context) { var migratableAttributeType = context.Compilation.GetTypeByMetadataName(Constants.MigratableAttributeMetadataName); @@ -73,7 +76,7 @@ private static Func CanAssign(SyntaxNodeAnalysisCo var t1 = context.SemanticModel.Compilation.GetTypeByMetadataName(srcType.FullName); var t2 = context.SemanticModel.Compilation.GetTypeByMetadataName(targetType.FullName); - return getBaseTypesAndSelf(t1).Contains(t2); + return getBaseTypesAndSelf(t1).Contains(t2,SymbolEqualityComparer.Default); }; } } diff --git a/Weingartner.Json.Migration.Roslyn/Weingartner.Json.Migration.Roslyn.csproj b/Weingartner.Json.Migration.Roslyn/Weingartner.Json.Migration.Roslyn.csproj index ec6c8b3..2d9d403 100644 --- a/Weingartner.Json.Migration.Roslyn/Weingartner.Json.Migration.Roslyn.csproj +++ b/Weingartner.Json.Migration.Roslyn/Weingartner.Json.Migration.Roslyn.csproj @@ -36,5 +36,10 @@ + + + + +