简体   繁体   中英

How Do I Add Custom Properties To CodeDOM Output

我正在尝试向CodeDOM输出添加自定义属性,例如文件版本,作者等。我不确定如何。

For the file version, you have to use AssemblyFileVersion attribute. See the example.

CodeCompileUnit unit = CreateMyUnit();
var attribute = new CodeAttributeDeclaration(
    new CodeTypeReference(typeof(AssemblyFileVersionAttribute)));
attribute.Arguments.Add(
    new CodeAttributeArgument(
        new CodePrimitiveExpression("1.1.1.1")));
unit.AssemblyCustomAttributes.Add(attribute);

As for the author, you may do the similar thing. See the MSDN assembly attribute .

EDIT:

You need add the references.

using System.CodeDom;
using System.CodeDom.Compiler;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM