Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ install:

environment:
PATH: $(PATH);$(PROGRAMFILES)\dotnet\

# https://www.appveyor.com/docs/build-configuration/#secure-variables
# However, secure variables are not decoded during Pull Request builds which prevents someone from submitting PR with malicious build script displaying those variables. In more controlled environment through with a trusted team and private GitHub repositories there is an option on General tab of project settings to allow secure variables for PRs.
COVERALLS_REPO_TOKEN:
secure: tsTABRbCmdWFLT194XNIrpurerOfjN6cEoxt2RaSUfLmUIgra/+CwuqVkv0sPRop
SONAR_TOKEN:
secure: guog1+ttdnlD8sVgvizlewksm3qbO7dy2oZUcR8WhurWYvdOByinxXo732hmSaMT


before_build:
# Remove UAP10 and netstandard20 from csproj
#- cmd: copy /Y src\System.Linq.Dynamic.Core\System.Linq.Dynamic.Core.AppVeyor.csproj src\System.Linq.Dynamic.Core\System.Linq.Dynamic.Core.csproj
Expand All @@ -39,7 +43,7 @@ before_build:

build_script:
# Begin SonarScanner
- dotnet sonarscanner begin /k:"system.linq.dynamic.core" /d:sonar.organization="stefh-github" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.login="%SONAR_TOKEN%" /v:"%APPVEYOR_BUILD_NUMBER%" /d:sonar.cs.opencover.reportsPaths="%CD%\coverage.xml"
- ps: if (-Not $env:APPVEYOR_PULL_REQUEST_NUMBER) { & "dotnet sonarscanner begin /k:\"system.linq.dynamic.core\" /d:sonar.organization=\"stefh-github\" /d:sonar.host.url=\"https://sonarcloud.io\" /d:sonar.login=\"%SONAR_TOKEN%\" /v:\"%APPVEYOR_BUILD_NUMBER%\" /d:sonar.cs.opencover.reportsPaths=\"%CD%\coverage.xml\"" }

# Build Code
- dotnet build src\EntityFramework.DynamicLinq\EntityFramework.DynamicLinq.csproj -c %CONFIGURATION%
Expand All @@ -59,7 +63,7 @@ test_script:
- cmd: '"OpenCover\tools\OpenCover.Console.exe" -target:dotnet.exe -targetargs:"test test\System.Linq.Dynamic.Core.Tests\System.Linq.Dynamic.Core.Tests.csproj --configuration %CONFIGURATION% --framework netcoreapp1.1 --no-build" -output:coverage.xml -register:user -filter:"+[Microsoft.EntityFrameworkCore.DynamicLinq]* +[System.Linq.Dynamic.Core]* -[*Tests*]*" -nodefaultfilters -returntargetcode -oldstyle'
- codecov -f "coverage.xml"
- coveralls.net\tools\csmacnz.Coveralls.exe --opencover -i .\coverage.xml
- dotnet sonarscanner end /d:sonar.login="%SONAR_TOKEN%"
- ps: if (-Not $env:APPVEYOR_PULL_REQUEST_NUMBER) { & "dotnet sonarscanner end /d:sonar.login=\"%SONAR_TOKEN%\"" }

# Run tests for EntityFramework.DynamicLinq
- dotnet test -c %CONFIGURATION% --no-build test\EntityFramework.DynamicLinq.Tests\EntityFramework.DynamicLinq.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@
<Compile Include="..\..\test\System.Linq.Dynamic.Core.Tests\Helpers\TestEnum.cs">
<Link>Helpers\TestEnum.cs</Link>
</Compile>
<Compile Include="..\..\test\System.Linq.Dynamic.Core.Tests\Helpers\Models\UserProfileDetails.cs">
<Link>Helpers\Models\UserProfileDetails.cs</Link>
</Compile>
<Compile Include="..\..\test\System.Linq.Dynamic.Core.Tests\Helpers\Models\UserState.cs">
<Link>Helpers\Models\UserState.cs</Link>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/System.Linq.Dynamic.Core/DynamicExpressionParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static LambdaExpression ParseLambda([NotNull] Type itType, [CanBeNull] Ty
[PublicAPI]
public static LambdaExpression ParseLambda([CanBeNull] ParsingConfig parsingConfig, [NotNull] Type itType, [CanBeNull] Type resultType, string expression, params object[] values)
{
return ParseLambda(true, itType, resultType, expression, parsingConfig, values);
return ParseLambda(parsingConfig, true, itType, resultType, expression, values);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public class ComplexParseLambda3Result
public int TotalIncome { get; set; }
}

public class CustomClassWithStaticMethod
{
public static int GetAge(int x) => x;
}

private class TestCustomTypeProvider : AbstractDynamicLinqCustomTypeProvider, IDynamicLinkCustomTypeProvider
{
private HashSet<Type> _customTypes;
Expand All @@ -44,6 +49,7 @@ public virtual HashSet<Type> GetCustomTypes()
}

_customTypes = new HashSet<Type>(FindTypesMarkedWithDynamicLinqTypeAttribute(new[] { GetType().GetTypeInfo().Assembly }));
_customTypes.Add(typeof(CustomClassWithStaticMethod));
return _customTypes;
}
}
Expand Down Expand Up @@ -413,5 +419,26 @@ public void ParseLambda_IllegalMethodCall_ThrowsException()
})
.Throws<ParseException>().WithMessage("Methods on type 'Stream' are not accessible");
}

[Fact]
public void ParseLambda_CustomMethod()
{
// Assign
var config = new ParsingConfig
{
CustomTypeProvider = new TestCustomTypeProvider()
};

var context = new CustomClassWithStaticMethod();
string expression = $"{nameof(CustomClassWithStaticMethod)}.{nameof(CustomClassWithStaticMethod.GetAge)}(10)";

// Act
var lambdaExpression = DynamicExpressionParser.ParseLambda(config, typeof(CustomClassWithStaticMethod), null, expression);
Delegate del = lambdaExpression.Compile();
int result = (int)del.DynamicInvoke(context);

// Assert
Check.That(result).IsEqualTo(10);
}
}
}