-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Options validation source generator (#87587)
- Loading branch information
Showing
78 changed files
with
12,224 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
src/libraries/Microsoft.Extensions.Options/gen/DiagDescriptors.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// 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; | ||
using System; | ||
|
||
namespace Microsoft.Extensions.Options.Generators | ||
{ | ||
internal sealed class DiagDescriptors : DiagDescriptorsBase | ||
{ | ||
private const string Category = "Microsoft.Extensions.Options.SourceGeneration"; | ||
|
||
public static DiagnosticDescriptor CantUseWithGenericTypes { get; } = Make( | ||
id: "SYSLIB1201", | ||
title: SR.CantUseWithGenericTypesTitle, | ||
messageFormat: SR.CantUseWithGenericTypesMessage, | ||
category: Category); | ||
|
||
public static DiagnosticDescriptor NoEligibleMember { get; } = Make( | ||
id: "SYSLIB1202", | ||
title: SR.NoEligibleMemberTitle, | ||
messageFormat: SR.NoEligibleMemberMessage, | ||
category: Category, | ||
defaultSeverity: DiagnosticSeverity.Warning); | ||
|
||
public static DiagnosticDescriptor NoEligibleMembersFromValidator { get; } = Make( | ||
id: "SYSLIB1203", | ||
title: SR.NoEligibleMembersFromValidatorTitle, | ||
messageFormat: SR.NoEligibleMembersFromValidatorMessage, | ||
category: Category, | ||
defaultSeverity: DiagnosticSeverity.Warning); | ||
|
||
public static DiagnosticDescriptor DoesntImplementIValidateOptions { get; } = Make( | ||
id: "SYSLIB1204", | ||
title: SR.DoesntImplementIValidateOptionsTitle, | ||
messageFormat: SR.DoesntImplementIValidateOptionsMessage, | ||
category: Category); | ||
|
||
public static DiagnosticDescriptor AlreadyImplementsValidateMethod { get; } = Make( | ||
id: "SYSLIB1205", | ||
title: SR.AlreadyImplementsValidateMethodTitle, | ||
messageFormat: SR.AlreadyImplementsValidateMethodMessage, | ||
category: Category); | ||
|
||
public static DiagnosticDescriptor MemberIsInaccessible { get; } = Make( | ||
id: "SYSLIB1206", | ||
title: SR.MemberIsInaccessibleTitle, | ||
messageFormat: SR.MemberIsInaccessibleMessage, | ||
category: Category); | ||
|
||
public static DiagnosticDescriptor NotEnumerableType { get; } = Make( | ||
id: "SYSLIB1207", | ||
title: SR.NotEnumerableTypeTitle, | ||
messageFormat: SR.NotEnumerableTypeMessage, | ||
category: Category); | ||
|
||
public static DiagnosticDescriptor ValidatorsNeedSimpleConstructor { get; } = Make( | ||
id: "SYSLIB1208", | ||
title: SR.ValidatorsNeedSimpleConstructorTitle, | ||
messageFormat: SR.ValidatorsNeedSimpleConstructorMessage, | ||
category: Category); | ||
|
||
public static DiagnosticDescriptor CantBeStaticClass { get; } = Make( | ||
id: "SYSLIB1209", | ||
title: SR.CantBeStaticClassTitle, | ||
messageFormat: SR.CantBeStaticClassMessage, | ||
category: Category); | ||
|
||
public static DiagnosticDescriptor NullValidatorType { get; } = Make( | ||
id: "SYSLIB1210", | ||
title: SR.NullValidatorTypeTitle, | ||
messageFormat: SR.NullValidatorTypeMessage, | ||
category: Category); | ||
|
||
public static DiagnosticDescriptor CircularTypeReferences { get; } = Make( | ||
id: "SYSLIB1211", | ||
title: SR.CircularTypeReferencesTitle, | ||
messageFormat: SR.CircularTypeReferencesMessage, | ||
category: Category); | ||
|
||
public static DiagnosticDescriptor PotentiallyMissingTransitiveValidation { get; } = Make( | ||
id: "SYSLIB1212", | ||
title: SR.PotentiallyMissingTransitiveValidationTitle, | ||
messageFormat: SR.PotentiallyMissingTransitiveValidationMessage, | ||
category: Category, | ||
defaultSeverity: DiagnosticSeverity.Warning); | ||
|
||
public static DiagnosticDescriptor PotentiallyMissingEnumerableValidation { get; } = Make( | ||
id: "SYSLIB1213", | ||
title: SR.PotentiallyMissingEnumerableValidationTitle, | ||
messageFormat: SR.PotentiallyMissingEnumerableValidationMessage, | ||
category: Category, | ||
defaultSeverity: DiagnosticSeverity.Warning); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/libraries/Microsoft.Extensions.Options/gen/DiagDescriptorsBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using Microsoft.CodeAnalysis; | ||
|
||
namespace Microsoft.Extensions.Options.Generators | ||
{ | ||
#pragma warning disable CA1052 // Static holder types should be Static or NotInheritable | ||
internal class DiagDescriptorsBase | ||
#pragma warning restore CA1052 | ||
{ | ||
protected static DiagnosticDescriptor Make( | ||
string id, | ||
string title, | ||
string messageFormat, | ||
string category, | ||
DiagnosticSeverity defaultSeverity = DiagnosticSeverity.Error, | ||
bool isEnabledByDefault = true) | ||
{ | ||
return new( | ||
id, | ||
title, | ||
messageFormat, | ||
category, | ||
defaultSeverity, | ||
isEnabledByDefault); | ||
} | ||
} | ||
} |
Oops, something went wrong.