Skip to content

Commit 0c2fff0

Browse files
authored
Add GeneratedCodeAttribute in codedom-based generator
1 parent ba1dee1 commit 0c2fff0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Nerdbank.GitVersioning.Tasks/AssemblyVersionInfo.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,14 @@ private CodeTypeDeclaration CreateThisAssemblyClass()
119119
{
120120
IsClass = true,
121121
IsPartial = true,
122-
TypeAttributes = TypeAttributes.NotPublic | TypeAttributes.Sealed,
122+
TypeAttributes = TypeAttributes.NotPublic | TypeAttributes.Sealed | TypeAttributes.Abstract,
123123
};
124+
125+
var codeAttributeDeclarationCollection = new CodeAttributeDeclarationCollection();
126+
codeAttributeDeclarationCollection.Add(new CodeAttributeDeclaration("System.CodeDom.Compiler.GeneratedCode",
127+
new CodeAttributeArgument(new CodePrimitiveExpression(ThisAssembly.AssemblyName)),
128+
new CodeAttributeArgument(new CodePrimitiveExpression(ThisAssembly.AssemblyVersion))));
129+
thisAssembly.CustomAttributes = codeAttributeDeclarationCollection;
124130

125131
// CodeDOM doesn't support static classes, so hide the constructor instead.
126132
thisAssembly.Members.Add(new CodeConstructor { Attributes = MemberAttributes.Private });

0 commit comments

Comments
 (0)