From c89fc418755eadc8dc457a298a032caa45273b8c Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Wed, 14 Oct 2020 11:53:06 -0700 Subject: [PATCH] Fix warnings for analyzer release (#227) * Fix some warnings about analyzer authoring --- .../AnalyzerReleases.Shipped.md | 20 +++++++++++++++ .../GeneratorDiagnostics.cs | 2 +- .../ManualTypeMarshallingAnalyzer.cs | 25 ++++++++++--------- 3 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 DllImportGenerator/DllImportGenerator/AnalyzerReleases.Shipped.md diff --git a/DllImportGenerator/DllImportGenerator/AnalyzerReleases.Shipped.md b/DllImportGenerator/DllImportGenerator/AnalyzerReleases.Shipped.md new file mode 100644 index 000000000000..449faf2f65ef --- /dev/null +++ b/DllImportGenerator/DllImportGenerator/AnalyzerReleases.Shipped.md @@ -0,0 +1,20 @@ +## Release 1.0 + +### New Rules + +Rule ID | Category | Severity | Notes +--------|----------|----------|------- +DLLIMPORTGEN001 | Usage | Error +DLLIMPORTGEN002 | Usage | Error +DLLIMPORTGENANALYZER001 | Usage | Error +DLLIMPORTGENANALYZER002 | Usage | Error +DLLIMPORTGENANALYZER003 | Usage | Error +DLLIMPORTGENANALYZER004 | Usage | Error +DLLIMPORTGENANALYZER005 | Usage | Error +DLLIMPORTGENANALYZER006 | Usage | Error +DLLIMPORTGENANALYZER007 | Usage | Error +DLLIMPORTGENANALYZER008 | Usage | Error +DLLIMPORTGENANALYZER009 | Usage | Error +DLLIMPORTGENANALYZER010 | Usage | Warning +DLLIMPORTGENANALYZER011 | Usage | Warning +DLLIMPORTGENANALYZER012 | Usage | Error diff --git a/DllImportGenerator/DllImportGenerator/GeneratorDiagnostics.cs b/DllImportGenerator/DllImportGenerator/GeneratorDiagnostics.cs index 51f64e6a870e..b4b29420052f 100644 --- a/DllImportGenerator/DllImportGenerator/GeneratorDiagnostics.cs +++ b/DllImportGenerator/DllImportGenerator/GeneratorDiagnostics.cs @@ -55,7 +55,7 @@ public class Ids public const string ConfigurationNotSupported = Prefix + "002"; } - private const string Category = "DllImportGenerator"; + private const string Category = "SourceGeneration"; public readonly static DiagnosticDescriptor ParameterTypeNotSupported = new DiagnosticDescriptor( diff --git a/DllImportGenerator/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs b/DllImportGenerator/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs index 8366ca698ed9..0cc4f2beb5fd 100644 --- a/DllImportGenerator/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs +++ b/DllImportGenerator/DllImportGenerator/ManualTypeMarshallingAnalyzer.cs @@ -12,10 +12,11 @@ namespace Microsoft.Interop [DiagnosticAnalyzer(LanguageNames.CSharp)] public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer { + public const string Prefix = "DLLIMPORTGENANALYZER"; private const string Category = "Usage"; public readonly static DiagnosticDescriptor BlittableTypeMustBeBlittableRule = new DiagnosticDescriptor( - "INTEROPGEN001", + Prefix + "001", "BlittableTypeMustBeBlittable", new LocalizableResourceString(nameof(Resources.BlittableTypeMustBeBlittableMessage), Resources.ResourceManager, typeof(Resources)), Category, @@ -25,7 +26,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public readonly static DiagnosticDescriptor CannotHaveMultipleMarshallingAttributesRule = new DiagnosticDescriptor( - "INTEROPGEN002", + Prefix + "002", "CannotHaveMultipleMarshallingAttributes", new LocalizableResourceString(nameof(Resources.CannotHaveMultipleMarshallingAttributesMessage), Resources.ResourceManager, typeof(Resources)), Category, @@ -36,7 +37,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public readonly static DiagnosticDescriptor NativeTypeMustBeNonNullRule = new DiagnosticDescriptor( - "INTEROPGEN003", + Prefix + "003", "NativeTypeMustBeNonNull", new LocalizableResourceString(nameof(Resources.NativeTypeMustBeNonNullMessage), Resources.ResourceManager, typeof(Resources)), Category, @@ -46,7 +47,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public readonly static DiagnosticDescriptor NativeTypeMustBeBlittableRule = new DiagnosticDescriptor( - "INTEROPGEN004", + Prefix + "004", "NativeTypeMustBeBlittable", new LocalizableResourceString(nameof(Resources.NativeTypeMustBeBlittableMessage), Resources.ResourceManager, typeof(Resources)), Category, @@ -56,7 +57,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public readonly static DiagnosticDescriptor GetPinnableReferenceReturnTypeBlittableRule = new DiagnosticDescriptor( - "INTEROPGEN005", + Prefix + "005", "GetPinnableReferenceReturnTypeBlittable", new LocalizableResourceString(nameof(Resources.GetPinnableReferenceReturnTypeBlittableMessage), Resources.ResourceManager, typeof(Resources)), Category, @@ -66,7 +67,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public readonly static DiagnosticDescriptor NativeTypeMustBePointerSizedRule = new DiagnosticDescriptor( - "INTEROPGEN006", + Prefix + "006", "NativeTypeMustBePointerSized", new LocalizableResourceString(nameof(Resources.NativeTypeMustBePointerSizedMessage), Resources.ResourceManager, typeof(Resources)), Category, @@ -76,7 +77,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public readonly static DiagnosticDescriptor NativeTypeMustHaveRequiredShapeRule = new DiagnosticDescriptor( - "INTEROPGEN007", + Prefix + "007", "NativeTypeMustHaveRequiredShape", new LocalizableResourceString(nameof(Resources.NativeTypeMustHaveRequiredShapeMessage), Resources.ResourceManager, typeof(Resources)), Category, @@ -86,7 +87,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public readonly static DiagnosticDescriptor ValuePropertyMustHaveSetterRule = new DiagnosticDescriptor( - "INTEROPGEN008", + Prefix + "008", "ValuePropertyMustHaveSetter", new LocalizableResourceString(nameof(Resources.ValuePropertyMustHaveSetterMessage), Resources.ResourceManager, typeof(Resources)), Category, @@ -96,7 +97,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public readonly static DiagnosticDescriptor ValuePropertyMustHaveGetterRule = new DiagnosticDescriptor( - "INTEROPGEN009", + Prefix + "009", "ValuePropertyMustHaveGetter", new LocalizableResourceString(nameof(Resources.ValuePropertyMustHaveGetterMessage), Resources.ResourceManager, typeof(Resources)), Category, @@ -106,7 +107,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public readonly static DiagnosticDescriptor GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackRule = new DiagnosticDescriptor( - "INTEROPGEN010", + Prefix + "010", "GetPinnableReferenceShouldSupportAllocatingMarshallingFallback", new LocalizableResourceString(nameof(Resources.GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackMessage), Resources.ResourceManager, typeof(Resources)), Category, @@ -116,7 +117,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public readonly static DiagnosticDescriptor StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule = new DiagnosticDescriptor( - "INTEROPGEN011", + Prefix + "011", "StackallocMarshallingShouldSupportAllocatingMarshallingFallback", new LocalizableResourceString(nameof(Resources.StackallocMarshallingShouldSupportAllocatingMarshallingFallbackMessage), Resources.ResourceManager, typeof(Resources)), Category, @@ -126,7 +127,7 @@ public class ManualTypeMarshallingAnalyzer : DiagnosticAnalyzer public readonly static DiagnosticDescriptor StackallocConstructorMustHaveStackBufferSizeConstantRule = new DiagnosticDescriptor( - "INTEROPGEN012", + Prefix + "012", "StackallocConstructorMustHaveStackBufferSizeConstant", new LocalizableResourceString(nameof(Resources.StackallocConstructorMustHaveStackBufferSizeConstantMessage), Resources.ResourceManager, typeof(Resources)), Category,