Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved support for .NET Standard 2 #124

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
22 changes: 2 additions & 20 deletions Antlr3.Runtime.Visualizer/Antlr3.Runtime.Visualizer.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="MSBuild.Sdk.Extras">

<PropertyGroup>
<TargetFrameworks>net35-client</TargetFrameworks>
Expand All @@ -12,19 +12,8 @@
<InformationalVersion>$(ANTLRInformationalVersion)</InformationalVersion>
</PropertyGroup>

<Choose>
<When Condition="'$(TargetFramework)' == 'net35-client'">
<PropertyGroup>
<TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
</PropertyGroup>
</When>
</Choose>

<PropertyGroup>
<!-- Workaround for lack of XAML support in the new project system -->
<LanguageTargets>$(MSBuildExtensionsPath)\$(VisualStudioVersion)\Bin\Microsoft.CSharp.targets</LanguageTargets>
<UseWPF>true</UseWPF>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -84,11 +73,4 @@
</None>
</ItemGroup>

<ItemGroup>
<Page Include="BaseTreeVisualizerViewControl.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="MSBuild.Sdk.Extras">

<PropertyGroup>
<TargetFrameworks>net35-client;net40-client</TargetFrameworks>
Expand Down Expand Up @@ -30,30 +30,8 @@
</PropertyGroup>
</Target>

<Choose>
<When Condition="'$(TargetFramework)' == 'net35-client'">
<PropertyGroup>
<TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
</PropertyGroup>
</When>
<When Condition="'$(TargetFramework)' == 'net40-client'">
<PropertyGroup>
<TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
</PropertyGroup>

<ItemGroup>
<Reference Include="System.Xaml" />
</ItemGroup>
</When>
</Choose>

<PropertyGroup>
<!-- Workaround for lack of XAML support in the new project system -->
<LanguageTargets Condition="Exists('$(MSBuildExtensionsPath)\$(VisualStudioVersion)\Bin\Microsoft.CSharp.targets')">$(MSBuildExtensionsPath)\$(VisualStudioVersion)\Bin\Microsoft.CSharp.targets</LanguageTargets>
<UseWPF>true</UseWPF>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -101,15 +79,4 @@
<None Include="Resources\Templates\AttributeRendererTemplates.stg" />
</ItemGroup>

<ItemGroup>
<Page Include="TemplateVisualizerFrame.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="TemplateVisualizerWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Antlr4.StringTemplate/Antlr4.StringTemplate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="MSBuild.Sdk.Extras">

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

<Description>The C# port of StringTemplate 4.</Description>
<Version>$(STVersion)</Version>
Expand Down
2 changes: 1 addition & 1 deletion Antlr4.StringTemplate/Debug/AddAttributeEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public override string ToString()
return "addEvent{" +
", name='" + name + '\'' +
", value=" + value +
#if !NETSTANDARD
#if !NETSTANDARD1_3
", location=" + GetFileName() + ":" + GetLine() +
#endif
'}';
Expand Down
8 changes: 4 additions & 4 deletions Antlr4.StringTemplate/Debug/ConstructionEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,25 @@

