Skip to content

Commit

Permalink
Improved support for .NET Standard 2
Browse files Browse the repository at this point in the history
Closes antlr#123
  • Loading branch information
sharwell committed Oct 12, 2019
1 parent 051b181 commit c1de7cb
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 17 deletions.
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

0 comments on commit c1de7cb

Please sign in to comment.