Skip to content

Commit 3cdacae

Browse files
authored
Merge pull request #111 from arthurward/feature/resolveAnalysisWarnings
Resolve code analysis warnings in source generator attributes.
2 parents 7b3d1ed + 30bd5bc commit 3cdacae

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/PlantUmlClassDiagramGenerator.SourceGenerator/PlantUmlSourceGenerator.Attributes.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ public void RegisterAttributes(IncrementalGeneratorInitializationContext context
1111
context.RegisterPostInitializationOutput(context =>
1212
{
1313
const string source = """
14+
#nullable enable
15+
1416
namespace PlantUmlClassDiagramGenerator.SourceGenerator.Attributes;
1517
1618
[global::System.Flags]
@@ -47,7 +49,7 @@ internal enum AssociationTypes
4749
| global::System.AttributeTargets.Interface
4850
| global::System.AttributeTargets.Enum
4951
| global::System.AttributeTargets.Struct)]
50-
internal class PlantUmlDiagramAttribute : global::System.Attribute
52+
internal sealed class PlantUmlDiagramAttribute : global::System.Attribute
5153
{
5254
public Accessibilities IncludeMemberAccessibilities { get; set; } = Accessibilities.NotSet;
5355
public Accessibilities ExcludeMemberAccessibilities { get; set; } = Accessibilities.NotSet;
@@ -65,7 +67,7 @@ internal class PlantUmlDiagramAttribute : global::System.Attribute
6567
| global::System.AttributeTargets.Event
6668
| global::System.AttributeTargets.Interface
6769
| global::System.AttributeTargets.Parameter)]
68-
internal class PlantUmlIgnoreAttribute : global::System.Attribute
70+
internal sealed class PlantUmlIgnoreAttribute : global::System.Attribute
6971
{ }
7072
7173
[global::System.AttributeUsage(
@@ -79,7 +81,7 @@ internal class PlantUmlIgnoreAttribute : global::System.Attribute
7981
| global::System.AttributeTargets.Event
8082
| global::System.AttributeTargets.Interface
8183
| global::System.AttributeTargets.Parameter)]
82-
internal class PlantUmlAssociationAttribute(string node) : global::System.Attribute
84+
internal sealed class PlantUmlAssociationAttribute(string node) : global::System.Attribute
8385
{
8486
public string Node { get;} = node;
8587
@@ -100,7 +102,7 @@ internal class PlantUmlAssociationAttribute(string node) : global::System.Attrib
100102
| global::System.AttributeTargets.Event
101103
| global::System.AttributeTargets.Interface
102104
| global::System.AttributeTargets.Parameter)]
103-
internal class PlantUmlIgnoreAssociationAttribute : global::System.Attribute
105+
internal sealed class PlantUmlIgnoreAssociationAttribute : global::System.Attribute
104106
{ }
105107
106108
[global::System.AttributeUsage(
@@ -109,12 +111,12 @@ internal class PlantUmlIgnoreAssociationAttribute : global::System.Attribute
109111
| global::System.AttributeTargets.Interface
110112
| global::System.AttributeTargets.Enum
111113
| global::System.AttributeTargets.Struct)]
112-
internal class PlantUmlExtraAssociationTargetsAttribute(params global::System.Type[] types ) : global::System.Attribute
114+
internal sealed class PlantUmlExtraAssociationTargetsAttribute(params global::System.Type[] types ) : global::System.Attribute
113115
{
114116
public global::System.Type[] Types { get; } = types;
115117
}
116118
""";
117-
context.AddSource("Attributes", SourceText.From(source, Encoding.UTF8));
119+
context.AddSource("Attributes.g", SourceText.From(source, Encoding.UTF8));
118120
});
119121
}
120122
}

0 commit comments

Comments
 (0)