diff --git a/SystemExtensions.NetStandard.Generators/Diagnostics.cs b/SystemExtensions.NetStandard.Generators/Diagnostics.cs index 5eb452f..3e2ccce 100644 --- a/SystemExtensions.NetStandard.Generators/Diagnostics.cs +++ b/SystemExtensions.NetStandard.Generators/Diagnostics.cs @@ -1,79 +1,78 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Text; -namespace System.Extensions +namespace System.Extensions; + +internal static class Diagnostics { - internal static class Diagnostics - { - public const string DependencyPropertyGenerator_NoAttributeFound = "DGD 0001"; - public const string DependencyPropertyGenerator_ClassMustBeTopLevel = "DGD 1001"; - public const string DependencyPropertyGenerator_ClassMustBePartial = "DGD 1002"; - public const string DependencyPropertyGenerator_ClassMustBeInNamespace = "DGD 1003"; - public const string DependencyPropertyGenerator_ClassMustImplementINotifyPropertyChanged = "DGD 1004"; + public const string DependencyPropertyGenerator_NoAttributeFound = "DGD 0001"; + public const string DependencyPropertyGenerator_ClassMustBeTopLevel = "DGD 1001"; + public const string DependencyPropertyGenerator_ClassMustBePartial = "DGD 1002"; + public const string DependencyPropertyGenerator_ClassMustBeInNamespace = "DGD 1003"; + public const string DependencyPropertyGenerator_ClassMustImplementINotifyPropertyChanged = "DGD 1004"; - public static Diagnostic MissingAttributeDiagnostic(string attributeName, string attributeNamespace) => Diagnostic.Create( - new DiagnosticDescriptor( - DependencyPropertyGenerator_NoAttributeFound, - $"{attributeNamespace}.{attributeName} not found", - "Could not find attribute with name {0} in namespace {1}.", - "WpfExtended.SourceGeneration", - DiagnosticSeverity.Error, - true, - $"This error occurs when the attribute generated by the {nameof(DependencyPropertyGenerator)} is not found", - null), - Location.None, - attributeName, attributeNamespace); + public static Diagnostic MissingAttributeDiagnostic(string attributeName, string attributeNamespace) => Diagnostic.Create( + new DiagnosticDescriptor( + DependencyPropertyGenerator_NoAttributeFound, + $"{attributeNamespace}.{attributeName} not found", + "Could not find attribute with name {0} in namespace {1}.", + "SystemExtensions.NetStandard.Generators", + DiagnosticSeverity.Error, + true, + $"This error occurs when the attribute generated by the {nameof(NotifyPropertyChangedGenerator)} is not found", + null), + Location.None, + attributeName, attributeNamespace); - public static Diagnostic ClassNotTopLevelDiagnostic(string className, string containingSymbol, SyntaxTree syntaxTree, TextSpan textSpan) => Diagnostic.Create( - new DiagnosticDescriptor( - DependencyPropertyGenerator_ClassMustBeTopLevel, - $"{className} must be top level", - "Class {0} must be top level. It is currently declared under {1}.", - "WpfExtended.SourceGeneration", - DiagnosticSeverity.Error, - true, - null, - null), - Location.Create(syntaxTree, textSpan), - className, containingSymbol); + public static Diagnostic ClassNotTopLevelDiagnostic(string className, string containingSymbol, SyntaxTree syntaxTree, TextSpan textSpan) => Diagnostic.Create( + new DiagnosticDescriptor( + DependencyPropertyGenerator_ClassMustBeTopLevel, + $"{className} must be top level", + "Class {0} must be top level. It is currently declared under {1}.", + "SystemExtensions.NetStandard.Generators", + DiagnosticSeverity.Error, + true, + null, + null), + Location.Create(syntaxTree, textSpan), + className, containingSymbol); - public static Diagnostic ClassNotPartial(string className) => Diagnostic.Create( - new DiagnosticDescriptor( - DependencyPropertyGenerator_ClassMustBePartial, - $"{className} is not partial", - "Class {0} must be marked as partial in order for the generator to work", - "WpfExtended.SourceGeneration", - DiagnosticSeverity.Error, - true, - null, - null), - Location.None, - className); + public static Diagnostic ClassNotPartial(string className) => Diagnostic.Create( + new DiagnosticDescriptor( + DependencyPropertyGenerator_ClassMustBePartial, + $"{className} is not partial", + "Class {0} must be marked as partial in order for the generator to work", + "SystemExtensions.NetStandard.Generators", + DiagnosticSeverity.Error, + true, + null, + null), + Location.None, + className); - public static Diagnostic ClassNotInNamespace(string className) => Diagnostic.Create( - new DiagnosticDescriptor( - DependencyPropertyGenerator_ClassMustBeInNamespace, - $"{className} is not defined in a namespace", - "Class {0} must be defined inside a namespace for the generator to work", - "WpfExtended.SourceGeneration", - DiagnosticSeverity.Error, - true, - null, - null), - Location.None, - className); + public static Diagnostic ClassNotInNamespace(string className) => Diagnostic.Create( + new DiagnosticDescriptor( + DependencyPropertyGenerator_ClassMustBeInNamespace, + $"{className} is not defined in a namespace", + "Class {0} must be defined inside a namespace for the generator to work", + "SystemExtensions.NetStandard.Generators", + DiagnosticSeverity.Error, + true, + null, + null), + Location.None, + className); - public static Diagnostic ClassDoesNotImplementINotifyPropertyChanged(string className) => Diagnostic.Create( - new DiagnosticDescriptor( - DependencyPropertyGenerator_ClassMustImplementINotifyPropertyChanged, - $"{className} must implement INotifyPropertyChanged", - "Class {0} must implement INotifyPropertyChanged for the generator to work", - "WpfExtended.SourceGeneration", - DiagnosticSeverity.Error, - true, - null, - null), - Location.None, - className); - } + public static Diagnostic ClassDoesNotImplementINotifyPropertyChanged(string className) => Diagnostic.Create( + new DiagnosticDescriptor( + DependencyPropertyGenerator_ClassMustImplementINotifyPropertyChanged, + $"{className} must implement INotifyPropertyChanged", + "Class {0} must implement INotifyPropertyChanged for the generator to work", + "SystemExtensions.NetStandard.Generators", + DiagnosticSeverity.Error, + true, + null, + null), + Location.None, + className); } diff --git a/SystemExtensions.NetStandard.Generators/SystemExtensions.NetStandard.Generators.csproj b/SystemExtensions.NetStandard.Generators/SystemExtensions.NetStandard.Generators.csproj index 4d9e242..c66ccee 100644 --- a/SystemExtensions.NetStandard.Generators/SystemExtensions.NetStandard.Generators.csproj +++ b/SystemExtensions.NetStandard.Generators/SystemExtensions.NetStandard.Generators.csproj @@ -3,10 +3,8 @@ netstandard2.0 true - true Alexandru Macocian Source generators extensions for netstandard2.0. - LICENSE 0.1.0 latest true