diff --git a/Readme.md b/Readme.md index dbd550ab..dab64df6 100644 --- a/Readme.md +++ b/Readme.md @@ -49,8 +49,18 @@ This step is optional, but highly recommended for users working with a version o These versions of Visual Studio do not support the NuGet Package Manager extension, but the C# target for ANTLR 4 does support .NET 2.0 and higher so you should be able to use the [command line NuGet utility](http://docs.nuget.org/docs/start-here/installing-nuget) instead of working directly within Visual Studio. ### Step 4: Install ANTLR 4 support in a C# project - -#### For nearly all Visual Studio 2010 and newer installations +#### For Visual Studio 2017 +1. Create or open a C# project which will use ANTLR +2. Right click the top-level solution node in the Solution Explorer window and select **Manage NuGet Packages for Solution...** +3. In the upper left, choose **Browse** and then choose **nuget.org** as the **Package source** +4. Next to the **Search** box, check **Include prerelease** +5. In the **Search** box, type **Antlr4** to search for the package +6. In the search results, locate and select the package called **Antlr4**. Verify that the name is listed as exactly **Antlr4**. +7. In the right pane, select the C# projects you want to use ANTLR4 by clicking their checkboxes +8. Click **Install** under the list of projects +9. Approve changes and accept license agreements, if prompted. + +#### For nearly all Visual Studio 2010 - 2015 installations 1. Create or open a C# project which will use ANTLR 2. Right click the top-level solution node in the Solution Explorer window and select **Manage NuGet Packages for Solution...** diff --git a/appveyor.yml b/appveyor.yml index 7f1df53c..804e1b1f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,6 +10,7 @@ build_script: test_script: - vstest.console /logger:Appveyor /TestCaseFilter:"TestCategory=runtime-suite" "C:\projects\antlr4cs\runtime\CSharp\Antlr4.Runtime.Test\bin\%CONFIGURATION%\net45\Antlr4.Runtime.Test.dll" - vstest.console /logger:Appveyor /TestCaseFilter:"TestCategory=runtime-suite" "C:\projects\antlr4cs\runtime\CSharp\Antlr4.Runtime.Test\bin\%CONFIGURATION%\net452\Antlr4.Runtime.Test.dll" +- vstest.console /logger:Appveyor /TestCaseFilter:"TestCategory=runtime-suite" "C:\projects\antlr4cs\runtime\CSharp\Antlr4.Runtime.Test\bin\%CONFIGURATION%\net472\Antlr4.Runtime.Test.dll" - vstest.console /logger:Appveyor /TestCaseFilter:"TestCategory=runtime-suite" "C:\projects\antlr4cs\runtime\CSharp\Antlr4.Runtime.Test\bin\%CONFIGURATION%\portable40-net40+sl5+win8+wp8+wpa81\Antlr4.Runtime.Test.dll" - vstest.console /logger:Appveyor /TestCaseFilter:"TestCategory=runtime-suite" "C:\projects\antlr4cs\runtime\CSharp\Antlr4.Runtime.Test\bin\%CONFIGURATION%\net40\Antlr4.Runtime.Test.dll" - vstest.console /logger:Appveyor /TestCaseFilter:"TestCategory=runtime-suite" "C:\projects\antlr4cs\runtime\CSharp\Antlr4.Runtime.Test\bin\%CONFIGURATION%\net35\Antlr4.Runtime.Test.dll" diff --git a/build/Antlr4.CodeGenerator.nuspec b/build/Antlr4.CodeGenerator.nuspec index 486b4c35..ee99dc16 100644 --- a/build/Antlr4.CodeGenerator.nuspec +++ b/build/Antlr4.CodeGenerator.nuspec @@ -30,11 +30,17 @@ - - - - - + + + + + + + + + + + @@ -48,6 +54,7 @@ - + + diff --git a/build/Antlr4.Runtime.nuspec b/build/Antlr4.Runtime.nuspec index 802d0cfb..f92cfb58 100644 --- a/build/Antlr4.Runtime.nuspec +++ b/build/Antlr4.Runtime.nuspec @@ -27,6 +27,7 @@ + @@ -64,6 +65,10 @@ + + + + diff --git a/build/DotnetValidation/DotnetValidation.csproj b/build/DotnetValidation/DotnetValidation.csproj index 99293ddc..1bbba791 100644 --- a/build/DotnetValidation/DotnetValidation.csproj +++ b/build/DotnetValidation/DotnetValidation.csproj @@ -2,7 +2,7 @@ Exe - net20;net30;net35;net35-cf;net40;net45;netcoreapp1.1;portable40-net40+sl5+win8+wp8+wpa81 + net20;net30;net35;net35-cf;net40;net45;netcoreapp1.1;netcoreapp2.1;portable40-net40+sl5+win8+wp8+wpa81 False True diff --git a/build/DotnetValidationJavaCodegen/DotnetValidation.csproj b/build/DotnetValidationJavaCodegen/DotnetValidation.csproj index 9e774202..3a76ddb7 100644 --- a/build/DotnetValidationJavaCodegen/DotnetValidation.csproj +++ b/build/DotnetValidationJavaCodegen/DotnetValidation.csproj @@ -2,7 +2,7 @@ Exe - net20;net30;net35;net35-cf;net40;net45;netcoreapp1.1;portable40-net40+sl5+win8+wp8+wpa81 + net20;net30;net35;net35-cf;net40;net45;netcoreapp1.1;netcoreapp2.1;portable40-net40+sl5+win8+wp8+wpa81 False False diff --git a/build/build.ps1 b/build/build.ps1 index 54e771ae..d95d0590 100644 --- a/build/build.ps1 +++ b/build/build.ps1 @@ -110,7 +110,7 @@ If (-not (Test-Path $nuget)) { mkdir '..\runtime\CSharp\.nuget' } - $nugetSource = 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe' + $nugetSource = 'https://dist.nuget.org/win-x86-commandline/v5.7.0/nuget.exe' Invoke-WebRequest $nugetSource -OutFile $nuget If (-not $?) { $host.ui.WriteErrorLine('Unable to download NuGet executable, aborting!') @@ -131,6 +131,11 @@ If ($Logger) { } &$nuget 'restore' $SolutionPath -Project2ProjectTimeOut 1200 +if (-not $?) { + $host.ui.WriteErrorLine('Restore failed, aborting!') + Exit $LASTEXITCODE +} + &$msbuild '/nologo' '/m' '/nr:false' "/t:$Target" $LoggerArgument "/verbosity:$Verbosity" "/p:Configuration=$BuildConfig" "/p:VisualStudioVersion=$VisualStudioVersion" "/p:KeyConfiguration=$KeyConfiguration" $SolutionPath if (-not $?) { $host.ui.WriteErrorLine('Build failed, aborting!') @@ -187,6 +192,13 @@ If (-not $NoValidate) { Exit $LASTEXITCODE } + git 'clean' '-dxf' 'DotnetValidationJavaCodegen' + dotnet 'run' '--project' '.\DotnetValidationJavaCodegen\DotnetValidation.csproj' '--framework' 'netcoreapp2.1' + if (-not $?) { + $host.ui.WriteErrorLine('Build failed, aborting!') + Exit $LASTEXITCODE + } + git 'clean' '-dxf' 'DotnetValidationJavaCodegen' &$nuget 'restore' 'DotnetValidationJavaCodegen' &$msbuild '/nologo' '/m' '/nr:false' '/t:Rebuild' $LoggerArgument "/verbosity:$Verbosity" "/p:Configuration=$BuildConfig" '.\DotnetValidationJavaCodegen\DotnetValidation.sln' @@ -241,6 +253,13 @@ If (-not $NoValidate) { Exit $LASTEXITCODE } + git 'clean' '-dxf' 'DotnetValidation' + dotnet 'run' '--project' '.\DotnetValidation\DotnetValidation.csproj' '--framework' 'netcoreapp2.1' + if (-not $?) { + $host.ui.WriteErrorLine('Build failed, aborting!') + Exit $LASTEXITCODE + } + git 'clean' '-dxf' 'DotnetValidation' &$nuget 'restore' 'DotnetValidation' &$msbuild '/nologo' '/m' '/nr:false' '/t:Rebuild' $LoggerArgument "/verbosity:$Verbosity" "/p:Configuration=$BuildConfig" '.\DotnetValidation\DotnetValidation.sln' diff --git a/runtime/CSharp/Antlr4.Runtime.Test/Antlr4.Runtime.Test.csproj b/runtime/CSharp/Antlr4.Runtime.Test/Antlr4.Runtime.Test.csproj index 489b5922..c332fb94 100644 --- a/runtime/CSharp/Antlr4.Runtime.Test/Antlr4.Runtime.Test.csproj +++ b/runtime/CSharp/Antlr4.Runtime.Test/Antlr4.Runtime.Test.csproj @@ -3,7 +3,8 @@ - net20;net30;net35;portable40-net40+sl5+win8+wp8+wpa81;net40;net45;net452 + + net20;net30;net35;portable40-net40+sl5+win8+wp8+wpa81;net40;net45;net452;net472 False True @@ -109,6 +110,16 @@ + + + $(DefineConstants);NET45;NET45PLUS;NET40PLUS;NET35PLUS;NET30PLUS;NET20PLUS + + + + TargetFramework=netstandard2.0 + + + diff --git a/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.csproj b/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.csproj index 78696780..7264be8c 100644 --- a/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.csproj +++ b/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.csproj @@ -2,7 +2,7 @@ - netstandard1.1;net20;net30;net35-cf;net35-client;portable40-net40+sl5+win8+wp8+wpa81;net40-client;net45 + netstandard1.1;netstandard2.0;net20;net30;net35-cf;net35-client;portable40-net40+sl5+win8+wp8+wpa81;net40-client;net45 False 4.6.0.0 diff --git a/runtime/CSharp/Antlr4.Runtime/AntlrFileStream.cs b/runtime/CSharp/Antlr4.Runtime/AntlrFileStream.cs index bb35006e..9f036b37 100644 --- a/runtime/CSharp/Antlr4.Runtime/AntlrFileStream.cs +++ b/runtime/CSharp/Antlr4.Runtime/AntlrFileStream.cs @@ -1,7 +1,7 @@ // Copyright (c) Terence Parr, Sam Harwell. All Rights Reserved. // Licensed under the BSD License. See LICENSE.txt in the project root for license information. -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 using Antlr4.Runtime.Misc; using Antlr4.Runtime.Sharpen; diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/ATNState.cs b/runtime/CSharp/Antlr4.Runtime/Atn/ATNState.cs index b2cceede..a9fa5748 100644 --- a/runtime/CSharp/Antlr4.Runtime/Atn/ATNState.cs +++ b/runtime/CSharp/Antlr4.Runtime/Atn/ATNState.cs @@ -179,7 +179,7 @@ public virtual void AddTransition(int index, Antlr4.Runtime.Atn.Transition e) { if (epsilonOnlyTransitions != e.IsEpsilon) { -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 System.Console.Error.WriteLine("ATN state {0} has both epsilon and non-epsilon transitions.", stateNumber); #endif epsilonOnlyTransitions = false; diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/LexerATNSimulator.cs b/runtime/CSharp/Antlr4.Runtime/Atn/LexerATNSimulator.cs index b1ab74ac..2a0c1ceb 100644 --- a/runtime/CSharp/Antlr4.Runtime/Atn/LexerATNSimulator.cs +++ b/runtime/CSharp/Antlr4.Runtime/Atn/LexerATNSimulator.cs @@ -12,7 +12,7 @@ namespace Antlr4.Runtime.Atn /// "dup" of ParserInterpreter public class LexerATNSimulator : ATNSimulator { -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 public const bool debug = false; public const bool dfa_debug = false; @@ -247,7 +247,7 @@ protected internal virtual int ExecATN([NotNull] ICharStream input, [NotNull] DF protected internal virtual DFAState GetExistingTargetState([NotNull] DFAState s, int t) { DFAState target = s.GetTarget(t); -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 if (debug && target != null) { System.Console.Out.WriteLine("reuse state " + s.stateNumber + " edge to " + target.stateNumber); diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/ParserATNSimulator.cs b/runtime/CSharp/Antlr4.Runtime/Atn/ParserATNSimulator.cs index aa382d3e..fbb315d8 100644 --- a/runtime/CSharp/Antlr4.Runtime/Atn/ParserATNSimulator.cs +++ b/runtime/CSharp/Antlr4.Runtime/Atn/ParserATNSimulator.cs @@ -279,7 +279,7 @@ namespace Antlr4.Runtime.Atn public class ParserATNSimulator : ATNSimulator { #pragma warning disable 0162 // Unreachable code detected -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 public const bool debug = false; public const bool dfa_debug = false; @@ -566,7 +566,7 @@ protected internal virtual int ExecDFA([NotNull] DFA dfa, [NotNull] ITokenStream DFAState target = GetExistingTargetState(s, t); if (target == null) { -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 if (dfa_debug && t >= 0) { System.Console.Out.WriteLine("no edge for " + parser.Vocabulary.GetDisplayName(t)); @@ -1793,7 +1793,7 @@ protected internal virtual BitSet EvalSemanticContext([NotNull] DFAState.PredPre continue; } bool evaluatedResult = EvalSemanticContext(pair.pred, outerContext, pair.alt); -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 if (debug || dfa_debug) { System.Console.Out.WriteLine("eval pred " + pair + "=" + evaluatedResult); @@ -1801,7 +1801,7 @@ protected internal virtual BitSet EvalSemanticContext([NotNull] DFAState.PredPre #endif if (evaluatedResult) { -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 if (debug || dfa_debug) { System.Console.Out.WriteLine("PREDICT " + pair.alt); @@ -2385,7 +2385,7 @@ public virtual string GetLookaheadName(ITokenStream input) return GetTokenName(input.La(1)); } -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 public virtual void DumpDeadEndConfigs([NotNull] NoViableAltException nvae) { System.Console.Error.WriteLine("dead end configs: "); @@ -2570,7 +2570,7 @@ protected internal virtual DFAState AddDFAState([NotNull] DFA dfa, [NotNull] ATN return newState; } DFAState added = dfa.AddState(newState); -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 if (debug && added == newState) { System.Console.Out.WriteLine("adding new DFA state: " + newState); @@ -2587,7 +2587,7 @@ protected internal virtual DFAState CreateDFAState([NotNull] DFA dfa, [NotNull] protected internal virtual void ReportAttemptingFullContext([NotNull] DFA dfa, [Nullable] BitSet conflictingAlts, [NotNull] SimulatorState conflictState, int startIndex, int stopIndex) { -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 if (debug || retry_debug) { Interval interval = Interval.Of(startIndex, stopIndex); @@ -2602,7 +2602,7 @@ protected internal virtual void ReportAttemptingFullContext([NotNull] DFA dfa, [ protected internal virtual void ReportContextSensitivity([NotNull] DFA dfa, int prediction, [NotNull] SimulatorState acceptState, int startIndex, int stopIndex) { -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 if (debug || retry_debug) { Interval interval = Interval.Of(startIndex, stopIndex); @@ -2620,7 +2620,7 @@ protected internal virtual void ReportAmbiguity([NotNull] DFA dfa, DFAState D, i { // the DFA state from execATN() that had SLL conflicts // configs that LL not SLL considered conflicting -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 if (debug || retry_debug) { Interval interval = Interval.Of(startIndex, stopIndex); diff --git a/runtime/CSharp/Antlr4.Runtime/ConsoleErrorListener.cs b/runtime/CSharp/Antlr4.Runtime/ConsoleErrorListener.cs index 5d36ffdf..6016780c 100644 --- a/runtime/CSharp/Antlr4.Runtime/ConsoleErrorListener.cs +++ b/runtime/CSharp/Antlr4.Runtime/ConsoleErrorListener.cs @@ -1,7 +1,7 @@ // Copyright (c) Terence Parr, Sam Harwell. All Rights Reserved. // Licensed under the BSD License. See LICENSE.txt in the project root for license information. -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 using Antlr4.Runtime.Sharpen; diff --git a/runtime/CSharp/Antlr4.Runtime/DefaultErrorStrategy.cs b/runtime/CSharp/Antlr4.Runtime/DefaultErrorStrategy.cs index e4255127..9c3a4e20 100644 --- a/runtime/CSharp/Antlr4.Runtime/DefaultErrorStrategy.cs +++ b/runtime/CSharp/Antlr4.Runtime/DefaultErrorStrategy.cs @@ -150,7 +150,7 @@ public virtual void ReportError(Parser recognizer, RecognitionException e) } else { -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 System.Console.Error.WriteLine("unknown recognition error type: " + e.GetType().FullName); #endif NotifyErrorListeners(recognizer, e.Message, e); diff --git a/runtime/CSharp/Antlr4.Runtime/Misc/RuleDependencyChecker.cs b/runtime/CSharp/Antlr4.Runtime/Misc/RuleDependencyChecker.cs index 5426587a..5a6b5627 100644 --- a/runtime/CSharp/Antlr4.Runtime/Misc/RuleDependencyChecker.cs +++ b/runtime/CSharp/Antlr4.Runtime/Misc/RuleDependencyChecker.cs @@ -457,7 +457,7 @@ private RuleDependencyChecker() { } -#if PORTABLE +#if PORTABLE && !NETSTANDARD2_0 public interface ICustomAttributeProvider { object[] GetCustomAttributes(Type attributeType, bool inherit); @@ -1012,7 +1012,7 @@ private RuleDependencyChecker() { } -#if PORTABLE +#if PORTABLE && !NETSTANDARD2_0 public interface ICustomAttributeProvider { object[] GetCustomAttributes(Type attributeType, bool inherit); diff --git a/runtime/CSharp/Antlr4.Runtime/Parser.cs b/runtime/CSharp/Antlr4.Runtime/Parser.cs index 42942a1f..f75f1aa7 100644 --- a/runtime/CSharp/Antlr4.Runtime/Parser.cs +++ b/runtime/CSharp/Antlr4.Runtime/Parser.cs @@ -16,7 +16,7 @@ namespace Antlr4.Runtime /// This is all the parsing support code essentially; most of it is error recovery stuff. public abstract class Parser : Recognizer { -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 public class TraceListener : IParseTreeListener { public virtual void EnterEveryRule(ParserRuleContext ctx) @@ -122,7 +122,7 @@ public virtual void ExitEveryRule(ParserRuleContext ctx) /// protected internal bool _buildParseTrees = true; -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 /// /// When /// @@ -183,7 +183,7 @@ public virtual void Reset() _ctx = null; _syntaxErrors = 0; matchedEOF = false; -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 Trace = false; #endif _precedenceStack.Clear(); @@ -1131,7 +1131,7 @@ public virtual IList GetDFAStrings() return s; } -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 /// For debugging and other purposes. public virtual void DumpDFA() { @@ -1199,7 +1199,7 @@ public virtual bool Profile } } -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 /// /// During a parse is sometimes useful to listen in on the rule entry and exit /// events as well as token matches. diff --git a/runtime/CSharp/Antlr4.Runtime/Properties/AssemblyInfo.cs b/runtime/CSharp/Antlr4.Runtime/Properties/AssemblyInfo.cs index 4d82c6cd..b48c51ee 100644 --- a/runtime/CSharp/Antlr4.Runtime/Properties/AssemblyInfo.cs +++ b/runtime/CSharp/Antlr4.Runtime/Properties/AssemblyInfo.cs @@ -18,7 +18,7 @@ // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("bc228eb9-e79c-4e5a-a1b9-0434ea566bab")] #endif diff --git a/runtime/CSharp/Antlr4.Runtime/Recognizer`2.cs b/runtime/CSharp/Antlr4.Runtime/Recognizer`2.cs index 29d55fdd..c4428763 100644 --- a/runtime/CSharp/Antlr4.Runtime/Recognizer`2.cs +++ b/runtime/CSharp/Antlr4.Runtime/Recognizer`2.cs @@ -7,7 +7,7 @@ using Antlr4.Runtime.Misc; using Antlr4.Runtime.Sharpen; -#if NET40PLUS && !NETSTANDARD +#if NET40PLUS && !NETSTANDARD1_1 using System.Runtime.CompilerServices; #endif @@ -18,7 +18,7 @@ public abstract class Recognizer : IRecognizer { public const int Eof = -1; -#if NET40PLUS && !NETSTANDARD +#if NET40PLUS && !NETSTANDARD1_1 private static readonly ConditionalWeakTable> tokenTypeMapCache = new ConditionalWeakTable>(); private static readonly ConditionalWeakTable> ruleIndexMapCache = new ConditionalWeakTable>(); #endif @@ -26,7 +26,7 @@ public abstract class Recognizer : IRecognizer [NotNull] private IAntlrErrorListener[] _listeners = { -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 ConsoleErrorListener.Instance #endif }; @@ -82,7 +82,7 @@ public virtual IDictionary TokenTypeMap { get { -#if NET40PLUS && !NETSTANDARD +#if NET40PLUS && !NETSTANDARD1_1 return tokenTypeMapCache.GetValue(Vocabulary, CreateTokenTypeMap); #else return CreateTokenTypeMap(Vocabulary); @@ -125,7 +125,7 @@ public virtual IDictionary RuleIndexMap { throw new NotSupportedException("The current recognizer does not provide a list of rule names."); } -#if NET40PLUS && !NETSTANDARD +#if NET40PLUS && !NETSTANDARD1_1 return ruleIndexMapCache.GetValue(ruleNames, Utils.ToMap); #else return Utils.ToMap(ruleNames); diff --git a/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/CollectionDebuggerView`2.cs b/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/CollectionDebuggerView`2.cs index b1c0c866..cb7f7cae 100644 --- a/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/CollectionDebuggerView`2.cs +++ b/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/CollectionDebuggerView`2.cs @@ -26,7 +26,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if !NET40PLUS || (PORTABLE && !WINRT) +#if !NET40PLUS || (PORTABLE && !WINRT && !NETSTANDARD2_0) using System; using System.Collections.Generic; diff --git a/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/NonSerializedAttribute.cs b/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/NonSerializedAttribute.cs index 09d3262e..fb26de11 100644 --- a/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/NonSerializedAttribute.cs +++ b/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/NonSerializedAttribute.cs @@ -1,4 +1,4 @@ -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 #if !COMPACT using System; diff --git a/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/SerializableAttribute.cs b/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/SerializableAttribute.cs index 147e1c6b..9b3c4970 100644 --- a/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/SerializableAttribute.cs +++ b/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/SerializableAttribute.cs @@ -1,4 +1,4 @@ -#if PORTABLE || NETSTANDARD +#if PORTABLE && !NETSTANDARD2_0 namespace System { diff --git a/runtime/CSharp/Antlr4.Runtime/TokenStreamRewriter.cs b/runtime/CSharp/Antlr4.Runtime/TokenStreamRewriter.cs index b8a0120f..bd30e43f 100644 --- a/runtime/CSharp/Antlr4.Runtime/TokenStreamRewriter.cs +++ b/runtime/CSharp/Antlr4.Runtime/TokenStreamRewriter.cs @@ -643,7 +643,7 @@ public virtual string GetText(string programName, Interval interval) // kill first delete rop.index = Math.Min(prevRop.index, rop.index); rop.lastIndex = Math.Max(prevRop.lastIndex, rop.lastIndex); -#if !PORTABLE +#if !PORTABLE || NETSTANDARD2_0 System.Console.Out.WriteLine("new rop " + rop); #endif } diff --git a/runtime/CSharp/Antlr4.Tool/Antlr4.Tool.csproj b/runtime/CSharp/Antlr4.Tool/Antlr4.Tool.csproj index 9149f8cc..c50d5332 100644 --- a/runtime/CSharp/Antlr4.Tool/Antlr4.Tool.csproj +++ b/runtime/CSharp/Antlr4.Tool/Antlr4.Tool.csproj @@ -3,7 +3,7 @@ Exe - netstandard1.5;net45 + netstandard2.0;netstandard1.5;net45 False Antlr4 Antlr4 diff --git a/runtime/CSharp/Antlr4BuildTasks/Antlr4.CodeGenerator.props b/runtime/CSharp/Antlr4BuildTasks/Antlr4.CodeGenerator.props index ce257a92..65c4d48f 100644 --- a/runtime/CSharp/Antlr4BuildTasks/Antlr4.CodeGenerator.props +++ b/runtime/CSharp/Antlr4BuildTasks/Antlr4.CodeGenerator.props @@ -7,7 +7,8 @@ ..\tools\net40 - ..\tools\netstandard + ..\tools\netstandard2.0 + ..\tools\netstandard1.5 ..\tools\antlr4-csharp-4.6.7-SNAPSHOT-complete.jar diff --git a/runtime/CSharp/Antlr4BuildTasks/Antlr4.CodeGenerator.targets b/runtime/CSharp/Antlr4BuildTasks/Antlr4.CodeGenerator.targets index c5b1a9ed..5201f3f3 100644 --- a/runtime/CSharp/Antlr4BuildTasks/Antlr4.CodeGenerator.targets +++ b/runtime/CSharp/Antlr4BuildTasks/Antlr4.CodeGenerator.targets @@ -196,4 +196,16 @@ + + + + + + + + + + + + diff --git a/runtime/CSharp/Antlr4BuildTasks/Antlr4BuildTasks.csproj b/runtime/CSharp/Antlr4BuildTasks/Antlr4BuildTasks.csproj index bbb06e42..7b874757 100644 --- a/runtime/CSharp/Antlr4BuildTasks/Antlr4BuildTasks.csproj +++ b/runtime/CSharp/Antlr4BuildTasks/Antlr4BuildTasks.csproj @@ -2,7 +2,7 @@ - netstandard1.5;net40 + netstandard2.0;netstandard1.5;net40 False Antlr4.Build.Tasks @@ -29,6 +29,15 @@ + + + + + + + + + @@ -37,9 +46,6 @@ - - $(DefineConstants);NETSTANDARD - diff --git a/runtime/CSharp/Antlr4BuildTasks/Antlr4ClassGenerationTaskInternal.cs b/runtime/CSharp/Antlr4BuildTasks/Antlr4ClassGenerationTaskInternal.cs index 852d4e8c..2b9c37c5 100644 --- a/runtime/CSharp/Antlr4BuildTasks/Antlr4ClassGenerationTaskInternal.cs +++ b/runtime/CSharp/Antlr4BuildTasks/Antlr4ClassGenerationTaskInternal.cs @@ -224,8 +224,11 @@ public bool Execute() if (UseCSharpGenerator) { -#if NETSTANDARD - string framework = "netstandard"; +#if NETSTANDARD1_5 + string framework = "netstandard1.5"; + string extension = ".dll"; +#elif NETSTANDARD2_0 + string framework = "netstandard2.0"; string extension = ".dll"; #else string framework = "net45"; diff --git a/runtime/CSharp/Antlr4BuildTasks/BuildMessage.cs b/runtime/CSharp/Antlr4BuildTasks/BuildMessage.cs index aff7c547..8dfc4a2a 100644 --- a/runtime/CSharp/Antlr4BuildTasks/BuildMessage.cs +++ b/runtime/CSharp/Antlr4BuildTasks/BuildMessage.cs @@ -7,7 +7,7 @@ namespace Antlr4.Build.Tasks using System.Diagnostics; using System.Text.RegularExpressions; -#if !NETSTANDARD +#if !NETSTANDARD1_5 [Serializable] #endif internal struct BuildMessage diff --git a/runtime/CSharp/Antlr4BuildTasks/TraceLevel.cs b/runtime/CSharp/Antlr4BuildTasks/TraceLevel.cs index 5d18c6e5..d7fbf7c0 100644 --- a/runtime/CSharp/Antlr4BuildTasks/TraceLevel.cs +++ b/runtime/CSharp/Antlr4BuildTasks/TraceLevel.cs @@ -1,7 +1,7 @@ // Copyright (c) Terence Parr, Sam Harwell. All Rights Reserved. // Licensed under the BSD License. See LICENSE.txt in the project root for license information. -#if NETSTANDARD +#if NETSTANDARD1_5 namespace Antlr4.Build.Tasks {