Skip to content

Commit 0e66d19

Browse files
author
Josh Peterson
committed
Compile ProcessImportedType in IDataContractSurrogate for unityaot
The `IDataContractSurrogate` interface is part of the public API of .NET 4.7.1. In has a method named `ProcessImportedType`, which was not compiled into the unityaot profile. The `ProcessImportedType` method uses types `CodeTypeDeclaration` and `CodeCompileUnit` as parameters. Both of these types are pretty large, and we don't want to compile them into the unityaot profile. So in order to compile the `ProcessImportedType` method method, add empty `CodeTypeDeclaration` and `CodeCompileUnit` types in unityaot (the profile stubber will fill these in properly). This change allows the unstripped unityaot profile work correctly with IL2CPP. It is difficult for the profile stubber to handle this case, because the code in `SurrogateProviderAdapter` is in a facade assembly, which the profile stubber currently ignores.
1 parent a69e92f commit 0e66d19

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

mcs/class/Facades/System.Runtime.Serialization.Xml/DataContractSerializerExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
#if !NO_CODEDOM
5+
#if !NO_CODEDOM || UNITY_AOT
66
using System.CodeDom;
77
#endif
88
using System.Collections.ObjectModel;
@@ -73,7 +73,7 @@ public Type GetReferencedTypeOnImport(string typeName, string typeNamespace, obj
7373
throw NotImplemented.ByDesign;
7474
}
7575

76-
#if !NO_CODEDOM
76+
#if !NO_CODEDOM || UNITY_AOT
7777
public CodeTypeDeclaration ProcessImportedType(CodeTypeDeclaration typeDeclaration, CodeCompileUnit compileUnit)
7878
{
7979
throw NotImplemented.ByDesign;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#if UNITY_AOT
2+
3+
public class CodeCompileUnit
4+
{
5+
}
6+
7+
#endif
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#if UNITY_AOT
2+
3+
public class CodeTypeDeclaration
4+
{
5+
}
6+
7+
#endif

mcs/class/System/unityaot_System.dll.sources

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
../System.Web/System.Web/HttpUtility.cs
33
../System.Web/System.Web.Util/Helpers.cs
44
../System.Web/System.Web.Util/HttpEncoder.cs
5+
System.CodeDom/CodeCompileUnit.cs
6+
System.CodeDom/CodeTypeDeclaration.cs

mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/IDataContractSurrogate.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public interface IDataContractSurrogate
1717
object GetCustomDataToExport(Type clrType, Type dataContractType);
1818
void GetKnownCustomDataTypes(Collection<Type> customDataTypes);
1919
Type GetReferencedTypeOnImport(string typeName, string typeNamespace, object customData);
20-
#if !NO_CODEDOM
20+
#if !NO_CODEDOM || UNITY_AOT
2121
CodeTypeDeclaration ProcessImportedType(CodeTypeDeclaration typeDeclaration, CodeCompileUnit compileUnit);
2222
#endif
2323
}
@@ -70,11 +70,11 @@ internal static Type GetReferencedTypeOnImport(IDataContractSurrogate surrogate,
7070
return null;
7171
return surrogate.GetReferencedTypeOnImport(typeName, typeNamespace, customData);
7272
}
73-
#if !NO_CODEDOM
73+
#if !NO_CODEDOM || UNITY_AOT
7474
internal static CodeTypeDeclaration ProcessImportedType(IDataContractSurrogate surrogate, CodeTypeDeclaration typeDeclaration, CodeCompileUnit compileUnit)
7575
{
7676
return surrogate.ProcessImportedType(typeDeclaration, compileUnit);
7777
}
7878
#endif
7979
}
80-
}
80+
}

0 commit comments

Comments
 (0)