private static void AddPublicKeyTokenAttribute(GeneratorExecutionContext context) { var syntaxWriter = new CurlyIndenter(new System.CodeDom.Compiler.IndentedTextWriter(new StringWriter())); syntaxWriter.WriteLine("using System;"); syntaxWriter.WriteLine("using System.Runtime.CompilerServices;"); syntaxWriter.WriteLine(); syntaxWriter.WriteLine("namespace Xenial"); syntaxWriter.OpenBrace(); syntaxWriter.WriteLine("[AttributeUsage(AttributeTargets.Assembly)]"); syntaxWriter.WriteLine("[CompilerGenerated]"); syntaxWriter.WriteLine("internal class XenialPublicKeyAttribute : Attribute"); syntaxWriter.OpenBrace(); syntaxWriter.WriteLine("public string PublicKey { get; }"); syntaxWriter.WriteLine("public XenialPublicKeyAttribute(string publicKey)"); syntaxWriter.Indent(); syntaxWriter.WriteLine("=> PublicKey = publicKey;"); syntaxWriter.UnIndent(); syntaxWriter.CloseBrace(); syntaxWriter.CloseBrace(); var syntax = syntaxWriter.ToString(); var source = SourceText.From(syntax, Encoding.UTF8); context.AddSource("XenialPublicKeyAttribute.g.cs", source); }
private static void AddCheckLicenceAttribute(GeneratorExecutionContext context) { var syntaxWriter = new CurlyIndenter(new System.CodeDom.Compiler.IndentedTextWriter(new StringWriter())); syntaxWriter.WriteLine("using System;"); syntaxWriter.WriteLine("using System.Runtime.CompilerServices;"); syntaxWriter.WriteLine(); syntaxWriter.WriteLine("namespace Xenial"); syntaxWriter.OpenBrace(); syntaxWriter.WriteLine("[AttributeUsage(AttributeTargets.Class)]"); syntaxWriter.WriteLine("[CompilerGenerated]"); syntaxWriter.WriteLine("internal class XenialCheckLicenceAttribute : Attribute"); syntaxWriter.OpenBrace(); syntaxWriter.WriteLine("public XenialCheckLicenceAttribute() { }"); syntaxWriter.CloseBrace(); syntaxWriter.CloseBrace(); var syntax = syntaxWriter.ToString(); var source = SourceText.From(syntax, Encoding.UTF8); context.AddSource("XenialCheckLicenceAttribute.g.cs", source); }