Skip to content

Commit ee971b3

Browse files
committed
Update AssemblyMetadataGenerator.cs
1 parent e1fc354 commit ee971b3

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

src/AssemblyMetadata.Generators/AssemblyMetadataGenerator.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,37 @@
11
using System.Reflection;
2+
using System.Resources;
3+
using System.Runtime.Versioning;
24

35
using Microsoft.CodeAnalysis;
46
using Microsoft.CodeAnalysis.CSharp.Syntax;
5-
using Microsoft.CodeAnalysis.CSharp;
67

78
namespace AssemblyMetadata.Generators;
89

910
[Generator(LanguageNames.CSharp)]
1011
public class AssemblyMetadataGenerator : IIncrementalGenerator
1112
{
13+
private static readonly HashSet<string> _attributes = new()
14+
{
15+
nameof(AssemblyCompanyAttribute),
16+
nameof(AssemblyConfigurationAttribute),
17+
nameof(AssemblyCopyrightAttribute),
18+
nameof(AssemblyCultureAttribute),
19+
nameof(AssemblyDelaySignAttribute),
20+
nameof(AssemblyDescriptionAttribute),
21+
nameof(AssemblyFileVersionAttribute),
22+
nameof(AssemblyInformationalVersionAttribute),
23+
nameof(AssemblyKeyFileAttribute),
24+
nameof(AssemblyKeyNameAttribute),
25+
nameof(AssemblyMetadataAttribute),
26+
nameof(AssemblyProductAttribute),
27+
nameof(AssemblySignatureKeyAttribute),
28+
nameof(AssemblyTitleAttribute),
29+
nameof(AssemblyTrademarkAttribute),
30+
nameof(AssemblyVersionAttribute),
31+
nameof(NeutralResourcesLanguageAttribute),
32+
nameof(TargetFrameworkAttribute),
33+
};
34+
1235
public void Initialize(IncrementalGeneratorInitializationContext context)
1336
{
1437
var provider = context.SyntaxProvider
@@ -46,7 +69,7 @@ private static GeneratorContext SemanticTransform(GeneratorAttributeSyntaxContex
4669
foreach (var attribute in attributes)
4770
{
4871
var name = attribute.AttributeClass?.Name;
49-
if (name == null)
72+
if (name == null || !_attributes.Contains(name))
5073
continue;
5174

5275
if (attribute.ConstructorArguments.Length == 1)

0 commit comments

Comments
 (0)