Fix DependencyPropertySourceGenerator broken due to unknown diagnostic message (#17)

This commit is contained in:
2023-08-31 23:47:31 +02:00
committed by GitHub
parent daca000745
commit faf7e4248b
4 changed files with 3 additions and 18 deletions
@@ -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);
}
}
@@ -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);
}
}
@@ -7,7 +7,7 @@
<Authors>Alexandru Macocian</Authors>
<Description>Source generator library.</Description>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Version>0.1.1</Version>
<Version>0.1.2</Version>
<LangVersion>latest</LangVersion>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
</PropertyGroup>