From faf7e4248bb119fde16c8cbeee794dd2618301a6 Mon Sep 17 00:00:00 2001 From: Macocian Alexandru Victor Date: Thu, 31 Aug 2023 23:47:31 +0200 Subject: [PATCH] Fix DependencyPropertySourceGenerator broken due to unknown diagnostic message (#17) --- .../WpfExtended.SourceGeneration.Tests.csproj | 2 +- .../DependencyPropertyGenerator.cs | 3 +-- WpfExtended.SourceGeneration/Diagnostics.cs | 14 -------------- .../WpfExtended.SourceGeneration.csproj | 2 +- 4 files changed, 3 insertions(+), 18 deletions(-) diff --git a/WpfExtended.SourceGeneration.Tests/WpfExtended.SourceGeneration.Tests.csproj b/WpfExtended.SourceGeneration.Tests/WpfExtended.SourceGeneration.Tests.csproj index 6963ec8..f62b91d 100644 --- a/WpfExtended.SourceGeneration.Tests/WpfExtended.SourceGeneration.Tests.csproj +++ b/WpfExtended.SourceGeneration.Tests/WpfExtended.SourceGeneration.Tests.csproj @@ -1,7 +1,7 @@  - net5.0-windows + net7.0-windows true preview Exe diff --git a/WpfExtended.SourceGeneration/DependencyPropertyGenerator.cs b/WpfExtended.SourceGeneration/DependencyPropertyGenerator.cs index f9cc208..65bdef9 100644 --- a/WpfExtended.SourceGeneration/DependencyPropertyGenerator.cs +++ b/WpfExtended.SourceGeneration/DependencyPropertyGenerator.cs @@ -10,7 +10,7 @@ using System.Extensions.Templates; namespace System.Extensions { - [Generator] + [Generator(LanguageNames.CSharp)] public class DependencyPropertyGenerator : ISourceGenerator { private const string AttributeNamespace = "System.Windows.Extensions"; @@ -81,7 +81,6 @@ namespace System.Extensions foreach (var group in fieldSymbols.GroupBy(f => f.ContainingType, SymbolEqualityComparer.IncludeNullability)) { var classSource = ProcessClass((INamedTypeSymbol)group.Key, attributeSymbol, group.ToList(), context); - context.ReportDiagnostic(Diagnostics.GeneratedSymbolsForClassDiagnostic(group.Key.Name)); context.AddSource($"{group.Key.Name}.DependencyPropertyGenerator.g.cs", classSource); } } diff --git a/WpfExtended.SourceGeneration/Diagnostics.cs b/WpfExtended.SourceGeneration/Diagnostics.cs index 08e16a9..3df238e 100644 --- a/WpfExtended.SourceGeneration/Diagnostics.cs +++ b/WpfExtended.SourceGeneration/Diagnostics.cs @@ -7,7 +7,6 @@ namespace System.Extensions { public const string DependencyPropertyGenerator_NoAttributeFound = "DGD 0001"; public const string DependencyPropertyGenerator_ClassMustBeTopLevel = "DGD 1001"; - public const string DependencyPropertyGenerator_Success = "DGD 3001"; public static Diagnostic MissingAttributeDiagnostic(string attributeName, string attributeNamespace) => Diagnostic.Create( new DiagnosticDescriptor( @@ -34,18 +33,5 @@ namespace System.Extensions null), Location.Create(syntaxTree, textSpan), className, containingSymbol); - - public static Diagnostic GeneratedSymbolsForClassDiagnostic(string className) => Diagnostic.Create( - new DiagnosticDescriptor( - DependencyPropertyGenerator_Success, - $"{className} created dependency properties", - "DependencyPropertyGenerator successfully created implementations for properties in {0}", - "WpfExtended.SourceGeneration", - DiagnosticSeverity.Info, - true, - null, - null), - Location.None, - className); } } diff --git a/WpfExtended.SourceGeneration/WpfExtended.SourceGeneration.csproj b/WpfExtended.SourceGeneration/WpfExtended.SourceGeneration.csproj index f3d8f9b..539fd29 100644 --- a/WpfExtended.SourceGeneration/WpfExtended.SourceGeneration.csproj +++ b/WpfExtended.SourceGeneration/WpfExtended.SourceGeneration.csproj @@ -7,7 +7,7 @@ Alexandru Macocian Source generator library. LICENSE - 0.1.1 + 0.1.2 latest true