--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using Microsoft.CodeAnalysis;
+
+namespace Microsoft.CodeAnalysis.DotnetRuntime.Extensions
+{
+ internal static partial class DiagnosticDescriptorHelper
+ {
+ public static DiagnosticDescriptor Create(
+ string id,
+ LocalizableString title,
+ LocalizableString messageFormat,
+ string category,
+ DiagnosticSeverity defaultSeverity,
+ bool isEnabledByDefault,
+ LocalizableString? description = null,
+ params string[] customTags)
+ {
+ string helpLink = $"https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/{id.ToLowerInvariant()}.md";
+
+ return new DiagnosticDescriptor(id, title, messageFormat, category, defaultSeverity, isEnabledByDefault, description, helpLink, customTags);
+ }
+ }
+}
using System;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.DotnetRuntime.Extensions;
namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration
{
public static DiagnosticDescriptor MultiDimArraysNotSupported { get; } = CreateTypeNotSupportedDescriptor(nameof(SR.MultiDimArraysNotSupported));
public static DiagnosticDescriptor NullableUnderlyingTypeNotSupported { get; } = CreateTypeNotSupportedDescriptor(nameof(SR.NullableUnderlyingTypeNotSupported));
- public static DiagnosticDescriptor PropertyNotSupported { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor PropertyNotSupported { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1101",
title: new LocalizableResourceString(nameof(SR.PropertyNotSupportedTitle), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Configuration.Binder.SourceGeneration.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.PropertyNotSupportedMessageFormat), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Configuration.Binder.SourceGeneration.SR)),
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true);
- public static DiagnosticDescriptor LanguageVersionNotSupported { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor LanguageVersionNotSupported { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1102",
title: new LocalizableResourceString(nameof(SR.LanguageVersionIsNotSupportedTitle), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Configuration.Binder.SourceGeneration.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.Language_VersionIsNotSupportedMessageFormat), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Configuration.Binder.SourceGeneration.SR)),
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true);
- public static DiagnosticDescriptor ValueTypesInvalidForBind { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor ValueTypesInvalidForBind { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1103",
title: new LocalizableResourceString(nameof(SR.ValueTypesInvalidForBindTitle), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Configuration.Binder.SourceGeneration.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.ValueTypesInvalidForBindMessageFormat), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Configuration.Binder.SourceGeneration.SR)),
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true);
- public static DiagnosticDescriptor CouldNotDetermineTypeInfo { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor CouldNotDetermineTypeInfo { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1104",
title: new LocalizableResourceString(nameof(SR.CouldNotDetermineTypeInfoTitle), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Configuration.Binder.SourceGeneration.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.CouldNotDetermineTypeInfoMessageFormat), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Configuration.Binder.SourceGeneration.SR)),
isEnabledByDefault: true);
private static DiagnosticDescriptor CreateTypeNotSupportedDescriptor(string nameofLocalizableMessageFormat) =>
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
id: "SYSLIB1100",
title: new LocalizableResourceString(nameof(SR.TypeNotSupportedTitle), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Configuration.Binder.SourceGeneration.SR)),
messageFormat: new LocalizableResourceString(nameofLocalizableMessageFormat, SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Configuration.Binder.SourceGeneration.SR)),
<Compile Include="$(CoreLibSharedDir)System\Runtime\CompilerServices\RequiredMemberAttribute.cs" Link="Common\System\Runtime\CompilerServices\RequiredMemberAttribute.cs" />
<Compile Include="$(CoreLibSharedDir)System\Collections\Generic\ValueListBuilder.cs" Link="Production\ValueListBuilder.cs" />
<Compile Include="$(CoreLibSharedDir)System\Collections\Generic\ValueListBuilder.Pop.cs" Link="Production\ValueListBuilder.Pop.cs" />
+ <Compile Include="$(CommonPath)\Roslyn\DiagnosticDescriptorHelper.cs" Link="Common\Roslyn\DiagnosticDescriptorHelper.cs" />
<Compile Include="$(CommonPath)\Roslyn\GetBestTypeByMetadataName.cs" Link="Common\Roslyn\GetBestTypeByMetadataName.cs" />
<Compile Include="$(CommonPath)\SourceGenerators\SourceWriter.cs" Link="Common\SourceGenerators\SourceWriter.cs" />
<Compile Include="ConfigurationBindingGenerator.cs" />
using System;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.DotnetRuntime.Extensions;
namespace Microsoft.Extensions.Logging.Generators
{
public static class DiagnosticDescriptors
{
- public static DiagnosticDescriptor InvalidLoggingMethodName { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor InvalidLoggingMethodName { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1001",
title: new LocalizableResourceString(nameof(SR.InvalidLoggingMethodNameMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.InvalidLoggingMethodNameMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Error,
isEnabledByDefault: true);
- public static DiagnosticDescriptor ShouldntMentionLogLevelInMessage { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor ShouldntMentionLogLevelInMessage { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1002",
title: new LocalizableResourceString(nameof(SR.ShouldntMentionLogLevelInMessageTitle), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.ShouldntMentionInTemplateMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
- public static DiagnosticDescriptor InvalidLoggingMethodParameterName { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor InvalidLoggingMethodParameterName { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1003",
title: new LocalizableResourceString(nameof(SR.InvalidLoggingMethodParameterNameMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.InvalidLoggingMethodParameterNameMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Error,
isEnabledByDefault: true);
- public static DiagnosticDescriptor MissingRequiredType { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor MissingRequiredType { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1005",
title: new LocalizableResourceString(nameof(SR.MissingRequiredTypeTitle), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.MissingRequiredTypeMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Error,
isEnabledByDefault: true);
- public static DiagnosticDescriptor ShouldntReuseEventIds { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor ShouldntReuseEventIds { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1006",
title: new LocalizableResourceString(nameof(SR.ShouldntReuseEventIdsTitle), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.ShouldntReuseEventIdsMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Info,
isEnabledByDefault: true);
- public static DiagnosticDescriptor LoggingMethodMustReturnVoid { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor LoggingMethodMustReturnVoid { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1007",
title: new LocalizableResourceString(nameof(SR.LoggingMethodMustReturnVoidMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.LoggingMethodMustReturnVoidMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Error,
isEnabledByDefault: true);
- public static DiagnosticDescriptor MissingLoggerArgument { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor MissingLoggerArgument { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1008",
title: new LocalizableResourceString(nameof(SR.MissingLoggerArgumentTitle), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.MissingLoggerArgumentMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Error,
isEnabledByDefault: true);
- public static DiagnosticDescriptor LoggingMethodShouldBeStatic { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor LoggingMethodShouldBeStatic { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1009",
title: new LocalizableResourceString(nameof(SR.LoggingMethodShouldBeStaticMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.LoggingMethodShouldBeStaticMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
- public static DiagnosticDescriptor LoggingMethodMustBePartial { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor LoggingMethodMustBePartial { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1010",
title: new LocalizableResourceString(nameof(SR.LoggingMethodMustBePartialMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.LoggingMethodMustBePartialMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Error,
isEnabledByDefault: true);
- public static DiagnosticDescriptor LoggingMethodIsGeneric { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor LoggingMethodIsGeneric { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1011",
title: new LocalizableResourceString(nameof(SR.LoggingMethodIsGenericMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.LoggingMethodIsGenericMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Error,
isEnabledByDefault: true);
- public static DiagnosticDescriptor RedundantQualifierInMessage { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor RedundantQualifierInMessage { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1012",
title: new LocalizableResourceString(nameof(SR.RedundantQualifierInMessageTitle), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.RedundantQualifierInMessageMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
- public static DiagnosticDescriptor ShouldntMentionExceptionInMessage { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor ShouldntMentionExceptionInMessage { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1013",
title: new LocalizableResourceString(nameof(SR.ShouldntMentionExceptionInMessageTitle), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.ShouldntMentionInTemplateMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
- public static DiagnosticDescriptor TemplateHasNoCorrespondingArgument { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor TemplateHasNoCorrespondingArgument { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1014",
title: new LocalizableResourceString(nameof(SR.TemplateHasNoCorrespondingArgumentTitle), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.TemplateHasNoCorrespondingArgumentMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Error,
isEnabledByDefault: true);
- public static DiagnosticDescriptor ArgumentHasNoCorrespondingTemplate { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor ArgumentHasNoCorrespondingTemplate { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1015",
title: new LocalizableResourceString(nameof(SR.ArgumentHasNoCorrespondingTemplateTitle), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.ArgumentHasNoCorrespondingTemplateMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
- public static DiagnosticDescriptor LoggingMethodHasBody { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor LoggingMethodHasBody { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1016",
title: new LocalizableResourceString(nameof(SR.LoggingMethodHasBodyMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.LoggingMethodHasBodyMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Error,
isEnabledByDefault: true);
- public static DiagnosticDescriptor MissingLogLevel { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor MissingLogLevel { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1017",
title: new LocalizableResourceString(nameof(SR.MissingLogLevelMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.MissingLogLevelMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Error,
isEnabledByDefault: true);
- public static DiagnosticDescriptor ShouldntMentionLoggerInMessage { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor ShouldntMentionLoggerInMessage { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1018",
title: new LocalizableResourceString(nameof(SR.ShouldntMentionLoggerInMessageTitle), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.ShouldntMentionInTemplateMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
- public static DiagnosticDescriptor MissingLoggerField { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor MissingLoggerField { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1019",
title: new LocalizableResourceString(nameof(SR.MissingLoggerFieldTitle), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.MissingLoggerFieldMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Error,
isEnabledByDefault: true);
- public static DiagnosticDescriptor MultipleLoggerFields { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor MultipleLoggerFields { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1020",
title: new LocalizableResourceString(nameof(SR.MultipleLoggerFieldsTitle), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.MultipleLoggerFieldsMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Error,
isEnabledByDefault: true);
- public static DiagnosticDescriptor InconsistentTemplateCasing { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor InconsistentTemplateCasing { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1021",
title: new LocalizableResourceString(nameof(SR.InconsistentTemplateCasingMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.InconsistentTemplateCasingMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Error,
isEnabledByDefault: true);
- public static DiagnosticDescriptor MalformedFormatStrings { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor MalformedFormatStrings { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1022",
title: new LocalizableResourceString(nameof(SR.MalformedFormatStringsTitle), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.MalformedFormatStringsMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Error,
isEnabledByDefault: true);
- public static DiagnosticDescriptor GeneratingForMax6Arguments { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor GeneratingForMax6Arguments { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1023",
title: new LocalizableResourceString(nameof(SR.GeneratingForMax6ArgumentsMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.GeneratingForMax6ArgumentsMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Error,
isEnabledByDefault: true);
- public static DiagnosticDescriptor InvalidLoggingMethodParameterOut { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor InvalidLoggingMethodParameterOut { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1024",
title: new LocalizableResourceString(nameof(SR.InvalidLoggingMethodParameterOutTitle), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.InvalidLoggingMethodParameterOutMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
DiagnosticSeverity.Error,
isEnabledByDefault: true);
- public static DiagnosticDescriptor ShouldntReuseEventNames { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor ShouldntReuseEventNames { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1025",
title: new LocalizableResourceString(nameof(SR.ShouldntReuseEventNamesTitle), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.ShouldntReuseEventNamesMessage), SR.ResourceManager, typeof(FxResources.Microsoft.Extensions.Logging.Generators.SR)),
</ItemGroup>
<ItemGroup>
+ <Compile Include="$(CommonPath)\Roslyn\DiagnosticDescriptorHelper.cs" Link="Common\Roslyn\DiagnosticDescriptorHelper.cs" />
<Compile Include="$(CommonPath)\Roslyn\GetBestTypeByMetadataName.cs" Link="Common\Roslyn\GetBestTypeByMetadataName.cs" />
</ItemGroup>
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.DotnetRuntime.Extensions;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
private const string Category = "JSImportGenerator";
public static readonly DiagnosticDescriptor ConfigurationNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitle)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessage)),
description: GetResourceString(nameof(SR.ConfigurationNotSupportedDescription)));
public static readonly DiagnosticDescriptor ConfigurationValueNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitle)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageValue)),
description: GetResourceString(nameof(SR.ConfigurationNotSupportedDescription)));
public static readonly DiagnosticDescriptor MarshallingAttributeConfigurationNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitle)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageMarshallingInfo)),
description: GetResourceString(nameof(SR.ConfigurationNotSupportedDescription)));
public static readonly DiagnosticDescriptor ReturnTypeNotSupportedWithDetails =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.TypeNotSupported,
GetResourceString(nameof(SR.TypeNotSupportedTitle)),
GetResourceString(nameof(SR.TypeNotSupportedMessageReturnWithDetails)),
description: GetResourceString(nameof(SR.TypeNotSupportedDescription)));
public static readonly DiagnosticDescriptor ParameterTypeNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.TypeNotSupported,
GetResourceString(nameof(SR.TypeNotSupportedTitle)),
GetResourceString(nameof(SR.TypeNotSupportedMessageParameter)),
description: GetResourceString(nameof(SR.TypeNotSupportedDescription)));
public static readonly DiagnosticDescriptor ReturnTypeNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.TypeNotSupported,
GetResourceString(nameof(SR.TypeNotSupportedTitle)),
GetResourceString(nameof(SR.TypeNotSupportedMessageReturn)),
description: GetResourceString(nameof(SR.TypeNotSupportedDescription)));
public static readonly DiagnosticDescriptor ParameterTypeNotSupportedWithDetails =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.TypeNotSupported,
GetResourceString(nameof(SR.TypeNotSupportedTitle)),
GetResourceString(nameof(SR.TypeNotSupportedMessageParameterWithDetails)),
description: GetResourceString(nameof(SR.TypeNotSupportedDescription)));
public static readonly DiagnosticDescriptor ParameterConfigurationNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitle)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageParameter)),
description: GetResourceString(nameof(SR.ConfigurationNotSupportedDescription)));
public static readonly DiagnosticDescriptor ReturnConfigurationNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitle)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageReturn)),
description: GetResourceString(nameof(SR.ConfigurationNotSupportedDescription)));
public static readonly DiagnosticDescriptor InvalidImportAttributedMethodSignature =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidJSImportAttributeUsage,
GetResourceString(nameof(SR.InvalidJSImportAttributeUsageTitle)),
GetResourceString(nameof(SR.InvalidJSImportAttributedMethodSignatureMessage)),
description: GetResourceString(nameof(SR.InvalidJSImportAttributedMethodDescription)));
public static readonly DiagnosticDescriptor InvalidExportAttributedMethodSignature =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidJSExportAttributeUsage,
GetResourceString(nameof(SR.InvalidJSExportAttributeUsageTitle)),
GetResourceString(nameof(SR.InvalidJSExportAttributedMethodSignatureMessage)),
description: GetResourceString(nameof(SR.InvalidJSExportAttributedMethodDescription)));
public static readonly DiagnosticDescriptor InvalidImportAttributedMethodContainingTypeMissingModifiers =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidJSImportAttributeUsage,
GetResourceString(nameof(SR.InvalidJSImportAttributeUsageTitle)),
GetResourceString(nameof(SR.InvalidAttributedMethodContainingTypeMissingModifiersMessage)),
description: GetResourceString(nameof(SR.InvalidJSImportAttributedMethodDescription)));
public static readonly DiagnosticDescriptor InvalidExportAttributedMethodContainingTypeMissingModifiers =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidJSExportAttributeUsage,
GetResourceString(nameof(SR.InvalidJSExportAttributeUsageTitle)),
GetResourceString(nameof(SR.InvalidAttributedMethodContainingTypeMissingModifiersMessage)),
description: GetResourceString(nameof(SR.InvalidJSExportAttributedMethodDescription)));
public static readonly DiagnosticDescriptor JSImportRequiresAllowUnsafeBlocks =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.JSImportRequiresAllowUnsafeBlocks,
GetResourceString(nameof(SR.JSImportRequiresAllowUnsafeBlocksTitle)),
GetResourceString(nameof(SR.JSImportRequiresAllowUnsafeBlocksMessage)),
description: GetResourceString(nameof(SR.JSImportRequiresAllowUnsafeBlocksDescription)));
public static readonly DiagnosticDescriptor JSExportRequiresAllowUnsafeBlocks =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.JSExportRequiresAllowUnsafeBlocks,
GetResourceString(nameof(SR.JSExportRequiresAllowUnsafeBlocksTitle)),
GetResourceString(nameof(SR.JSExportRequiresAllowUnsafeBlocksMessage)),
<ItemGroup>
<Folder Include="Resources\xlf\" />
+ <Compile Include="$(CommonPath)Roslyn\DiagnosticDescriptorHelper.cs" Link="Common\Roslyn\DiagnosticDescriptorHelper.cs" />
<Compile Include="$(LibrariesProjectRoot)System.Runtime.InteropServices.JavaScript\src\System\Runtime\InteropServices\JavaScript\MarshalerType.cs" Link="System\Runtime\InteropServices\JavaScript\MarshalerType.cs" />
</ItemGroup>
using System;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.DotnetRuntime.Extensions;
+
namespace Microsoft.Interop.Analyzers
{
public static class AnalyzerDiagnostics
}
public static readonly DiagnosticDescriptor ConvertToGeneratedComInterface =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.ConvertToGeneratedComInterface,
GetResourceString(nameof(SR.ConvertToGeneratedComInterfaceTitle)),
GetResourceString(nameof(SR.ConvertToGeneratedComInterfaceMessage)),
description: GetResourceString(nameof(SR.ConvertToGeneratedComInterfaceDescription)));
public static readonly DiagnosticDescriptor AddGeneratedComClassAttribute =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.AddGeneratedComClassAttribute,
GetResourceString(nameof(SR.AddGeneratedComClassAttributeTitle)),
GetResourceString(nameof(SR.AddGeneratedComClassAttributeMessage)),
description: GetResourceString(nameof(SR.AddGeneratedComClassAttributeDescription)));
public static readonly DiagnosticDescriptor ComHostingDoesNotSupportGeneratedComInterface =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.ComHostingDoesNotSupportGeneratedComInterface,
GetResourceString(nameof(SR.ComHostingDoesNotSupportGeneratedComInterfaceTitle)),
GetResourceString(nameof(SR.ComHostingDoesNotSupportGeneratedComInterfaceMessage)),
description: GetResourceString(nameof(SR.ComHostingDoesNotSupportGeneratedComInterfaceDescription)));
public static readonly DiagnosticDescriptor RuntimeComApisDoNotSupportSourceGeneratedCom =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.RuntimeComAndGeneratedComDoNotMix,
GetResourceString(nameof(SR.RuntimeComApisDoNotSupportSourceGeneratedComTitle)),
GetResourceString(nameof(SR.RuntimeComApisDoNotSupportSourceGeneratedComMessage)),
description: GetResourceString(nameof(SR.RuntimeComApisDoNotSupportSourceGeneratedComDescription)));
public static readonly DiagnosticDescriptor CastsBetweenRuntimeComAndSourceGeneratedComNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.RuntimeComAndGeneratedComDoNotMix,
GetResourceString(nameof(SR.CastsBetweenRuntimeComAndSourceGeneratedComNotSupportedTitle)),
GetResourceString(nameof(SR.CastsBetweenRuntimeComAndSourceGeneratedComNotSupportedMessage)),
<Compile Include="$(LibrariesProjectRoot)System.Runtime.InteropServices\src\System\Runtime\InteropServices\Marshalling\ComInterfaceOptions.cs" Link="Production\ComInterfaceOptions.cs" />
<Compile Include="..\Common\DefaultMarshallingInfoParser.cs" Link="Common\DefaultMarshallingInfoParser.cs" />
<Compile Include="..\..\tests\Common\ExceptionMarshalling.cs" Link="Common\ExceptionMarshalling.cs" />
+ <Compile Include="$(CommonPath)\Roslyn\DiagnosticDescriptorHelper.cs" Link="Common\Roslyn\DiagnosticDescriptorHelper.cs" />
<Compile Include="$(CommonPath)\Roslyn\GetBestTypeByMetadataName.cs" Link="Common\Roslyn\GetBestTypeByMetadataName.cs" />
<Compile Include="..\Common\OperationExtensions.cs" Link="Common\OperationExtensions.cs" />
<Compile Include="..\Common\ConvertToSourceGeneratedInteropFixer.cs" Link="Common\ConvertToSourceGeneratedInteropFixer.cs" />
using System;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.DotnetRuntime.Extensions;
namespace Microsoft.Interop
{
/// <inheritdoc cref="SR.RequiresAllowUnsafeBlocksMessageCom"/>
public static readonly DiagnosticDescriptor RequiresAllowUnsafeBlocks =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.RequiresAllowUnsafeBlocks,
GetResourceString(nameof(SR.RequiresAllowUnsafeBlocksTitleCom)),
GetResourceString(nameof(SR.RequiresAllowUnsafeBlocksMessageCom)),
/// <inheritdoc cref="SR.InvalidAttributedMethodSignatureMessageCom"/>
public static readonly DiagnosticDescriptor InvalidAttributedMethodSignature =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidLibraryImportAttributeUsage,
GetResourceString(nameof(SR.InvalidVirtualMethodIndexAttributeUsage)),
GetResourceString(nameof(SR.InvalidAttributedMethodSignatureMessageCom)),
/// <inheritdoc cref="SR.InvalidAttributedMethodContainingTypeMissingModifiersMessageCom"/>
public static readonly DiagnosticDescriptor InvalidAttributedMethodContainingTypeMissingModifiers =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidLibraryImportAttributeUsage,
GetResourceString(nameof(SR.InvalidVirtualMethodIndexAttributeUsage)),
GetResourceString(nameof(SR.InvalidAttributedMethodContainingTypeMissingModifiersMessageCom)),
/// <inheritdoc cref="SR.InvalidGeneratedComInterfaceUsageMissingPartialModifier"/>
public static readonly DiagnosticDescriptor InvalidAttributedInterfaceMissingPartialModifiers =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidGeneratedComInterfaceAttributeUsage,
GetResourceString(nameof(SR.InvalidGeneratedComInterfaceAttributeUsageTitle)),
GetResourceString(nameof(SR.InvalidGeneratedComInterfaceUsageMissingPartialModifier)),
/// <inheritdoc cref="SR.InvalidAttributedMethodContainingTypeMissingUnmanagedObjectUnwrapperAttributeMessage"/>
public static readonly DiagnosticDescriptor InvalidAttributedMethodContainingTypeMissingUnmanagedObjectUnwrapperAttribute =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidLibraryImportAttributeUsage,
GetResourceString(nameof(SR.InvalidVirtualMethodIndexAttributeUsage)),
GetResourceString(nameof(SR.InvalidAttributedMethodContainingTypeMissingUnmanagedObjectUnwrapperAttributeMessage)),
/// <inheritdoc cref="SR.InvalidStringMarshallingConfigurationOnInterfaceMessage"/>
public static readonly DiagnosticDescriptor InvalidStringMarshallingMismatchBetweenBaseAndDerived =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidGeneratedComInterfaceAttributeUsage,
GetResourceString(nameof(SR.InvalidGeneratedComInterfaceAttributeUsageTitle)),
GetResourceString(nameof(SR.InvalidStringMarshallingConfigurationOnInterfaceMessage)),
/// <inheritdoc cref="SR.InvalidOptionsOnInterfaceMessage"/>
public static readonly DiagnosticDescriptor InvalidOptionsOnInterface =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidGeneratedComInterfaceAttributeUsage,
GetResourceString(nameof(SR.InvalidGeneratedComInterfaceAttributeUsageTitle)),
GetResourceString(nameof(SR.InvalidOptionsOnInterfaceMessage)),
/// <inheritdoc cref="SR.InvalidStringMarshallingConfigurationOnMethodMessage"/>
public static readonly DiagnosticDescriptor InvalidStringMarshallingConfigurationOnMethod =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidLibraryImportAttributeUsage,
GetResourceString(nameof(SR.InvalidVirtualMethodIndexAttributeUsage)),
GetResourceString(nameof(SR.InvalidStringMarshallingConfigurationOnMethodMessage)),
/// <inheritdoc cref="SR.InvalidStringMarshallingConfigurationOnInterfaceMessage"/>
public static readonly DiagnosticDescriptor InvalidStringMarshallingConfigurationOnInterface =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidGeneratedComInterfaceAttributeUsage,
GetResourceString(nameof(SR.InvalidGeneratedComInterfaceAttributeUsageTitle)),
GetResourceString(nameof(SR.InvalidStringMarshallingConfigurationOnInterfaceMessage)),
/// <inheritdoc cref="SR.StringMarshallingCustomTypeNotAccessibleByGeneratedCode"/>
public static readonly DiagnosticDescriptor StringMarshallingCustomTypeNotAccessibleByGeneratedCode =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidGeneratedComInterfaceAttributeUsage,
GetResourceString(nameof(SR.InvalidGeneratedComInterfaceAttributeUsageTitle)),
GetResourceString(nameof(SR.StringMarshallingCustomTypeNotAccessibleByGeneratedCode)),
/// <inheritdoc cref="SR.InvalidExceptionMarshallingConfigurationMessage"/>
public static readonly DiagnosticDescriptor InvalidExceptionMarshallingConfiguration =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidLibraryImportAttributeUsage,
GetResourceString(nameof(SR.InvalidVirtualMethodIndexAttributeUsage)),
GetResourceString(nameof(SR.InvalidExceptionMarshallingConfigurationMessage)),
/// <inheritdoc cref="SR.TypeNotSupportedMessageParameterCom"/>
public static readonly DiagnosticDescriptor ParameterTypeNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.TypeNotSupported,
GetResourceString(nameof(SR.TypeNotSupportedTitleCom)),
GetResourceString(nameof(SR.TypeNotSupportedMessageParameterCom)),
/// <inheritdoc cref="SR.TypeNotSupportedMessageReturnCom"/>
public static readonly DiagnosticDescriptor ReturnTypeNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.TypeNotSupported,
GetResourceString(nameof(SR.TypeNotSupportedTitleCom)),
GetResourceString(nameof(SR.TypeNotSupportedMessageReturnCom)),
/// <inheritdoc cref="SR.TypeNotSupportedMessageParameterWithDetails"/>
public static readonly DiagnosticDescriptor ParameterTypeNotSupportedWithDetails =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.TypeNotSupported,
GetResourceString(nameof(SR.TypeNotSupportedTitleCom)),
GetResourceString(nameof(SR.TypeNotSupportedMessageParameterWithDetails)),
/// <inheritdoc cref="SR.TypeNotSupportedMessageReturnWithDetails"/>
public static readonly DiagnosticDescriptor ReturnTypeNotSupportedWithDetails =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.TypeNotSupported,
GetResourceString(nameof(SR.TypeNotSupportedTitleCom)),
GetResourceString(nameof(SR.TypeNotSupportedMessageReturnWithDetails)),
/// <inheritdoc cref="SR.ConfigurationNotSupportedMessageParameterCom"/>
public static readonly DiagnosticDescriptor ParameterConfigurationNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitleCom)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageParameterCom)),
/// <inheritdoc cref="SR.ConfigurationNotSupportedMessageReturnCom"/>
public static readonly DiagnosticDescriptor ReturnConfigurationNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitleCom)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageReturnCom)),
/// <inheritdoc cref="SR.MarshalAsConfigurationNotSupportedMessageParameterCom"/>
public static readonly DiagnosticDescriptor MarshalAsParameterConfigurationNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
GeneratorDiagnostics.Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitleCom)),
GetResourceString(nameof(SR.MarshalAsConfigurationNotSupportedMessageParameterCom)),
/// <inheritdoc cref="SR.MarshalAsConfigurationNotSupportedMessageReturnCom"/>
public static readonly DiagnosticDescriptor MarshalAsReturnConfigurationNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
GeneratorDiagnostics.Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitleCom)),
GetResourceString(nameof(SR.MarshalAsConfigurationNotSupportedMessageReturnCom)),
/// <inheritdoc cref="SR.ConfigurationNotSupportedMessageCom"/>
public static readonly DiagnosticDescriptor ConfigurationNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitleCom)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageCom)),
/// <inheritdoc cref="SR.ConfigurationNotSupportedMessageValueCom"/>
public static readonly DiagnosticDescriptor ConfigurationValueNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitleCom)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageValueCom)),
/// <inheritdoc cref="SR.ConfigurationNotSupportedMessageMarshallingInfoCom"/>
public static readonly DiagnosticDescriptor MarshallingAttributeConfigurationNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitleCom)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageMarshallingInfoCom)),
/// <inheritdoc cref="SR.MethodNotDeclaredInAttributedInterfaceMessage"/>
public static readonly DiagnosticDescriptor MethodNotDeclaredInAttributedInterface =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.MemberWillNotBeSourceGenerated,
GetResourceString(nameof(SR.MethodNotDeclaredInAttributedInterfaceTitle)),
GetResourceString(nameof(SR.MethodNotDeclaredInAttributedInterfaceMessage)),
/// <inheritdoc cref="SR.InstancePropertyDeclaredInInterfaceMessage"/>
public static readonly DiagnosticDescriptor InstancePropertyDeclaredInInterface =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.MemberWillNotBeSourceGenerated,
GetResourceString(nameof(SR.InstancePropertyDeclaredInInterfaceTitle)),
GetResourceString(nameof(SR.InstancePropertyDeclaredInInterfaceMessage)),
/// <inheritdoc cref="SR.InstanceEventDeclaredInInterfaceMessage"/>
public static readonly DiagnosticDescriptor InstanceEventDeclaredInInterface =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.MemberWillNotBeSourceGenerated,
GetResourceString(nameof(SR.InstanceEventDeclaredInInterfaceTitle)),
GetResourceString(nameof(SR.InstanceEventDeclaredInInterfaceMessage)),
/// <inheritdoc cref="SR.InvalidGeneratedComInterfaceAttributeUsageInterfaceNotAccessible"/>
public static readonly DiagnosticDescriptor InvalidAttributedInterfaceNotAccessible =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidGeneratedComInterfaceAttributeUsage,
GetResourceString(nameof(SR.InvalidGeneratedComInterfaceAttributeUsageTitle)),
GetResourceString(nameof(SR.InvalidGeneratedComInterfaceAttributeUsageInterfaceNotAccessible)),
/// <inheritdoc cref="SR.InvalidGeneratedComInterfaceAttributeUsageMissingGuidAttribute"/>
public static readonly DiagnosticDescriptor InvalidAttributedInterfaceMissingGuidAttribute =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidGeneratedComInterfaceAttributeUsage,
GetResourceString(nameof(SR.InvalidGeneratedComInterfaceAttributeUsageTitle)),
GetResourceString(nameof(SR.InvalidGeneratedComInterfaceAttributeUsageMissingGuidAttribute)),
/// <inheritdoc cref="SR.InvalidGeneratedComInterfaceAttributeUsageInterfaceIsGeneric"/>
public static readonly DiagnosticDescriptor InvalidAttributedInterfaceGenericNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidGeneratedComInterfaceAttributeUsage,
GetResourceString(nameof(SR.InvalidGeneratedComInterfaceAttributeUsageTitle)),
GetResourceString(nameof(SR.InvalidGeneratedComInterfaceAttributeUsageInterfaceIsGeneric)),
/// <inheritdoc cref="SR.MultipleComInterfaceBaseTypesMessage"/>
public static readonly DiagnosticDescriptor MultipleComInterfaceBaseTypes =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidGeneratedComInterfaceAttributeUsage,
GetResourceString(nameof(SR.MultipleComInterfaceBaseTypesTitle)),
GetResourceString(nameof(SR.MultipleComInterfaceBaseTypesMessage)),
/// <inheritdoc cref="SR.AnalysisFailedMethodMessage"/>
public static readonly DiagnosticDescriptor CannotAnalyzeMethodPattern =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.AnalysisFailed,
GetResourceString(nameof(SR.AnalysisFailedTitle)),
GetResourceString(nameof(SR.AnalysisFailedMethodMessage)),
/// <inheritdoc cref="SR.AnalysisFailedInterfaceMessage"/>
public static readonly DiagnosticDescriptor CannotAnalyzeInterfacePattern =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.AnalysisFailed,
GetResourceString(nameof(SR.AnalysisFailedTitle)),
GetResourceString(nameof(SR.AnalysisFailedInterfaceMessage)),
/// <inheritdoc cref="SR.BaseInterfaceCannotBeGeneratedMessage"/>
public static readonly DiagnosticDescriptor BaseInterfaceIsNotGenerated =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.BaseInterfaceFailedGeneration,
GetResourceString(nameof(SR.BaseInterfaceCannotBeGeneratedTitle)),
GetResourceString(nameof(SR.BaseInterfaceCannotBeGeneratedMessage)),
/// <inheritdoc cref="SR.InvalidGeneratedComClassAttributeUsageMissingPartialModifier"/>
public static readonly DiagnosticDescriptor InvalidAttributedClassMissingPartialModifier =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidGeneratedComClassAttributeUsage,
GetResourceString(nameof(SR.InvalidGeneratedComClassAttributeUsageTitle)),
GetResourceString(nameof(SR.InvalidGeneratedComClassAttributeUsageMissingPartialModifier)),
/// <inheritdoc cref="SR.InterfaceTypeNotSupportedMessage"/>
public static readonly DiagnosticDescriptor InterfaceTypeNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidGeneratedComInterfaceAttributeUsage,
GetResourceString(nameof(SR.InterfaceTypeNotSupportedTitle)),
GetResourceString(nameof(SR.InterfaceTypeNotSupportedMessage)),
/// <inheritdoc cref="SR.ClassDoesNotImplementAnyGeneratedComInterfacesMessage"/>
public static readonly DiagnosticDescriptor ClassDoesNotImplementAnyGeneratedComInterface =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidGeneratedComClassAttributeUsage,
GetResourceString(nameof(SR.InvalidGeneratedComClassAttributeUsageTitle)),
GetResourceString(nameof(SR.ClassDoesNotImplementAnyGeneratedComInterfacesMessage)),
/// <inheritdoc cref="SR.UnnecessaryParameterMarshallingInfoMessage"/>
public static readonly DiagnosticDescriptor UnnecessaryParameterMarshallingInfo =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.UnnecessaryMarshallingInfo,
GetResourceString(nameof(SR.UnnecessaryMarshallingInfoTitle)),
GetResourceString(nameof(SR.UnnecessaryParameterMarshallingInfoMessage)),
/// <inheritdoc cref="SR.UnnecessaryReturnMarshallingInfoMessage"/>
public static readonly DiagnosticDescriptor UnnecessaryReturnMarshallingInfo =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.UnnecessaryMarshallingInfo,
GetResourceString(nameof(SR.UnnecessaryMarshallingInfoTitle)),
GetResourceString(nameof(SR.UnnecessaryReturnMarshallingInfoMessage)),
/// <inheritdoc cref="SR.SizeOfCollectionMustBeKnownAtMarshalTimeMessageOutParam"/>
public static readonly DiagnosticDescriptor SizeOfInCollectionMustBeDefinedAtCallOutParam =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidGeneratedComInterfaceAttributeUsage,
GetResourceString(nameof(SR.SizeOfCollectionMustBeKnownAtMarshalTimeTitle)),
GetResourceString(nameof(SR.SizeOfCollectionMustBeKnownAtMarshalTimeMessageOutParam)),
/// <inheritdoc cref="SR.SizeOfCollectionMustBeKnownAtMarshalTimeMessageReturnValue"/>
public static readonly DiagnosticDescriptor SizeOfInCollectionMustBeDefinedAtCallReturnValue =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidGeneratedComInterfaceAttributeUsage,
GetResourceString(nameof(SR.SizeOfCollectionMustBeKnownAtMarshalTimeTitle)),
GetResourceString(nameof(SR.SizeOfCollectionMustBeKnownAtMarshalTimeMessageReturnValue)),
/// <inheritdoc cref="SR.ComMethodReturningIntWillBeOutParameterMessage"/>
public static readonly DiagnosticDescriptor ComMethodManagedReturnWillBeOutVariable =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.NotRecommendedGeneratedComInterfaceUsage,
GetResourceString(nameof(SR.ComMethodReturningIntWillBeOutParameterTitle)),
GetResourceString(nameof(SR.ComMethodReturningIntWillBeOutParameterMessage)),
private const string Category = "Interoperability";
public static readonly DiagnosticDescriptor ConvertToLibraryImport =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.ConvertToLibraryImport,
GetResourceString(nameof(SR.ConvertToLibraryImportTitle)),
GetResourceString(nameof(SR.ConvertToLibraryImportMessage)),
/// <inheritdoc cref="SR.MarshallerTypeMustSpecifyManagedTypeMessage" />
public static readonly DiagnosticDescriptor MarshallerTypeMustSpecifyManagedTypeRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidCustomMarshallerAttributeUsage,
GetResourceString(nameof(SR.InvalidCustomMarshallerAttributeUsageTitle)),
GetResourceString(nameof(SR.MarshallerTypeMustSpecifyManagedTypeMessage)),
/// <inheritdoc cref="SR.MarshallerTypeMustBeStaticClassOrStructMessage" />
public static readonly DiagnosticDescriptor MarshallerTypeMustBeStaticClassOrStructRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidMarshallerType,
GetResourceString(nameof(SR.InvalidMarshallerTypeTitle)),
GetResourceString(nameof(SR.MarshallerTypeMustBeStaticClassOrStructMessage)),
/// <inheritdoc cref="SR.ElementMarshallerCannotBeStatefulMessage" />
public static readonly DiagnosticDescriptor ElementMarshallerCannotBeStatefulRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidMarshallerType,
GetResourceString(nameof(SR.InvalidMarshallerTypeTitle)),
GetResourceString(nameof(SR.ElementMarshallerCannotBeStatefulMessage)),
/// <inheritdoc cref="SR.TypeMustBeUnmanagedMessage" />
public static readonly DiagnosticDescriptor UnmanagedTypeMustBeUnmanagedRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidNativeType,
GetResourceString(nameof(SR.InvalidMarshallerTypeTitle)),
GetResourceString(nameof(SR.TypeMustBeUnmanagedMessage)),
/// <inheritdoc cref="SR.GetPinnableReferenceReturnTypeBlittableMessage" />
public static readonly DiagnosticDescriptor GetPinnableReferenceReturnTypeBlittableRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidSignaturesInMarshallerShape,
GetResourceString(nameof(SR.InvalidSignaturesInMarshallerShapeTitle)),
GetResourceString(nameof(SR.GetPinnableReferenceReturnTypeBlittableMessage)),
/// <inheritdoc cref="SR.TypeMustHaveExplicitCastFromVoidPointerMessage" />
public static readonly DiagnosticDescriptor TypeMustHaveExplicitCastFromVoidPointerRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidNativeType,
GetResourceString(nameof(SR.InvalidMarshallerTypeTitle)),
GetResourceString(nameof(SR.TypeMustHaveExplicitCastFromVoidPointerMessage)),
/// <inheritdoc cref="SR.StatelessValueInRequiresConvertToUnmanagedMessage" />
public static readonly DiagnosticDescriptor StatelessValueInRequiresConvertToUnmanagedRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.StatelessValueInRequiresConvertToUnmanagedMessage)),
/// <inheritdoc cref="SR.StatelessLinearCollectionRequiresTwoParameterAllocateContainerForUnmanagedElementsMessage" />
public static readonly DiagnosticDescriptor StatelessLinearCollectionRequiresTwoParameterAllocateContainerForUnmanagedElementsRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.StatelessLinearCollectionRequiresTwoParameterAllocateContainerForUnmanagedElementsMessage)),
/// <inheritdoc cref="SR.OutRequiresToManagedMessage" />
public static readonly DiagnosticDescriptor OutRequiresToManagedRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.OutRequiresToManagedMessage)),
/// <inheritdoc cref="SR.StatelessRequiresConvertToManagedMessage" />
public static readonly DiagnosticDescriptor StatelessRequiresConvertToManagedRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.StatelessRequiresConvertToManagedMessage)),
/// <inheritdoc cref="SR.LinearCollectionInRequiresCollectionMethodsMessage" />
public static readonly DiagnosticDescriptor LinearCollectionInRequiresCollectionMethodsRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.LinearCollectionInRequiresCollectionMethodsMessage)),
/// <inheritdoc cref="SR.StatelessLinearCollectionInRequiresCollectionMethodsMessage" />
public static readonly DiagnosticDescriptor StatelessLinearCollectionInRequiresCollectionMethodsRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.StatelessLinearCollectionInRequiresCollectionMethodsMessage)),
/// <inheritdoc cref="SR.LinearCollectionOutRequiresCollectionMethodsMessage" />
public static readonly DiagnosticDescriptor LinearCollectionOutRequiresCollectionMethodsRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.LinearCollectionOutRequiresCollectionMethodsMessage)),
/// <inheritdoc cref="SR.StatelessLinearCollectionOutRequiresCollectionMethodsMessage" />
public static readonly DiagnosticDescriptor StatelessLinearCollectionOutRequiresCollectionMethodsRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.StatelessLinearCollectionOutRequiresCollectionMethodsMessage)),
/// <inheritdoc cref="SR.StatelessLinearCollectionRequiresTwoParameterAllocateContainerForManagedElementsMessage" />
public static readonly DiagnosticDescriptor StatelessLinearCollectionRequiresTwoParameterAllocateContainerForManagedElementsRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.StatelessLinearCollectionRequiresTwoParameterAllocateContainerForManagedElementsMessage)),
/// <inheritdoc cref="SR.CallerAllocFromManagedMustHaveBufferSizeMessage" />
public static readonly DiagnosticDescriptor CallerAllocFromManagedMustHaveBufferSizeRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.CallerAllocFromManagedMustHaveBufferSizeMessage)),
/// <inheritdoc cref="SR.StatelessLinearCollectionCallerAllocFromManagedMustHaveBufferSizeMessage" />
public static readonly DiagnosticDescriptor StatelessLinearCollectionCallerAllocFromManagedMustHaveBufferSizeRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.StatelessLinearCollectionCallerAllocFromManagedMustHaveBufferSizeMessage)),
/// <inheritdoc cref="SR.StatefulMarshallerRequiresFromManagedMessage" />
public static readonly DiagnosticDescriptor StatefulMarshallerRequiresFromManagedRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.StatefulMarshallerRequiresFromManagedMessage)),
/// <inheritdoc cref="SR.StatefulMarshallerRequiresToUnmanagedMessage" />
public static readonly DiagnosticDescriptor StatefulMarshallerRequiresToUnmanagedRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.StatefulMarshallerRequiresToUnmanagedMessage)),
/// <inheritdoc cref="SR.StatefulMarshallerRequiresToManagedMessage" />
public static readonly DiagnosticDescriptor StatefulMarshallerRequiresToManagedRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.StatefulMarshallerRequiresToManagedMessage)),
/// <inheritdoc cref="SR.StatefulMarshallerRequiresFromUnmanagedMessage" />
public static readonly DiagnosticDescriptor StatefulMarshallerRequiresFromUnmanagedRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.StatefulMarshallerRequiresFromUnmanagedMessage)),
/// <inheritdoc cref="SR.StatefulMarshallerRequiresFreeMessage" />
public static readonly DiagnosticDescriptor StatefulMarshallerRequiresFreeRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.StatefulMarshallerRequiresFreeMessage)),
/// <inheritdoc cref="SR.FromUnmanagedOverloadsNotSupportedMessage" />
public static readonly DiagnosticDescriptor FromUnmanagedOverloadsNotSupportedRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.FromUnmanagedOverloadsNotSupportedMessage)),
/// <inheritdoc cref="SR.MarshallerTypeMustBeClosedOrMatchArityMessage" />
public static readonly DiagnosticDescriptor MarshallerTypeMustBeClosedOrMatchArityRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidCustomMarshallerAttributeUsage,
GetResourceString(nameof(SR.InvalidMarshallerTypeTitle)),
GetResourceString(nameof(SR.MarshallerTypeMustBeClosedOrMatchArityMessage)),
/// <inheritdoc cref="SR.MarshallerTypeMustBeNonNullMessage" />
public static readonly DiagnosticDescriptor MarshallerTypeMustBeNonNullRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidCustomMarshallerAttributeUsage,
GetResourceString(nameof(SR.InvalidMarshallerTypeTitle)),
GetResourceString(nameof(SR.MarshallerTypeMustBeNonNullMessage)),
/// <inheritdoc cref="SR.FirstParameterMustMatchReturnTypeMessage" />
public static readonly DiagnosticDescriptor FirstParameterMustMatchReturnTypeRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidSignaturesInMarshallerShape,
GetResourceString(nameof(SR.InvalidSignaturesInMarshallerShapeTitle)),
GetResourceString(nameof(SR.FirstParameterMustMatchReturnTypeMessage)),
/// <inheritdoc cref="SR.ReturnTypesMustMatchMessage" />
public static readonly DiagnosticDescriptor ReturnTypesMustMatchRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidSignaturesInMarshallerShape,
GetResourceString(nameof(SR.InvalidSignaturesInMarshallerShapeTitle)),
GetResourceString(nameof(SR.ReturnTypesMustMatchMessage)),
/// <inheritdoc cref="SR.FirstParametersMustMatchMessage" />
public static readonly DiagnosticDescriptor FirstParametersMustMatchRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidSignaturesInMarshallerShape,
GetResourceString(nameof(SR.InvalidSignaturesInMarshallerShapeTitle)),
GetResourceString(nameof(SR.FirstParametersMustMatchMessage)),
/// <inheritdoc cref="SR.ElementTypesOfReturnTypesMustMatchMessage" />
public static readonly DiagnosticDescriptor ElementTypesOfReturnTypesMustMatchRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidSignaturesInMarshallerShape,
GetResourceString(nameof(SR.InvalidSignaturesInMarshallerShapeTitle)),
GetResourceString(nameof(SR.ElementTypesOfReturnTypesMustMatchMessage)),
/// <inheritdoc cref="SR.ReturnTypeMustBeExpectedTypeMessage" />
public static readonly DiagnosticDescriptor ReturnTypeMustBeExpectedTypeRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidSignaturesInMarshallerShape,
GetResourceString(nameof(SR.InvalidSignaturesInMarshallerShapeTitle)),
GetResourceString(nameof(SR.ReturnTypeMustBeExpectedTypeMessage)),
/// <inheritdoc cref="SR.ManagedTypeMustBeClosedOrMatchArityMessage" />
public static readonly DiagnosticDescriptor ManagedTypeMustBeClosedOrMatchArityRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidCustomMarshallerAttributeUsage,
GetResourceString(nameof(SR.InvalidManagedTypeTitle)),
GetResourceString(nameof(SR.ManagedTypeMustBeClosedOrMatchArityMessage)),
/// <inheritdoc cref="SR.ManagedTypeMustBeNonNullMessage" />
public static readonly DiagnosticDescriptor ManagedTypeMustBeNonNullRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidCustomMarshallerAttributeUsage,
GetResourceString(nameof(SR.InvalidManagedTypeTitle)),
GetResourceString(nameof(SR.ManagedTypeMustBeNonNullMessage)),
/// <inheritdoc cref="SR.MarshalModeMustBeValidEnumValue" />
public static readonly DiagnosticDescriptor MarshalModeMustBeValidValue =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidCustomMarshallerAttributeUsage,
GetResourceString(nameof(SR.InvalidMarshalModeTitle)),
GetResourceString(nameof(SR.MarshalModeMustBeValidEnumValue)),
{
/// <inheritdoc cref="CustomMarshallerAttributeAnalyzer.StatelessValueInRequiresConvertToUnmanagedRule" />
private static readonly DiagnosticDescriptor StatelessValueInRequiresConvertToUnmanagedRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.StatelessValueInRequiresConvertToUnmanagedMessage)),
/// <inheritdoc cref="CustomMarshallerAttributeAnalyzer.StatelessLinearCollectionRequiresTwoParameterAllocateContainerForUnmanagedElementsRule" />
private static readonly DiagnosticDescriptor StatelessLinearCollectionRequiresTwoParameterAllocateContainerForUnmanagedElementsRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.StatelessLinearCollectionRequiresTwoParameterAllocateContainerForUnmanagedElementsMessage)),
/// <inheritdoc cref="CustomMarshallerAttributeAnalyzer.StatelessRequiresConvertToManagedRule" />
private static readonly DiagnosticDescriptor StatelessRequiresConvertToManagedRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.StatelessRequiresConvertToManagedMessage)),
/// <inheritdoc cref="CustomMarshallerAttributeAnalyzer.StatelessLinearCollectionInRequiresCollectionMethodsRule" />
private static readonly DiagnosticDescriptor StatelessLinearCollectionInRequiresCollectionMethodsRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.StatelessLinearCollectionInRequiresCollectionMethodsMessage)),
/// <inheritdoc cref="CustomMarshallerAttributeAnalyzer.StatelessLinearCollectionOutRequiresCollectionMethodsMessage" />
private static readonly DiagnosticDescriptor StatelessLinearCollectionOutRequiresCollectionMethodsRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.StatelessLinearCollectionOutRequiresCollectionMethodsMessage)),
/// <inheritdoc cref="CustomMarshallerAttributeAnalyzer.StatelessLinearCollectionRequiresTwoParameterAllocateContainerForManagedElementsMessage" />
private static readonly DiagnosticDescriptor StatelessLinearCollectionRequiresTwoParameterAllocateContainerForManagedElementsRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.StatelessLinearCollectionRequiresTwoParameterAllocateContainerForManagedElementsMessage)),
/// <inheritdoc cref="CustomMarshallerAttributeAnalyzer.StatefulMarshallerRequiresFromManagedRule" />
private static readonly DiagnosticDescriptor StatefulMarshallerRequiresFromManagedRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.StatefulMarshallerRequiresFromManagedMessage)),
/// <inheritdoc cref="CustomMarshallerAttributeAnalyzer.StatefulMarshallerRequiresToUnmanagedRule" />
private static readonly DiagnosticDescriptor StatefulMarshallerRequiresToUnmanagedRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.StatefulMarshallerRequiresToUnmanagedMessage)),
/// <inheritdoc cref="CustomMarshallerAttributeAnalyzer.StatefulMarshallerRequiresToManagedRule" />
private static readonly DiagnosticDescriptor StatefulMarshallerRequiresToManagedRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.StatefulMarshallerRequiresToManagedMessage)),
/// <inheritdoc cref="CustomMarshallerAttributeAnalyzer.StatefulMarshallerRequiresFromUnmanagedRule" />
private static readonly DiagnosticDescriptor StatefulMarshallerRequiresFromUnmanagedRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CustomMarshallerTypeMustHaveRequiredShape,
GetResourceString(nameof(SR.CustomMarshallerTypeMustHaveRequiredShapeTitle)),
GetResourceString(nameof(SR.StatefulMarshallerRequiresFromUnmanagedMessage)),
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.DotnetRuntime.Extensions;
using static Microsoft.Interop.Analyzers.AnalyzerDiagnostics;
using Microsoft.CodeAnalysis.Operations;
private const string Category = "Usage";
public static readonly DiagnosticDescriptor MarshallerEntryPointTypeMustHaveCustomMarshallerAttributeWithMatchingManagedTypeRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidNativeMarshallingAttributeUsage,
GetResourceString(nameof(SR.InvalidNativeMarshallingAttributeUsageTitle)),
GetResourceString(nameof(SR.EntryPointTypeMustHaveCustomMarshallerAttributeWithMatchingManagedTypeMessage)),
description: GetResourceString(nameof(SR.EntryPointTypeMustHaveCustomMarshallerAttributeWithMatchingManagedTypeDescription)));
public static readonly DiagnosticDescriptor MarshallerEntryPointTypeMustBeNonNullRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidNativeMarshallingAttributeUsage,
GetResourceString(nameof(SR.InvalidNativeMarshallingAttributeUsageTitle)),
GetResourceString(nameof(SR.EntryPointTypeMustBeNonNullMessage)),
description: GetResourceString(nameof(SR.EntryPointTypeMustBeNonNullDescription)));
public static readonly DiagnosticDescriptor GenericEntryPointMarshallerTypeMustBeClosedOrMatchArityRule =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidNativeMarshallingAttributeUsage,
GetResourceString(nameof(SR.InvalidNativeMarshallingAttributeUsageTitle)),
GetResourceString(nameof(SR.GenericEntryPointMarshallerTypeMustBeClosedOrMatchArityMessage)),
using System;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.DotnetRuntime.Extensions;
namespace Microsoft.Interop
{
/// <inheritdoc cref="SR.InvalidAttributedMethodSignatureMessageLibraryImport"/>
public static readonly DiagnosticDescriptor InvalidAttributedMethodSignature =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidLibraryImportAttributeUsage,
GetResourceString(nameof(SR.InvalidLibraryImportAttributeUsageTitle)),
GetResourceString(nameof(SR.InvalidAttributedMethodSignatureMessageLibraryImport)),
/// <inheritdoc cref="SR.InvalidAttributedMethodContainingTypeMissingModifiersMessageLibraryImport"/>
public static readonly DiagnosticDescriptor InvalidAttributedMethodContainingTypeMissingModifiers =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidLibraryImportAttributeUsage,
GetResourceString(nameof(SR.InvalidLibraryImportAttributeUsageTitle)),
GetResourceString(nameof(SR.InvalidAttributedMethodContainingTypeMissingModifiersMessageLibraryImport)),
/// <inheritdoc cref="SR.InvalidStringMarshallingConfigurationMessageLibraryImport"/>
public static readonly DiagnosticDescriptor InvalidStringMarshallingConfiguration =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidLibraryImportAttributeUsage,
GetResourceString(nameof(SR.InvalidLibraryImportAttributeUsageTitle)),
GetResourceString(nameof(SR.InvalidStringMarshallingConfigurationMessageLibraryImport)),
/// <inheritdoc cref="SR.TypeNotSupportedMessageParameterLibraryImport"/>
public static readonly DiagnosticDescriptor ParameterTypeNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.TypeNotSupported,
GetResourceString(nameof(SR.TypeNotSupportedTitle)),
GetResourceString(nameof(SR.TypeNotSupportedMessageParameterLibraryImport)),
/// <inheritdoc cref="SR.TypeNotSupportedMessageReturnLibraryImport"/>
public static readonly DiagnosticDescriptor ReturnTypeNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.TypeNotSupported,
GetResourceString(nameof(SR.TypeNotSupportedTitle)),
GetResourceString(nameof(SR.TypeNotSupportedMessageReturnLibraryImport)),
/// <inheritdoc cref="SR.TypeNotSupportedMessageParameterWithDetails"/>
public static readonly DiagnosticDescriptor ParameterTypeNotSupportedWithDetails =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.TypeNotSupported,
GetResourceString(nameof(SR.TypeNotSupportedTitle)),
GetResourceString(nameof(SR.TypeNotSupportedMessageParameterWithDetails)),
/// <inheritdoc cref="SR.TypeNotSupportedMessageReturnWithDetails"/>
public static readonly DiagnosticDescriptor ReturnTypeNotSupportedWithDetails =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.TypeNotSupported,
GetResourceString(nameof(SR.TypeNotSupportedTitle)),
GetResourceString(nameof(SR.TypeNotSupportedMessageReturnWithDetails)),
/// <inheritdoc cref="SR.ConfigurationNotSupportedMessageParameterLibraryImport"/>
public static readonly DiagnosticDescriptor ParameterConfigurationNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitleLibraryImport)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageParameterLibraryImport)),
/// <inheritdoc cref="SR.ConfigurationNotSupportedMessageReturnLibraryImport"/>
public static readonly DiagnosticDescriptor ReturnConfigurationNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitleLibraryImport)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageReturnLibraryImport)),
/// <inheritdoc cref="SR.MarshalAsConfigurationNotSupportedMessageParameterLibraryImport"/>
public static readonly DiagnosticDescriptor MarshalAsParameterConfigurationNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
GeneratorDiagnostics.Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitleLibraryImport)),
GetResourceString(nameof(SR.MarshalAsConfigurationNotSupportedMessageParameterLibraryImport)),
/// <inheritdoc cref="SR.MarshalAsConfigurationNotSupportedMessageReturnLibraryImport"/>
public static readonly DiagnosticDescriptor MarshalAsReturnConfigurationNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
GeneratorDiagnostics.Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitleLibraryImport)),
GetResourceString(nameof(SR.MarshalAsConfigurationNotSupportedMessageReturnLibraryImport)),
/// <inheritdoc cref="SR.ConfigurationNotSupportedMessageLibraryImport"/>
public static readonly DiagnosticDescriptor ConfigurationNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitleLibraryImport)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageLibraryImport)),
/// <inheritdoc cref="SR.ConfigurationNotSupportedMessageValueLibraryImport"/>
public static readonly DiagnosticDescriptor ConfigurationValueNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitleLibraryImport)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageValueLibraryImport)),
/// <inheritdoc cref="SR.ConfigurationNotSupportedMessageMarshallingInfoLibraryImport"/>
public static readonly DiagnosticDescriptor MarshallingAttributeConfigurationNotSupported =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.ConfigurationNotSupported,
GetResourceString(nameof(SR.ConfigurationNotSupportedTitleLibraryImport)),
GetResourceString(nameof(SR.ConfigurationNotSupportedMessageMarshallingInfoLibraryImport)),
/// <inheritdoc cref="SR.CannotForwardToDllImportMessage"/>
public static readonly DiagnosticDescriptor CannotForwardToDllImport =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.CannotForwardToDllImport,
GetResourceString(nameof(SR.CannotForwardToDllImportTitle)),
GetResourceString(nameof(SR.CannotForwardToDllImportMessage)),
/// <inheritdoc cref="SR.RequiresAllowUnsafeBlocksMessageLibraryImport"/>
public static readonly DiagnosticDescriptor RequiresAllowUnsafeBlocks =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.RequiresAllowUnsafeBlocks,
GetResourceString(nameof(SR.RequiresAllowUnsafeBlocksTitleLibraryImport)),
GetResourceString(nameof(SR.RequiresAllowUnsafeBlocksMessageLibraryImport)),
/// <inheritdoc cref="SR.UnnecessaryParameterMarshallingInfoMessage"/>
public static readonly DiagnosticDescriptor UnnecessaryParameterMarshallingInfo =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.UnnecessaryMarshallingInfo,
GetResourceString(nameof(SR.UnnecessaryMarshallingInfoTitle)),
GetResourceString(nameof(SR.UnnecessaryParameterMarshallingInfoMessage)),
/// <inheritdoc cref="SR.UnnecessaryMarshallingInfoDescription"/>
public static readonly DiagnosticDescriptor UnnecessaryReturnMarshallingInfo =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.UnnecessaryMarshallingInfo,
GetResourceString(nameof(SR.UnnecessaryMarshallingInfoTitle)),
GetResourceString(nameof(SR.UnnecessaryReturnMarshallingInfoMessage)),
/// <inheritdoc cref="SR.SizeOfCollectionMustBeKnownAtMarshalTimeMessageOutParam"/>
public static readonly DiagnosticDescriptor SizeOfInCollectionMustBeDefinedAtCallOutParam =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidLibraryImportAttributeUsage,
GetResourceString(nameof(SR.SizeOfCollectionMustBeKnownAtMarshalTimeTitle)),
GetResourceString(nameof(SR.SizeOfCollectionMustBeKnownAtMarshalTimeMessageOutParam)),
/// <inheritdoc cref="SR.SizeOfCollectionMustBeKnownAtMarshalTimeMessageReturnValue"/>
public static readonly DiagnosticDescriptor SizeOfInCollectionMustBeDefinedAtCallReturnValue =
- new DiagnosticDescriptor(
+ DiagnosticDescriptorHelper.Create(
Ids.InvalidLibraryImportAttributeUsage,
GetResourceString(nameof(SR.SizeOfCollectionMustBeKnownAtMarshalTimeTitle)),
GetResourceString(nameof(SR.SizeOfCollectionMustBeKnownAtMarshalTimeMessageReturnValue)),
</ItemGroup>
<ItemGroup>
+ <Compile Include="$(CommonPath)Roslyn\DiagnosticDescriptorHelper.cs" Link="Common\Roslyn\DiagnosticDescriptorHelper.cs" />
<Compile Include="$(CommonPath)Roslyn\GetBestTypeByMetadataName.cs" Link="Common\Roslyn\GetBestTypeByMetadataName.cs" />
<Compile Include="..\Common\DefaultMarshallingInfoParser.cs" Link="Common\DefaultMarshallingInfoParser.cs" />
<Compile Include="..\Common\OperationExtensions.cs" Link="Common\OperationExtensions.cs" />
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.DotnetRuntime.Extensions;
namespace System.Text.Json.SourceGeneration
{
{
// Must be kept in sync with https://github.com/dotnet/runtime/blob/main/docs/project/list-of-diagnostics.md
- public static DiagnosticDescriptor TypeNotSupported { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor TypeNotSupported { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1030",
title: new LocalizableResourceString(nameof(SR.TypeNotSupportedTitle), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.TypeNotSupportedMessageFormat), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true);
- public static DiagnosticDescriptor DuplicateTypeName { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor DuplicateTypeName { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1031",
title: new LocalizableResourceString(nameof(SR.DuplicateTypeNameTitle), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.DuplicateTypeNameMessageFormat), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true);
- public static DiagnosticDescriptor ContextClassesMustBePartial { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor ContextClassesMustBePartial { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1032",
title: new LocalizableResourceString(nameof(SR.ContextClassesMustBePartialTitle), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.ContextClassesMustBePartialMessageFormat), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true);
- public static DiagnosticDescriptor MultipleJsonConstructorAttribute { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor MultipleJsonConstructorAttribute { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1033",
title: new LocalizableResourceString(nameof(SR.MultipleJsonConstructorAttributeTitle), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.MultipleJsonConstructorAttributeFormat), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true);
- public static DiagnosticDescriptor JsonStringEnumConverterNotSupportedInAot { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor JsonStringEnumConverterNotSupportedInAot { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1034",
title: new LocalizableResourceString(nameof(SR.JsonStringEnumConverterNotSupportedTitle), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.JsonStringEnumConverterNotSupportedMessageFormat), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true);
- public static DiagnosticDescriptor MultipleJsonExtensionDataAttribute { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor MultipleJsonExtensionDataAttribute { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1035",
title: new LocalizableResourceString(nameof(SR.MultipleJsonExtensionDataAttributeTitle), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.MultipleJsonExtensionDataAttributeFormat), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true);
- public static DiagnosticDescriptor DataExtensionPropertyInvalid { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor DataExtensionPropertyInvalid { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1036",
title: new LocalizableResourceString(nameof(SR.DataExtensionPropertyInvalidTitle), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.DataExtensionPropertyInvalidFormat), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true);
- public static DiagnosticDescriptor InaccessibleJsonIncludePropertiesNotSupported { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor InaccessibleJsonIncludePropertiesNotSupported { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1038",
title: new LocalizableResourceString(nameof(SR.InaccessibleJsonIncludePropertiesNotSupportedTitle), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.InaccessibleJsonIncludePropertiesNotSupportedFormat), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true);
- public static DiagnosticDescriptor PolymorphismNotSupported { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor PolymorphismNotSupported { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1039",
title: new LocalizableResourceString(nameof(SR.FastPathPolymorphismNotSupportedTitle), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.FastPathPolymorphismNotSupportedMessageFormat), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true);
- public static DiagnosticDescriptor JsonConverterAttributeInvalidType { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor JsonConverterAttributeInvalidType { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1220",
title: new LocalizableResourceString(nameof(SR.JsonConverterAttributeInvalidTypeTitle), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.JsonConverterAttributeInvalidTypeMessageFormat), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true);
- public static DiagnosticDescriptor JsonUnsupportedLanguageVersion { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor JsonUnsupportedLanguageVersion { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1221",
title: new LocalizableResourceString(nameof(SR.JsonUnsupportedLanguageVersionTitle), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.JsonUnsupportedLanguageVersionMessageFormat), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true);
- public static DiagnosticDescriptor JsonConstructorInaccessible { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor JsonConstructorInaccessible { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1222",
title: new LocalizableResourceString(nameof(SR.JsonConstructorInaccessibleTitle), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.JsonConstructorInaccessibleMessageFormat), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true);
- public static DiagnosticDescriptor DerivedJsonConverterAttributesNotSupported { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor DerivedJsonConverterAttributesNotSupported { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1223",
title: new LocalizableResourceString(nameof(SR.DerivedJsonConverterAttributesNotSupportedTitle), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.DerivedJsonConverterAttributesNotSupportedMessageFormat), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true);
- public static DiagnosticDescriptor JsonSerializableAttributeOnNonContextType { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor JsonSerializableAttributeOnNonContextType { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1224",
title: new LocalizableResourceString(nameof(SR.JsonSerializableAttributeOnNonContextTypeTitle), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.JsonSerializableAttributeOnNonContextTypeMessageFormat), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
<Compile Include="$(CoreLibSharedDir)System\Runtime\CompilerServices\IsExternalInit.cs" Link="Common\System\Runtime\CompilerServices\IsExternalInit.cs" />
<Compile Include="$(CoreLibSharedDir)System\Runtime\CompilerServices\CompilerFeatureRequiredAttribute.cs" Link="Common\System\Runtime\CompilerServices\CompilerFeatureRequiredAttribute.cs" />
<Compile Include="$(CoreLibSharedDir)System\Runtime\CompilerServices\RequiredMemberAttribute.cs" Link="Common\System\Runtime\CompilerServices\RequiredMemberAttribute.cs" />
+ <Compile Include="$(CommonPath)\Roslyn\DiagnosticDescriptorHelper.cs" Link="Common\Roslyn\DiagnosticDescriptorHelper.cs" />
<Compile Include="$(CommonPath)\Roslyn\GetBestTypeByMetadataName.cs" Link="Common\Roslyn\GetBestTypeByMetadataName.cs" />
<Compile Include="$(CommonPath)\SourceGenerators\SourceWriter.cs" Link="Common\SourceGenerators\SourceWriter.cs" />
<Compile Include="..\Common\JsonCamelCaseNamingPolicy.cs" Link="Common\System\Text\Json\JsonCamelCaseNamingPolicy.cs" />
using System;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.DotnetRuntime.Extensions;
namespace System.Text.RegularExpressions.Generator
{
{
private const string Category = "Performance";
- public static DiagnosticDescriptor InvalidGeneratedRegexAttribute { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor InvalidGeneratedRegexAttribute { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1040",
title: new LocalizableResourceString(nameof(SR.InvalidGeneratedRegexAttributeTitle), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.InvalidGeneratedRegexAttributeMessage), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)),
isEnabledByDefault: true,
customTags: WellKnownDiagnosticTags.NotConfigurable);
- public static DiagnosticDescriptor MultipleGeneratedRegexAttributes { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor MultipleGeneratedRegexAttributes { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1041",
title: new LocalizableResourceString(nameof(SR.InvalidGeneratedRegexAttributeTitle), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.MultipleGeneratedRegexAttributesMessage), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)),
isEnabledByDefault: true,
customTags: WellKnownDiagnosticTags.NotConfigurable);
- public static DiagnosticDescriptor InvalidRegexArguments { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor InvalidRegexArguments { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1042",
title: new LocalizableResourceString(nameof(SR.InvalidGeneratedRegexAttributeTitle), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.InvalidRegexArgumentsMessage), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)),
isEnabledByDefault: true,
customTags: WellKnownDiagnosticTags.NotConfigurable);
- public static DiagnosticDescriptor RegexMethodMustHaveValidSignature { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor RegexMethodMustHaveValidSignature { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1043",
title: new LocalizableResourceString(nameof(SR.InvalidGeneratedRegexAttributeTitle), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.RegexMethodMustHaveValidSignatureMessage), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)),
isEnabledByDefault: true,
customTags: WellKnownDiagnosticTags.NotConfigurable);
- public static DiagnosticDescriptor LimitedSourceGeneration { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor LimitedSourceGeneration { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1044",
title: new LocalizableResourceString(nameof(SR.LimitedSourceGenerationTitle), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.LimitedSourceGenerationMessage), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)),
DiagnosticSeverity.Info,
isEnabledByDefault: true);
- public static DiagnosticDescriptor UseRegexSourceGeneration { get; } = new DiagnosticDescriptor(
+ public static DiagnosticDescriptor UseRegexSourceGeneration { get; } = DiagnosticDescriptorHelper.Create(
id: "SYSLIB1045",
title: new LocalizableResourceString(nameof(SR.UseRegexSourceGeneratorTitle), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.UseRegexSourceGeneratorMessage), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)),
<ItemGroup>
<!-- Common generator support -->
+ <Compile Include="$(CommonPath)Roslyn\DiagnosticDescriptorHelper.cs" Link="Common\Roslyn\DiagnosticDescriptorHelper.cs" />
<Compile Include="$(CommonPath)Roslyn\GetBestTypeByMetadataName.cs" Link="Common\Roslyn\GetBestTypeByMetadataName.cs" />
<Compile Include="$(CoreLibSharedDir)System\Runtime\CompilerServices\IsExternalInit.cs" Link="Common\System\Runtime\CompilerServices\IsExternalInit.cs" />
diagnosticString.GetMessageFormat (),
diagnosticId.GetDiagnosticCategory (),
DiagnosticSeverity.Warning,
- true);
+ true,
+ diagnosticId.GetHelpUri());
}
public static DiagnosticDescriptor GetDiagnosticDescriptor (DiagnosticId diagnosticId, DiagnosticString diagnosticString)
diagnosticString.GetMessage (),
diagnosticId.GetDiagnosticCategory (),
DiagnosticSeverity.Warning,
- true);
+ true,
+ diagnosticId.GetHelpUri());
public static DiagnosticDescriptor GetDiagnosticDescriptor (DiagnosticId diagnosticId,
LocalizableResourceString? lrsTitle = null,
bool isEnabledByDefault = true,
string? helpLinkUri = null)
{
+ helpLinkUri ??= diagnosticId.GetHelpUri();
+
if (lrsTitle == null || lrsMessage == null) {
var diagnosticString = new DiagnosticString (diagnosticId);
return new DiagnosticDescriptor (diagnosticId.AsString (),
>= 3050 and <= 6000 => DiagnosticCategory.AOT,
_ => throw new ArgumentException ($"The provided diagnostic id '{diagnosticId}' does not fall into the range of supported warning codes 2001 to 6000 (inclusive).")
};
+
+ public static string? GetHelpUri(this DiagnosticId diagnosticId) =>
+ diagnosticId.GetDiagnosticCategory() switch {
+ DiagnosticCategory.Trimming => $"https://learn.microsoft.com/dotnet/core/deploying/trimming/trim-warnings/il{(int) diagnosticId}",
+ DiagnosticCategory.SingleFile => $"https://learn.microsoft.com/dotnet/core/deploying/single-file/warnings/il{(int) diagnosticId}",
+ DiagnosticCategory.AOT =>$"https://learn.microsoft.com/dotnet/core/deploying/native-aot/warnings/il{(int) diagnosticId}",
+ _ => null
+ };
}
}