зеркало из https://github.com/mono/ikvm-fork.git
Removed class name length limitation.
This commit is contained in:
Родитель
848311cad9
Коммит
7bb7d9886f
|
@ -421,11 +421,6 @@ namespace IKVM.Internal
|
|||
|
||||
private TypeWrapper LoadClassByDottedNameFastImpl(string name, bool throwClassNotFoundException)
|
||||
{
|
||||
// .NET 1.1 has a limit of 1024 characters for type names
|
||||
if(name.Length >= 1024 || name.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Profiler.Enter("LoadClassByDottedName");
|
||||
try
|
||||
{
|
||||
|
|
|
@ -152,7 +152,16 @@ namespace IKVM.Internal
|
|||
string mangledTypeName;
|
||||
lock(dynamicTypes)
|
||||
{
|
||||
mangledTypeName = TypeNameUtil.EscapeName(tw.Name);
|
||||
// the CLR maximum type name length is 1023 characters,
|
||||
// but we need to leave some room for the suffix that we
|
||||
// may need to append to make the name unique
|
||||
const int MaxLength = 1000;
|
||||
string name = tw.Name;
|
||||
if (name.Length > MaxLength)
|
||||
{
|
||||
name = name.Substring(0, MaxLength) + "/truncated";
|
||||
}
|
||||
mangledTypeName = TypeNameUtil.ReplaceIllegalCharacters(name);
|
||||
// FXBUG the CLR (both 1.1 and 2.0) doesn't like type names that end with a single period,
|
||||
// it loses the trailing period in the name that gets passed in the TypeResolve event.
|
||||
if(dynamicTypes.ContainsKey(mangledTypeName) || mangledTypeName.EndsWith("."))
|
||||
|
|
|
@ -1128,7 +1128,7 @@ namespace IKVM.Internal
|
|||
private static string GetInnerClassName(string outer, string inner)
|
||||
{
|
||||
Debug.Assert(CheckInnerOuterNames(inner, outer));
|
||||
return TypeNameUtil.EscapeName(inner.Substring(outer.Length + 1));
|
||||
return TypeNameUtil.ReplaceIllegalCharacters(inner.Substring(outer.Length + 1));
|
||||
}
|
||||
#endif // STATIC_COMPILER
|
||||
|
||||
|
|
|
@ -1346,37 +1346,12 @@ namespace IKVM.Internal
|
|||
static class TypeNameUtil
|
||||
{
|
||||
// note that MangleNestedTypeName() assumes that there are less than 16 special characters
|
||||
private static readonly char[] specialCharacters = { '\\', '+', ',', '[', ']', '*', '&', '\u0000' };
|
||||
private static readonly string specialCharactersString = new String(specialCharacters);
|
||||
private const string specialCharactersString = "\\+,[]*&\u0000";
|
||||
|
||||
internal static string EscapeName(string name)
|
||||
internal static string ReplaceIllegalCharacters(string name)
|
||||
{
|
||||
// TODO the escaping of special characters is not required on .NET 2.0
|
||||
// (but it doesn't really hurt that much either, the only overhead is the
|
||||
// extra InnerClassAttribute to record the real name of the class)
|
||||
// Note that even though .NET 2.0 automatically escapes the special characters,
|
||||
// the name that gets passed in ResolveEventArgs.Name of the TypeResolve event
|
||||
// contains the unescaped type name.
|
||||
if (name.IndexOfAny(specialCharacters) >= 0)
|
||||
{
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
||||
foreach (char c in name)
|
||||
{
|
||||
if (specialCharactersString.IndexOf(c) >= 0)
|
||||
{
|
||||
if (c == 0)
|
||||
{
|
||||
// we can't escape the NUL character, so we replace it with a space.
|
||||
sb.Append(' ');
|
||||
continue;
|
||||
}
|
||||
sb.Append('\\');
|
||||
}
|
||||
sb.Append(c);
|
||||
}
|
||||
name = sb.ToString();
|
||||
}
|
||||
return name;
|
||||
// only the NUL character is illegal in CLR type names, so we replace it with a space
|
||||
return name.Replace('\u0000', ' ');
|
||||
}
|
||||
|
||||
internal static string MangleNestedTypeName(string name)
|
||||
|
|
Загрузка…
Ссылка в новой задаче