Skip to content

Commit

Permalink
* cleanup csprojs
Browse files Browse the repository at this point in the history
* don't think we need CopyLocalLockFileAssemblies=true
* build Tests project against net45 and netcoreapp2.0 target frameworks
* update nunit to v3.9.0
* remove obsolete thrash
  • Loading branch information
AndrewKostousov committed Jan 1, 2018
1 parent 0457a23 commit 307c9e1
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 10,578 deletions.
Binary file removed Assemblies/nunit.framework.dll
Binary file not shown.
10,407 changes: 0 additions & 10,407 deletions Assemblies/nunit.framework.xml

This file was deleted.

18 changes: 0 additions & 18 deletions GrEmit.nuspec

This file was deleted.

32 changes: 3 additions & 29 deletions GrEmit/AsmToBytes/AsmToBytes.csproj
Original file line number Diff line number Diff line change
@@ -1,33 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net45</TargetFrameworks>
<Authors>SKB Kontur.</Authors>
<Company>SKB Kontur</Company>
<Description>GrEmit is a library containing different helpers for generating code using Reflection.Emit with the main one being GroboIL - a smart wrapper over ILGenerator.</Description>
<Copyright>Copyright � SKB Kontur 2017.</Copyright>
<PackageProjectUrl>https://github.com/skbkontur/gremit</PackageProjectUrl>
<RepositoryUrl>https://github.com/skbkontur/gremit</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>.NET</PackageTags>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<Version>1.0.0</Version>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPackable>false</IsPackable>
<TargetFrameworks>netcoreapp2.0;net45</TargetFrameworks>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Collections" Version="4.3.0" />
<PackageReference Include="System.Runtime" Version="4.3.0" />
</ItemGroup>
</Project>
</Project>
37 changes: 9 additions & 28 deletions GrEmit/GrEmit/GrEmit.csproj
Original file line number Diff line number Diff line change
@@ -1,42 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
<Authors>SKB Kontur.</Authors>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>1701;1702;1705;1591</NoWarn>
<PackageId>GrEmit</PackageId>
<Version>2.2.0</Version>
<AssemblyVersion>2.2.0.0</AssemblyVersion>
<Authors>Igor Chevdar</Authors>
<Company>SKB Kontur</Company>
<Copyright>SKB Kontur 2012-2017</Copyright>
<Description>GrEmit is a library containing different helpers for generating code using Reflection.Emit with the main one being GroboIL - a smart wrapper over ILGenerator.</Description>
<Copyright>Copyright � SKB Kontur 2017.</Copyright>
<PackageTags>.NET Reflection Emit ILGenerator</PackageTags>
<PackageProjectUrl>https://github.com/skbkontur/gremit</PackageProjectUrl>
<RepositoryUrl>https://github.com/skbkontur/gremit</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>.NET</PackageTags>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>bin\Release\$(TargetFramework)\GrEmit.xml</DocumentationFile>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='net45'">
<DefineConstants>NET45</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
<DefineConstants>NETSTANDARD20</DefineConstants>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
<PackageReference Include="System.Collections" Version="4.3.0" />
<PackageReference Include="System.Runtime" Version="4.3.0" />
<PackageReference Include="System.IO" Version="4.3.0" />
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
<PackageReference Include="System.Reflection.Emit.ILGeneration" Version="4.3.0" />
<PackageReference Include="System.Reflection.Primitives" Version="4.3.0" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.3.0" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
</Project>
20 changes: 11 additions & 9 deletions GrEmit/GrEmit/GroboIL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
#if !NETSTANDARD2_0
using System.Runtime.InteropServices;
#endif

using GrEmit.InstructionComments;
using GrEmit.InstructionParameters;
Expand Down Expand Up @@ -129,7 +131,7 @@ public void Dispose()
{
if(!ReflectionExtensions.IsMono)
{
#if NET45
#if !NETSTANDARD2_0
if(Marshal.GetExceptionPointers() != IntPtr.Zero || Marshal.GetExceptionCode() != 0)
return;
#endif
Expand Down Expand Up @@ -301,8 +303,8 @@ public void MarkSequencePoint(ISymbolDocumentWriter document, int startLine, int

public static void MarkSequencePoint(ILGenerator il, ISymbolDocumentWriter document, int startLine, int startColumn, int endLine, int endColumn)
{
#if NETSTANDARD20
throw new InvalidOperationException("Not supported.");
#if NETSTANDARD2_0
throw new NotSupportedException("Not supported for netstandard2.0");
#else
il.MarkSequencePoint(document, startLine, startColumn, endLine, endColumn);
#endif
Expand Down Expand Up @@ -1972,7 +1974,7 @@ public void Calli(CallingConventions callingConvention, Type returnType, Type[]
il.EmitCalli(OpCodes.Calli, callingConvention, returnType, parameterTypes, optionalParameterTypes);
}

#if NET45
#if !NETSTANDARD2_0
/// <summary>
/// Calls the method indicated on the evaluation stack (as a pointer to an entry point) with arguments described by a calling convention.
/// </summary>
Expand Down Expand Up @@ -2019,10 +2021,10 @@ private void Emit(OpCode opCode, ILInstructionParameter parameter)
if(calliParameter.ManagedCallingConvention != null)
il.EmitCalli(opCode, calliParameter.ManagedCallingConvention.Value, calliParameter.ReturnType, calliParameter.ParameterTypes, null);
else
#if NET45
il.EmitCalli(opCode, calliParameter.UnmanagedCallingConvention.Value, calliParameter.ReturnType, calliParameter.ParameterTypes);
#if NETSTANDARD2_0
throw new NotSupportedException("Unmanaged function call is not supported for netstandard2.0");
#else
throw new ArgumentException("Unmanaged function call is not supported.");
il.EmitCalli(opCode, calliParameter.UnmanagedCallingConvention.Value, calliParameter.ReturnType, calliParameter.ParameterTypes);
#endif
}
else
Expand Down Expand Up @@ -2328,8 +2330,8 @@ public void SetLocalSymInfo(string name)

public static void SetLocalSymInfo(LocalBuilder localBuilder, string name)
{
#if NETSTANDARD20
throw new InvalidOperationException("Not supported");
#if NETSTANDARD2_0
throw new NotSupportedException("Not supported for netstandard2.0");
#else
localBuilder.SetLocalSymInfo(name);
#endif
Expand Down
42 changes: 22 additions & 20 deletions GrEmit/Tests/ReflectionExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Reflection;
using System.Reflection.Emit;

using GrEmit;
using GrEmit.Utils;

using NUnit.Framework;
Expand All @@ -13,10 +12,14 @@ namespace Tests
[TestFixture]
public class ReflectionExtensionsTest
{
[TestFixtureSetUp]
[OneTimeSetUp]
public void TestFixtureSetUp()
{
#if NET45
var assembly = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName(Guid.NewGuid().ToString()), AssemblyBuilderAccess.Run);
#else
var assembly = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName(Guid.NewGuid().ToString()), AssemblyBuilderAccess.Run);
#endif
module = assembly.DefineDynamicModule(Guid.NewGuid().ToString());
}

Expand All @@ -25,7 +28,7 @@ public void TestRuntimeMethodInfo_NonGenericClassNonGenericMethod()
{
var methodInfo = HackHelpers.GetMethodDefinition<NonGenericClass>(x => x.NonGenericMethod(0, null));
var parameterTypes = ReflectionExtensions.GetParameterTypes(methodInfo);
CollectionAssert.AreEqual(new[] {typeof(int), typeof(string)}, parameterTypes);
CollectionAssert.AreEqual(new[] { typeof(int), typeof(string) }, parameterTypes);
Assert.AreEqual(typeof(string), ReflectionExtensions.GetReturnType(methodInfo));
}

Expand All @@ -34,7 +37,7 @@ public void TestRuntimeMethodInfo_NonGenericClassGenericMethod()
{
var methodInfo = HackHelpers.GetMethodDefinition<NonGenericClass>(x => x.GenericMethod<double, string>(0, 0, 0, null, 0, null, null));
var parameterTypes = ReflectionExtensions.GetParameterTypes(methodInfo);
CollectionAssert.AreEqual(new[] {typeof(double), typeof(int), typeof(double), typeof(List<string>), typeof(int), typeof(double[]), typeof(string)}, parameterTypes);
CollectionAssert.AreEqual(new[] { typeof(double), typeof(int), typeof(double), typeof(List<string>), typeof(int), typeof(double[]), typeof(string) }, parameterTypes);
Assert.AreEqual(typeof(List<string[]>), ReflectionExtensions.GetReturnType(methodInfo));
}

Expand All @@ -43,7 +46,7 @@ public void TestRuntimeMethodInfo_GenericClassNonGenericMethod()
{
var methodInfo = HackHelpers.GetMethodDefinition<GenericClass<double, string>>(x => x.NonGenericMethod(0, 0, null, null, 0, null));
var parameterTypes = ReflectionExtensions.GetParameterTypes(methodInfo);
CollectionAssert.AreEqual(new[] {typeof(double), typeof(int), typeof(List<string>), typeof(string), typeof(int), typeof(double[])}, parameterTypes);
CollectionAssert.AreEqual(new[] { typeof(double), typeof(int), typeof(List<string>), typeof(string), typeof(int), typeof(double[]) }, parameterTypes);
Assert.AreEqual(typeof(List<string[]>), ReflectionExtensions.GetReturnType(methodInfo));
}

Expand All @@ -52,7 +55,7 @@ public void TestRuntimeMethodInfo_GenericClassGenericMethod()
{
var methodInfo = HackHelpers.GetMethodDefinition<GenericClass<double, string>>(x => x.GenericMethod<short, long>(0, 0, 0, null, 0, null, null, 0, 0, null, 0));
var parameterTypes = ReflectionExtensions.GetParameterTypes(methodInfo);
CollectionAssert.AreEqual(new[] {typeof(double), typeof(short), typeof(int), typeof(List<string>), typeof(short), typeof(string), typeof(List<long>), typeof(int), typeof(short), typeof(double[]), typeof(long)}, parameterTypes);
CollectionAssert.AreEqual(new[] { typeof(double), typeof(short), typeof(int), typeof(List<string>), typeof(short), typeof(string), typeof(List<long>), typeof(int), typeof(short), typeof(double[]), typeof(long) }, parameterTypes);
Assert.AreEqual(typeof(List<Tuple<string[], long>>), ReflectionExtensions.GetReturnType(methodInfo));
}

Expand All @@ -61,24 +64,24 @@ public void TestRuntimeMethodInfo_NonGenericClassConstructor()
{
var methodInfo = HackHelpers.GetObjectConstruction(() => new NonGenericClass(0, null));
var parameterTypes = ReflectionExtensions.GetParameterTypes(methodInfo);
CollectionAssert.AreEqual(new[] {typeof(int), typeof(string)}, parameterTypes);
CollectionAssert.AreEqual(new[] { typeof(int), typeof(string) }, parameterTypes);
}

[Test]
public void TestRuntimeMethodInfo_GenericClassConstructor()
{
var methodInfo = HackHelpers.GetObjectConstruction(() => new GenericClass<double, string>(0, 0, null, null, 0, null));
var parameterTypes = ReflectionExtensions.GetParameterTypes(methodInfo);
CollectionAssert.AreEqual(new[] {typeof(double), typeof(int), typeof(List<string>), typeof(string), typeof(int), typeof(double[])}, parameterTypes);
CollectionAssert.AreEqual(new[] { typeof(double), typeof(int), typeof(List<string>), typeof(string), typeof(int), typeof(double[]) }, parameterTypes);
}

[Test]
public void TestMethodBuilder_NonGenericClassNonGenericMethod()
{
var typeBuilder = module.DefineType("NonGenericClass" + Guid.NewGuid(), TypeAttributes.Class | TypeAttributes.Public);
var methodBuilder = typeBuilder.DefineMethod("NonGenericMethod", MethodAttributes.Public, typeof(string), new[] {typeof(int), typeof(string)});
var methodBuilder = typeBuilder.DefineMethod("NonGenericMethod", MethodAttributes.Public, typeof(string), new[] { typeof(int), typeof(string) });
var parameterTypes = ReflectionExtensions.GetParameterTypes(methodBuilder);
CollectionAssert.AreEqual(new[] {typeof(int), typeof(string)}, parameterTypes);
CollectionAssert.AreEqual(new[] { typeof(int), typeof(string) }, parameterTypes);
Assert.AreEqual(typeof(string), ReflectionExtensions.GetReturnType(methodBuilder));
}

Expand All @@ -95,7 +98,7 @@ public void TestMethodBuilder_NonGenericClassGenericMethod()
methodBuilder.SetReturnType(typeof(List<>).MakeGenericType(genericParameters[1].MakeArrayType()));
var instantiatedMethod = methodBuilder.MakeGenericMethod(typeof(double), typeof(string));
var parameterTypes = ReflectionExtensions.GetParameterTypes(instantiatedMethod);
CollectionAssert.AreEqual(new[] {typeof(double), typeof(int), typeof(double), typeof(List<string>), typeof(int), typeof(double[]), typeof(string)}, parameterTypes);
CollectionAssert.AreEqual(new[] { typeof(double), typeof(int), typeof(double), typeof(List<string>), typeof(int), typeof(double[]), typeof(string) }, parameterTypes);
Assert.AreEqual(typeof(List<string[]>), ReflectionExtensions.GetReturnType(instantiatedMethod));
}

Expand All @@ -107,10 +110,10 @@ public void TestMethodBuilder_GenericClassNonGenericMethod()
var t1 = genericParameters[0];
var t2 = genericParameters[1];
// T1 x, int y, List<T2> s, T2 t, int z, T1[] q
var methodBuilder = typeBuilder.DefineMethod("NonGenericMethod", MethodAttributes.Public, typeof(List<>).MakeGenericType(t2.MakeArrayType()), new[] {t1, typeof(int), typeof(List<>).MakeGenericType(t2), t2, typeof(int), t1.MakeArrayType()});
var methodBuilder = typeBuilder.DefineMethod("NonGenericMethod", MethodAttributes.Public, typeof(List<>).MakeGenericType(t2.MakeArrayType()), new[] { t1, typeof(int), typeof(List<>).MakeGenericType(t2), t2, typeof(int), t1.MakeArrayType() });
var instantiatedMethod = TypeBuilder.GetMethod(typeBuilder.MakeGenericType(typeof(double), typeof(string)), methodBuilder);
var parameterTypes = ReflectionExtensions.GetParameterTypes(instantiatedMethod);
CollectionAssert.AreEqual(new[] {typeof(double), typeof(int), typeof(List<string>), typeof(string), typeof(int), typeof(double[])}, parameterTypes);
CollectionAssert.AreEqual(new[] { typeof(double), typeof(int), typeof(List<string>), typeof(string), typeof(int), typeof(double[]) }, parameterTypes);
Assert.AreEqual(typeof(List<string[]>), ReflectionExtensions.GetReturnType(instantiatedMethod));
}

Expand All @@ -130,17 +133,17 @@ public void TestMethodBuilder_GenericClassGenericMethod()
methodBuilder.SetReturnType(typeof(List<>).MakeGenericType(typeof(Tuple<,>).MakeGenericType(t2.MakeArrayType(), t4)));
var instantiatedMethod = TypeBuilder.GetMethod(typeBuilder.MakeGenericType(typeof(double), typeof(string)), methodBuilder).MakeGenericMethod(typeof(short), typeof(long));
var parameterTypes = ReflectionExtensions.GetParameterTypes(instantiatedMethod);
CollectionAssert.AreEqual(new[] {typeof(double), typeof(short), typeof(int), typeof(List<string>), typeof(short), typeof(string), typeof(List<long>), typeof(int), typeof(short), typeof(double[]), typeof(long)}, parameterTypes);
CollectionAssert.AreEqual(new[] { typeof(double), typeof(short), typeof(int), typeof(List<string>), typeof(short), typeof(string), typeof(List<long>), typeof(int), typeof(short), typeof(double[]), typeof(long) }, parameterTypes);
Assert.AreEqual(typeof(List<Tuple<string[], long>>), ReflectionExtensions.GetReturnType(instantiatedMethod));
}

[Test]
public void TestConstructorBuilder_NonGenericClass()
{
var typeBuilder = module.DefineType("NonGenericClass" + Guid.NewGuid(), TypeAttributes.Class | TypeAttributes.Public);
var methodBuilder = typeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.HasThis, new[] {typeof(int), typeof(string)});
var methodBuilder = typeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.HasThis, new[] { typeof(int), typeof(string) });
var parameterTypes = ReflectionExtensions.GetParameterTypes(methodBuilder);
CollectionAssert.AreEqual(new[] {typeof(int), typeof(string)}, parameterTypes);
CollectionAssert.AreEqual(new[] { typeof(int), typeof(string) }, parameterTypes);
}

[Test]
Expand All @@ -154,14 +157,14 @@ public void TestConstructorBuilder_GenericClass()
var methodBuilder = typeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.HasThis, new[] { t1, typeof(int), typeof(List<>).MakeGenericType(t2), t2, typeof(int), t1.MakeArrayType() });
var instantiatedMethod = TypeBuilder.GetConstructor(typeBuilder.MakeGenericType(typeof(double), typeof(string)), methodBuilder);
var parameterTypes = ReflectionExtensions.GetParameterTypes(instantiatedMethod);
CollectionAssert.AreEqual(new[] {typeof(double), typeof(int), typeof(List<string>), typeof(string), typeof(int), typeof(double[])}, parameterTypes);
CollectionAssert.AreEqual(new[] { typeof(double), typeof(int), typeof(List<string>), typeof(string), typeof(int), typeof(double[]) }, parameterTypes);
}

[Test]
public void TestRuntimeType()
{
Assert.AreEqual(typeof(C1<List<int>>), ReflectionExtensions.GetBaseType(typeof(C2<int, string>)));
CollectionAssert.AreEquivalent(new[] { typeof(I3<int, double, string>), typeof(I2<int, double[]>), typeof(I1<List<int>>), typeof(I1<List<int[]>>)}, ReflectionExtensions.GetInterfaces(typeof(C3<int, double, string>)));
CollectionAssert.AreEquivalent(new[] { typeof(I3<int, double, string>), typeof(I2<int, double[]>), typeof(I1<List<int>>), typeof(I1<List<int[]>>) }, ReflectionExtensions.GetInterfaces(typeof(C3<int, double, string>)));
}

[Test]
Expand Down Expand Up @@ -233,9 +236,8 @@ public interface I2<T1, T2> : I1<List<T1>>
{
}

public interface I3<T1, T2, T3>: I2<T1, T2[]>
public interface I3<T1, T2, T3> : I2<T1, T2[]>
{

}

public class C1<T> : I1<T>
Expand Down
Loading

0 comments on commit 307c9e1

Please sign in to comment.