System.Orgyを正当化するextern alias
アセンブリの
System.Configuration.dllをビルドするには、System.dllをビルドしなければならないのだが、System.dllにあるいくつかのクラス、たとえばSystem.Net.Configuration.ModuleElementには、System.Configuration.dllのSystem.Configuration.ConfigurationElementが必要になる。*2
めんどっちいのは、これをbootstrapとfullのビルド2回転で実現しようとすると、System.Configuration.dllをビルドするときに、bootstrapのSystem.dllにあるNameValueCollectionとfullのSystem.dllにあるNameValueCollectionの2つが区別できないというエラーが出る(CS0029の一類型)。
それで、解決方法を探していて、extern aliasとゆー非常にマイナーな機能を見つけたのだけど、mcsのサポートはまだ完全ではないようだ。
これと関係してTypeForwardedToAttributeというのも気になっていて、MSこれ使ってるんじゃねーの?と思うのだけど、corcompareの結果を見る限り全く使っていないようだ追記のとおりで、実際には不明。*3
System.Runtime.CompilerServicesには、やっつけ用のクラスがいろいろ増えていそうな予感がする。
追記:
生成されたdllに残らないというのでビンゴらしい。
using System.Runtime.CompilerServices;
using System;
using System.Reflection;[assembly:CLSCompliant (true)]
[assembly:TypeForwardedTo (typeof (string))]
public class Test
{
public static void Main ()
{
foreach (Attribute a in
Assembly.GetExecutingAssembly ()
.GetCustomAttributes (true))
Console.WriteLine (a.GetType ());
}
}
$ csc typeforwardedtoattribute.cs -nologo$ mono typeforwardedtoattribute.exe
System.Runtime.CompilerServices.RuntimeCompatibilityAttribute
System.Runtime.CompilerServices.CompilationRelaxationsAttribute
System.CLSCompliantAttribute$ gmcs typeforwardedtoattribute.cs
$ mono typeforwardedtoattribute.exe
System.CLSCompliantAttribute
System.Runtime.CompilerServices.RuntimeCompatibilityAttribute
System.Runtime.CompilerServices.TypeForwardedToAttribute