namespace Antlr4.StringTemplate.Debug
{
#if !NETSTANDARD
#if !NETSTANDARD1_3
using System.Diagnostics;
#endif

/** An event that happens when building Template trees, adding attributes etc... */
public class ConstructionEvent
{
#if !NETSTANDARD
#if !NETSTANDARD1_3
private readonly StackTrace stack;
#endif

public ConstructionEvent()
{
#if !NETSTANDARD
#if !NETSTANDARD1_3
stack = new StackTrace(true);
#endif
}

#if !NETSTANDARD
#if !NETSTANDARD1_3
public virtual string GetFileName()
{
return GetTemplateEntryPoint().GetFileName();
Expand Down
8 changes: 4 additions & 4 deletions Antlr4.StringTemplate/Extensions/ExceptionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
namespace Antlr4.StringTemplate.Extensions
{
using System;
#if !NETSTANDARD
#if !NETSTANDARD1_3
using BindingFlags = System.Reflection.BindingFlags;
using MethodInfo = System.Reflection.MethodInfo;
#endif

public static class ExceptionExtensions
{
#if !NETSTANDARD
#if !NETSTANDARD1_3
private static readonly Action<Exception> _internalPreserveStackTrace = GetInternalPreserveStackTraceDelegate();

private static Action<Exception> GetInternalPreserveStackTraceDelegate()
Expand All @@ -62,7 +62,7 @@ public static bool IsCritical(this Exception e)
return true;
}

#if NETSTANDARD
#if NETSTANDARD1_3
switch (e.GetType().FullName)
{
case "System.AccessViolationException":
Expand Down Expand Up @@ -90,7 +90,7 @@ public static bool IsCritical(this Exception e)

public static void PreserveStackTrace(this Exception e)
{
#if !NETSTANDARD
#if !NETSTANDARD1_3
if (_internalPreserveStackTrace != null)
_internalPreserveStackTrace(e);
#endif
Expand Down
2 changes: 1 addition & 1 deletion Antlr4.StringTemplate/Extensions/PropertyInfoExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETSTANDARD
#if NETSTANDARD1_3

namespace Antlr4.StringTemplate.Extensions
{
Expand Down
2 changes: 1 addition & 1 deletion Antlr4.StringTemplate/Extensions/TypeExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETSTANDARD
#if NETSTANDARD1_3

namespace Antlr4.StringTemplate.Extensions
{
Expand Down
4 changes: 2 additions & 2 deletions Antlr4.StringTemplate/StringRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace Antlr4.StringTemplate
using CultureInfo = System.Globalization.CultureInfo;
using Encoding = System.Text.Encoding;
using HttpUtility = Antlr4.StringTemplate.Misc.HttpUtility;
#if !NETSTANDARD
#if !NETSTANDARD1_3
using SecurityElement = System.Security.SecurityElement;
#endif

Expand Down Expand Up @@ -65,7 +65,7 @@ public virtual string ToString(object o, string formatString, CultureInfo cultur

if (formatString.Equals("xml-encode"))
{
#if NETSTANDARD
#if NETSTANDARD1_3
return s.Replace("&", "&amp;")
.Replace("<", "&lt;")
.Replace(">", "&gt;")
Expand Down
2 changes: 2 additions & 0 deletions Runtime/Antlr3.Runtime/ANTLRFileStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ namespace Antlr.Runtime
* </summary>
*/
[System.Serializable]
#if !NETSTANDARD
[System.Security.Permissions.FileIOPermission(System.Security.Permissions.SecurityAction.Demand, Unrestricted = true)]
#endif
public class ANTLRFileStream : ANTLRStringStream
{
protected string fileName;
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Antlr3.Runtime/Antlr3.Runtime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="MSBuild.Sdk.Extras">

<PropertyGroup>
<TargetFrameworks>net20;net40-client;portable-net40+sl5+win8+wp8+wpa81;netstandard1.1</TargetFrameworks>
<TargetFrameworks>net20;net40-client;portable-net40+sl5+win8+wp8+wpa81;netstandard1.1;netstandard2.0</TargetFrameworks>
<RootNamespace>Antlr.Runtime</RootNamespace>

<Description>The runtime library for parsers generated by the C# target of ANTLR 3. This package supports projects targeting .NET 2.0 or newer, and built using Visual Studio 2008 or newer.</Description>
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Antlr3.Runtime/System/OnSerializingAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETSTANDARD
#if NETSTANDARD1_1

namespace System.Runtime.Serialization
{
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Antlr3.Runtime/System/StreamingContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETSTANDARD
#if NETSTANDARD1_1

namespace System.Runtime.Serialization
{
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"msbuild-sdks": {
"MSBuild.Sdk.Extras": "1.6.55"
"MSBuild.Sdk.Extras": "2.0.54"
}
}