Created
April 17, 2013 08:22
-
-
Save kazuk/5402657 to your computer and use it in GitHub Desktop.
InternalsVisibleTo 属性を吐くT4 Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<#@ template debug="false" hostspecific="true" language="C#" #> | |
<#@ assembly name="System.Core" #> | |
<#@ import namespace="System.Linq" #> | |
<#@ import namespace="System.Text" #> | |
<#@ import namespace="System.IO" #> | |
<#@ import namespace="System.Reflection" #> | |
<#@ import namespace="System.Collections.Generic" #> | |
<#@ output extension=".cs" #> | |
using System.Runtime.CompilerServices; | |
<# | |
RenderInternalsVisibleTo( | |
"DocOfCode.Tests", | |
LoadSignKey( Path.Combine( Path.GetDirectoryName( Host.TemplateFile ), @"..\SignKeys\key.snk" ) )); | |
#> | |
<#+ | |
public byte[] LoadSignKey( string pathName ) | |
{ | |
using( var file = File.Open( pathName, FileMode.Open ) ) | |
{ | |
var keyPair = new StrongNameKeyPair( file ); | |
return keyPair.PublicKey; | |
} | |
} | |
public void RenderInternalsVisibleTo( string assemblyName, byte[] publicKey ) | |
{ | |
#> | |
[assembly: InternalsVisibleTo("<#=assemblyName#>, publicKey=<#=string.Join("",publicKey.Select(b=>b.ToString("x2")))#>")] | |
<#+ | |
} | |
#> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment