Skip to content

Commit

Permalink
Merge pull request #5 from skbkontur/net-core-fixes
Browse files Browse the repository at this point in the history
net-core-fixes
  • Loading branch information
fakefeik authored Sep 25, 2019
2 parents 7d3423b + 358b642 commit 4be76ab
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v1.3 - 2019.09.25
- Set TargetFramework to netstandard2.0
- Update dependencies

## v1.2 - 2018.29.12
- Lazy converter expression compilation (some public methods of `ConverterCollection` don't need to be compiled)
- No more failing tests
Expand Down
2 changes: 1 addition & 1 deletion Mutators.Tests/ExpressionCompilerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void TestCompileSimple()
}));
}

[Test, Timeout(20000)]
[Test /*, Timeout(20000)*/]
public void TestCompilePerformance()
{
for (int i = 0; i < 100000; i++)
Expand Down
2 changes: 1 addition & 1 deletion Mutators.Tests/ExpressionEquivalenceCheckerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public void TestMethodCall()
var instance = Expression.Parameter(typeof(string));
var parameter = Expression.Parameter(typeof(string));

var containsMethodInfo = typeof(string).GetMethod("Contains", BindingFlags.Public | BindingFlags.Instance);
var containsMethodInfo = typeof(string).GetMethod("Contains", new[] {typeof(string)});
Assert.That(containsMethodInfo, Is.Not.Null);

TestEquivalent(Expression.Call(instance, containsMethodInfo, parameter), Expression.Call(instance, containsMethodInfo, parameter));
Expand Down
10 changes: 5 additions & 5 deletions Mutators.Tests/Mutators.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

<PropertyGroup>
<IsPackable>false</IsPackable>
<TargetFramework>net472</TargetFramework>
<TargetFrameworks>net472;netcoreapp2.2</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
<PackageReference Include="FluentAssertions" Version="5.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions Mutators/ConverterCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ private static void FindCustomFieldsContainer(Type type, Expression current, Lis
var properties = type.GetOrderedProperties();
foreach (var property in properties)
{
if (property.GetGetMethod().GetParameters().Length != 0)
continue;

var next = Expression.Property(current, property);
if (property.GetCustomAttributes(typeof(CustomFieldsContainerAttribute), false).Any())
{
Expand Down Expand Up @@ -451,6 +454,9 @@ private void ConfigureCustomFieldsForArrays(ConverterConfigurator<TSource, TDest
var parameter = Expression.Parameter(type);
foreach (var property in properties)
{
if (property.GetGetMethod().GetParameters().Length != 0)
continue;

var pathToNextDestChild = pathToDestChild.Merge(Expression.Lambda(Expression.Property(parameter, property), parameter));
if (!property.PropertyType.IsArray)
ConfigureCustomFieldsForArrays(configurator, property.PropertyType, pathToNextDestChild, sourceCustomFieldFits, destCustomFieldFits);
Expand Down
4 changes: 2 additions & 2 deletions Mutators/DataConfiguratorCollectionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ private static Type BuildMutatorsTreeCreator(int numberOfGenericParameters)

typeBuilder.DefineMethodOverride(methodBuilder, method);
typeBuilder.AddInterfaceImplementation(interfaceType);
return typeBuilder.CreateType();
return typeBuilder.CreateTypeInfo();
}

private static readonly string getMutatorsTreeMethodName = ((MethodCallExpression)((Expression<Func<IMutatorsTreeCreator<int>, MutatorsTreeBase<int>>>)(creator => creator.GetMutatorsTree(null, null, null, null))).Body).Method.Name;
private static readonly MethodInfo getDataConfiguratorCollectionMethod = ((MethodCallExpression)((Expression<Func<IDataConfiguratorCollectionFactory, IDataConfiguratorCollection<int>>>)(factory => factory.Get<int>())).Body).Method.GetGenericMethodDefinition();
private static readonly MethodInfo getConverterCollectionMethod = ((MethodCallExpression)((Expression<Func<IConverterCollectionFactory, IConverterCollection<int, int>>>)(factory => factory.Get<int, int>())).Body).Method.GetGenericMethodDefinition();
private static readonly MethodInfo mergeMethod = ((MethodCallExpression)((Expression<Func<MutatorsTreeBase<int>, MutatorsTreeBase<int>, MutatorsTreeBase<int>>>)((first, second) => Merge(first, second))).Body).Method.GetGenericMethodDefinition();

private static readonly AssemblyBuilder assembly = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName(AssemblyName), AssemblyBuilderAccess.Run);
private static readonly AssemblyBuilder assembly = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName(AssemblyName), AssemblyBuilderAccess.Run);
private static readonly ModuleBuilder module = assembly.DefineDynamicModule(Guid.NewGuid().ToString());

private static readonly object lockObject = new object();
Expand Down
6 changes: 3 additions & 3 deletions Mutators/Mutators.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>GrobExp.Mutators</AssemblyName>
<RootNamespace>GrobExp.Mutators</RootNamespace>
</PropertyGroup>
Expand All @@ -14,8 +14,8 @@

<ItemGroup>
<PackageReference Include="GroBuf" Version="1.4.8" />
<PackageReference Include="GrobExp.Compiler" Version="1.2.14" />
<PackageReference Include="Vostok.Logging.Abstractions" Version="1.0.1" />
<PackageReference Include="GrobExp.Compiler" Version="1.3.2" />
<PackageReference Include="Vostok.Logging.Abstractions" Version="1.0.2" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions Mutators/ValidationResultTreeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private static Type BuildTypeInternal(Type type)

typeBuilder.DefineMethodOverride(traverseEdgeMethodBuilder, traverseEdgeMethod);

var result = typeBuilder.CreateType();
var result = typeBuilder.CreateTypeInfo();
typesBeingBuilt[type] = null;
return result;
}
Expand All @@ -181,7 +181,7 @@ private static Type BuildTypeInternal(Type type)
private static readonly Hashtable factories = new Hashtable();
private static readonly object factoriesLock = new object();

private static readonly AssemblyBuilder assembly = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName(Guid.NewGuid().ToString()), AssemblyBuilderAccess.RunAndSave);
private static readonly AssemblyBuilder assembly = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName(Guid.NewGuid().ToString()), AssemblyBuilderAccess.RunAndCollect);
private static readonly ModuleBuilder module = assembly.DefineDynamicModule(Guid.NewGuid().ToString());
}

Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "1.2",
"version": "1.3",
"assemblyVersion": {
"precision": "build"
},
Expand Down

0 comments on commit 4be76ab

Please sign in to comment.