зеркало из https://github.com/mono/ikvm-fork.git
Added support for AssemblyVersionAttribute and AssemblyCultureAttribute to ikvmc.
Added warnings for AssemblyDelaySignAttribute, AssemblyKeyFileAttribute and AssemblyKeyNameAttribute. Throw NotImplementedException for AssemblyAlgorithmIdAttribute and AssemblyFlagsAttribute (that exception isn't reachable because these two attributes are not exposed as annotations.)
This commit is contained in:
Родитель
d4c5334936
Коммит
96d9ab24db
|
@ -724,7 +724,7 @@ class IkvmcCompiler
|
|||
return 0;
|
||||
}
|
||||
|
||||
private static bool TryParseVersion(string str, out Version version)
|
||||
internal static bool TryParseVersion(string str, out Version version)
|
||||
{
|
||||
if (str.EndsWith(".*"))
|
||||
{
|
||||
|
|
|
@ -3171,6 +3171,8 @@ namespace IKVM.Internal
|
|||
EmittedLinkageError = 118,
|
||||
EmittedVerificationError = 119,
|
||||
EmittedClassFormatError = 120,
|
||||
InvalidCustomAttribute = 121,
|
||||
IgnoredCustomAttribute = 122,
|
||||
}
|
||||
|
||||
static class StaticCompiler
|
||||
|
@ -3360,6 +3362,14 @@ namespace IKVM.Internal
|
|||
msg = "emitted java.lang.ClassFormatError in \"{0}\"" + Environment.NewLine +
|
||||
" (\"{1}\")";
|
||||
break;
|
||||
case Message.InvalidCustomAttribute:
|
||||
msg = "error emitting \"{0}\" custom attribute" + Environment.NewLine +
|
||||
" (\"{1}\")";
|
||||
break;
|
||||
case Message.IgnoredCustomAttribute:
|
||||
msg = "custom attribute \"{0}\" was ignored" + Environment.NewLine +
|
||||
" (\"{1}\")";
|
||||
break;
|
||||
default:
|
||||
throw new InvalidProgramException();
|
||||
}
|
||||
|
|
|
@ -1538,19 +1538,55 @@ namespace IKVM.Internal
|
|||
|
||||
internal override void Apply(ClassLoaderWrapper loader, AssemblyBuilder ab, object annotation)
|
||||
{
|
||||
// TODO we should support other pseudo custom attributes that Ref.Emit doesn't support (e.g. AssemblyVersionAttribute)
|
||||
if (type.IsSubclassOf(JVM.Import(typeof(SecurityAttribute))))
|
||||
{
|
||||
#if STATIC_COMPILER
|
||||
ab.__AddDeclarativeSecurity(MakeCustomAttributeBuilder(loader, annotation));
|
||||
#endif
|
||||
}
|
||||
#if STATIC_COMPILER
|
||||
else if (type == JVM.Import(typeof(System.Runtime.CompilerServices.TypeForwardedToAttribute)))
|
||||
{
|
||||
#if STATIC_COMPILER
|
||||
ab.__AddTypeForwarder((Type)ConvertValue(loader, Types.Type, ((object[])annotation)[3]));
|
||||
#endif
|
||||
}
|
||||
else if (type == JVM.Import(typeof(System.Reflection.AssemblyVersionAttribute)))
|
||||
{
|
||||
string str = (string)ConvertValue(loader, Types.String, ((object[])annotation)[3]);
|
||||
Version version;
|
||||
if (IkvmcCompiler.TryParseVersion(str, out version))
|
||||
{
|
||||
ab.__SetAssemblyVersion(version);
|
||||
}
|
||||
else
|
||||
{
|
||||
StaticCompiler.IssueMessage(Message.InvalidCustomAttribute, type.FullName, "The version '" + str + "' is invalid.");
|
||||
}
|
||||
}
|
||||
else if (type == JVM.Import(typeof(System.Reflection.AssemblyCultureAttribute)))
|
||||
{
|
||||
string str = (string)ConvertValue(loader, Types.String, ((object[])annotation)[3]);
|
||||
if (str != "")
|
||||
{
|
||||
ab.__SetAssemblyCulture(str);
|
||||
}
|
||||
}
|
||||
else if (type == JVM.Import(typeof(System.Reflection.AssemblyDelaySignAttribute))
|
||||
|| type == JVM.Import(typeof(System.Reflection.AssemblyKeyFileAttribute))
|
||||
|| type == JVM.Import(typeof(System.Reflection.AssemblyKeyNameAttribute)))
|
||||
{
|
||||
StaticCompiler.IssueMessage(Message.IgnoredCustomAttribute, type.FullName, "Please use the corresponding compiler switch.");
|
||||
}
|
||||
else if (type == JVM.Import(typeof(System.Reflection.AssemblyAlgorithmIdAttribute)))
|
||||
{
|
||||
// this attribute is currently not exposed as an annotation and isn't very interesting
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
else if (type == JVM.Import(typeof(System.Reflection.AssemblyFlagsAttribute)))
|
||||
{
|
||||
// this attribute is currently not exposed as an annotation and isn't very interesting
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
ab.SetCustomAttribute(MakeCustomAttributeBuilder(loader, annotation));
|
||||
|
|
Загрузка…
Ссылка в новой задаче