Remove internal `Xamarin.Utils.*` types from platform assemblies (#11811)
Only the `SanitizeObjectiveCName` method _can_ be needed, by the registrar. However if marked then the `StringUtils:.cctor` will also be marked, including the data (`static char[]`) which is not needed for apps Moving `SanitizeObjectiveCName` to the `Registrar` type is simpler and solve (removes) the extra cost (baggage) from the app.
This commit is contained in:
Родитель
fd500dc53c
Коммит
0de6274cb7
|
@ -1,3 +1,4 @@
|
|||
using System.Text;
|
||||
|
||||
namespace Registrar {
|
||||
abstract partial class Registrar {
|
||||
|
@ -12,5 +13,38 @@ namespace Registrar {
|
|||
first = (char) (first - 32 /* 'a' - 'A' */);
|
||||
return "set" + ((char) first).ToString () + getterSelector.Substring (1) + ":";
|
||||
}
|
||||
|
||||
public static string SanitizeObjectiveCName (string name)
|
||||
{
|
||||
StringBuilder sb = null;
|
||||
|
||||
for (int i = 0; i < name.Length; i++) {
|
||||
var ch = name [i];
|
||||
switch (ch) {
|
||||
case '.':
|
||||
case '+':
|
||||
case '/':
|
||||
case '`':
|
||||
case '@':
|
||||
case '<':
|
||||
case '>':
|
||||
case '$':
|
||||
case '-':
|
||||
if (sb == null)
|
||||
sb = new StringBuilder (name, 0, i, name.Length);
|
||||
sb.Append ('_');
|
||||
break;
|
||||
default:
|
||||
if (sb != null)
|
||||
sb.Append (ch);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sb != null)
|
||||
return sb.ToString ();
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,10 +22,10 @@ using System.Text;
|
|||
|
||||
using Foundation;
|
||||
using ObjCRuntime;
|
||||
using Xamarin.Utils;
|
||||
using Xamarin.Bundler;
|
||||
|
||||
#if MTOUCH || MMP || BUNDLER
|
||||
using Xamarin.Utils;
|
||||
using TAssembly=Mono.Cecil.AssemblyDefinition;
|
||||
using TType=Mono.Cecil.TypeReference;
|
||||
using TMethod=Mono.Cecil.MethodDefinition;
|
||||
|
@ -437,7 +437,7 @@ namespace Registrar {
|
|||
throw new InvalidOperationException ();
|
||||
var attrib = CategoryAttribute;
|
||||
var name = attrib.Name ?? Registrar.GetTypeFullName (Type);
|
||||
return StringUtils.SanitizeObjectiveCName (name);
|
||||
return SanitizeObjectiveCName (name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -447,7 +447,7 @@ namespace Registrar {
|
|||
throw new InvalidOperationException ();
|
||||
var attrib = Registrar.GetProtocolAttribute (Type);
|
||||
var name = attrib.Name ?? Registrar.GetTypeFullName (Type);
|
||||
return StringUtils.SanitizeObjectiveCName (name);
|
||||
return SanitizeObjectiveCName (name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2600,7 +2600,7 @@ namespace Registrar {
|
|||
}
|
||||
if (name == null)
|
||||
name = GetTypeFullName (type);
|
||||
return StringUtils.SanitizeObjectiveCName (name);
|
||||
return SanitizeObjectiveCName (name);
|
||||
}
|
||||
|
||||
protected string GetExportedTypeName (TType type)
|
||||
|
|
|
@ -1842,7 +1842,6 @@ SHARED_CORE_SOURCES = \
|
|||
|
||||
SHARED_SOURCES = \
|
||||
../runtime/Delegates.generated.cs \
|
||||
../tools/common/StringUtils.cs \
|
||||
MonoNativeFunctionWrapperAttribute.cs \
|
||||
NativeTypes/NMath.cs \
|
||||
ObjCRuntime/AdoptsAttribute.cs \
|
||||
|
|
|
@ -6412,7 +6412,7 @@ public partial class Generator : IMemberGatherer {
|
|||
if (!string.IsNullOrEmpty (model.Name)) {
|
||||
register_name = model.Name;
|
||||
} else if (model.AutoGeneratedName) {
|
||||
register_name = StringUtils.SanitizeObjectiveCName (GetAssemblyName () + "__" + type.FullName);
|
||||
register_name = Registrar.Registrar.SanitizeObjectiveCName (GetAssemblyName () + "__" + type.FullName);
|
||||
}
|
||||
}
|
||||
Header (sw);
|
||||
|
|
|
@ -221,39 +221,6 @@ namespace Xamarin.Utils {
|
|||
return new Version (major, 0);
|
||||
return Version.Parse (v);
|
||||
}
|
||||
|
||||
public static string SanitizeObjectiveCName (string name)
|
||||
{
|
||||
StringBuilder sb = null;
|
||||
|
||||
for (int i = 0; i < name.Length; i++) {
|
||||
var ch = name [i];
|
||||
switch (ch) {
|
||||
case '.':
|
||||
case '+':
|
||||
case '/':
|
||||
case '`':
|
||||
case '@':
|
||||
case '<':
|
||||
case '>':
|
||||
case '$':
|
||||
case '-':
|
||||
if (sb == null)
|
||||
sb = new StringBuilder (name, 0, i, name.Length);
|
||||
sb.Append ('_');
|
||||
break;
|
||||
default:
|
||||
if (sb != null)
|
||||
sb.Append (ch);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sb != null)
|
||||
return sb.ToString ();
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
static class StringExtensions
|
||||
|
|
Загрузка…
Ссылка в новой задаче