Skip to content

Commit

Permalink
Add a netstandard2.0 build of Antlr3.StringTemplate
Browse files Browse the repository at this point in the history
  • Loading branch information
sharwell committed Feb 19, 2018
1 parent a0c4c15 commit 512859f
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 3 deletions.
11 changes: 10 additions & 1 deletion Antlr3.StringTemplate/Antlr3.StringTemplate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net35-client</TargetFrameworks>
<TargetFrameworks>net35-client;netstandard2.0</TargetFrameworks>
<RootNamespace>Antlr.ST</RootNamespace>

<Description>The C# port of StringTemplate 3.</Description>
Expand Down Expand Up @@ -33,6 +33,15 @@
</PropertyGroup>
</Target>

<Choose>
<When Condition="'$(TargetFramework)' == 'netstandard2.0'">
<ItemGroup>
<PackageReference Include="System.Reflection.Emit.ILGeneration" Version="4.3.0" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.3.0" />
</ItemGroup>
</When>
</Choose>

<PropertyGroup>
<DefineConstants>$(DefineConstants);COMPILE_EXPRESSIONS;CACHE_FUNCTORS</DefineConstants>
</PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions Antlr3.StringTemplate/Language/ASTExpr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,11 @@ private static System.Func<StringTemplate, IStringTemplateWriter, int> GetEvalua
{
Type[] parameterTypes = { typeof( ASTExpr ), typeof( StringTemplate ), typeof( IStringTemplateWriter ) };
method = new DynamicMethod( "ActionEvaluator" + _evaluatorNumber, typeof( int ), parameterTypes, typeof( ConditionalExpr ), true );
#if !NETSTANDARD2_0
method.DefineParameter( 1, ParameterAttributes.None, "chunk" );
method.DefineParameter( 2, ParameterAttributes.None, "self" );
method.DefineParameter( 3, ParameterAttributes.None, "writer" );
#endif
_evaluatorNumber++;

var gen = method.GetILGenerator();
Expand Down
2 changes: 2 additions & 0 deletions Antlr3.StringTemplate/Language/ConditionalExpr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@ static System.Func<StringTemplate, IStringTemplateWriter, bool> GetEvaluator( AS
{
Type[] parameterTypes = { typeof( ASTExpr ), typeof( StringTemplate ), typeof( IStringTemplateWriter ) };
method = new DynamicMethod( "ConditionEvaluator" + _evaluatorNumber, typeof( bool ), parameterTypes, typeof( ConditionalExpr ), true );
#if !NETSTANDARD2_0
method.DefineParameter( 1, ParameterAttributes.None, "chunk" );
method.DefineParameter( 2, ParameterAttributes.None, "self" );
method.DefineParameter( 3, ParameterAttributes.None, "writer" );
#endif
_evaluatorNumber++;

var gen = method.GetILGenerator();
Expand Down
6 changes: 5 additions & 1 deletion Antlr3.Test/Antlr3.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net45</TargetFrameworks>
<TargetFrameworks>net45;netcoreapp2.0</TargetFrameworks>
<RootNamespace>AntlrUnitTests</RootNamespace>
<AssemblyName>AntlrUnitTests</AssemblyName>

Expand All @@ -14,6 +14,10 @@
<InformationalVersion>$(ANTLRInformationalVersion)</InformationalVersion>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
<PackageReference Include="Microsoft.Win32.Registry" Version="4.3.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.1.18" />
Expand Down
5 changes: 5 additions & 0 deletions Antlr3.Test/BaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,12 @@ public void setUp()
string configuration = "Release";
#endif
System.IO.DirectoryInfo currentAssemblyDirectory = new System.IO.FileInfo(typeof(BaseTest).Assembly.Location).Directory;

#if NET45
AntlrTool.ToolPathRoot = Path.Combine(currentAssemblyDirectory.Parent.Parent.Parent.FullName, "bin", configuration, "net40-client");
#else
AntlrTool.ToolPathRoot = Path.Combine(currentAssemblyDirectory.Parent.Parent.Parent.FullName, "bin", configuration, "netstandard2.0");
#endif

// new output dir for each test
tmpdir = Path.GetFullPath( Path.Combine( Path.GetTempPath(), "antlr-" + currentTimeMillis() ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net35-client;net40-client</TargetFrameworks>
<TargetFrameworks>net35-client;net40-client;netstandard2.0</TargetFrameworks>

<Description>The C# port of ANTLR 3</Description>
<Company>Tunnel Vision Laboratories, LLC</Company>
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ build_script:
test_script:
- vstest.console /logger:Appveyor /TestCaseFilter:"TestCategory!=SkipOnCI" "C:\projects\antlrcs\Antlr3.Test\bin\%CONFIGURATION%\net45\AntlrUnitTests.dll"
- vstest.console /logger:Appveyor /TestCaseFilter:"TestCategory!=Visualizer" "C:\projects\antlrcs\Antlr4.Test.StringTemplate\bin\%CONFIGURATION%\net45\Antlr4.Test.StringTemplate.dll"
- dotnet vstest /Framework:".NETCoreApp,Version=v2.0" /TestCaseFilter:"TestCategory!=SkipOnCI" "C:\projects\antlrcs\Antlr3.Test\bin\%CONFIGURATION%\netcoreapp2.0\AntlrUnitTests.dll"
- dotnet vstest /Framework:".NETCoreApp,Version=v2.0" /TestCaseFilter:"TestCategory!=Visualizer" "C:\projects\antlrcs\Antlr4.Test.StringTemplate\bin\%CONFIGURATION%\netcoreapp2.0\Antlr4.Test.StringTemplate.dll"
artifacts:
- path: build\prep\nuget\*.nupkg
Expand Down

0 comments on commit 512859f

Please sign in to comment.