Skip to content

Commit 36c2ae9

Browse files
committed
.Net Standard & .Net Core Support Added
1 parent 9509cf3 commit 36c2ae9

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

src/Interceptors/InstanceInterceptors/InterfaceInterception/InterfaceInterceptorClassGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static InterfaceInterceptorClassGenerator()
4343
pair = ms.ToArray();
4444
}
4545

46-
AssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(
46+
AssemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(
4747
new AssemblyName("Unity_ILEmit_InterfaceProxies") { KeyPair = new StrongNameKeyPair(pair) },
4848
#if DEBUG_SAVE_GENERATED_ASSEMBLY
4949
AssemblyBuilderAccess.RunAndSave);
@@ -129,7 +129,7 @@ public Type CreateProxyType()
129129

130130
AddConstructor();
131131

132-
Type result = _typeBuilder.CreateType();
132+
Type result = _typeBuilder.CreateTypeInfo().AsType();
133133
#if DEBUG_SAVE_GENERATED_ASSEMBLY
134134
assemblyBuilder.Save("Unity_ILEmit_InterfaceProxies.dll");
135135
#endif

src/Interceptors/TypeInterceptors/VirtualMethodInterception/InterceptingClassGeneration/InterceptingClassGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public partial class InterceptingClassGenerator
2828

2929
static InterceptingClassGenerator()
3030
{
31-
AssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(
31+
AssemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(
3232
new AssemblyName("Unity_ILEmit_DynamicClasses"),
3333
#if DEBUG_SAVE_GENERATED_ASSEMBLY
3434
AssemblyBuilderAccess.RunAndSave);
@@ -70,7 +70,7 @@ public Type GenerateType()
7070
.Implement(implementedInterfaces, memberCount);
7171
}
7272

73-
Type result = _typeBuilder.CreateType();
73+
Type result = _typeBuilder.CreateTypeInfo().AsType();
7474
#if DEBUG_SAVE_GENERATED_ASSEMBLY
7575
assemblyBuilder.Save("Unity_ILEmit_DynamicClasses.dll");
7676
#endif

src/Unity.Interception.csproj

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<SignAssembly>true</SignAssembly>
2020
<AssemblyOriginatorKeyFile>package.snk</AssemblyOriginatorKeyFile>
2121
<DelaySign>false</DelaySign>
22+
<TargetFrameworks>netstandard2.0;net47;net46;net45;netcoreapp2.0</TargetFrameworks>
2223
</PropertyGroup>
2324

2425
<ItemGroup>
@@ -33,6 +34,10 @@
3334
<None Remove="package.snk" />
3435
<EmbeddedResource Include="package.snk" />
3536
</ItemGroup>
37+
38+
<ItemGroup>
39+
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
40+
</ItemGroup>
3641

3742
<ItemGroup>
3843
<EmbeddedResource Update="Properties\Resources.resx">
@@ -46,18 +51,16 @@
4651
<EmbeddedResource Remove="Utilities\net 4.0\**" />
4752
<None Remove="Utilities\net 4.0\**" />
4853
</ItemGroup>
49-
50-
54+
55+
5156
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
5257
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
53-
<TargetFrameworks>net47;net46;net45;net40</TargetFrameworks>
5458
<OutputPath>$(SolutionDir)lib</OutputPath>
5559
</PropertyGroup>
56-
60+
5761
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
58-
<DebugType>Full</DebugType>
5962
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
60-
<TargetFramework>net47</TargetFramework>
63+
<DebugType>Full</DebugType>
6164
</PropertyGroup>
6265

6366

@@ -73,4 +76,20 @@
7376
<PackageReference Include="Unity.Abstractions" Version="$(UnityAbstractionsVersion)" />
7477
</ItemGroup>
7578

79+
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
80+
<Reference Include="System.Runtime.Remoting" />
81+
</ItemGroup>
82+
83+
<ItemGroup Condition="'$(TargetFramework)' == 'net46'">
84+
<Reference Include="System.Runtime.Remoting" />
85+
</ItemGroup>
86+
87+
<ItemGroup Condition="'$(TargetFramework)' == 'net47'">
88+
<Reference Include="System.Runtime.Remoting" />
89+
</ItemGroup>
90+
91+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'netcoreapp2.0' ">
92+
<Compile Remove="Interceptors\InstanceInterceptors\TransparentProxyInterception\*.cs" />
93+
</ItemGroup>
94+
7695
</Project>

0 commit comments

Comments
 (0)