From e52b241c392fb17eb0701dccfb3169bae8726402 Mon Sep 17 00:00:00 2001
From: Sam Harwell <sam@tunnelvisionlabs.com>
Date: Sun, 16 Jul 2017 08:24:24 -0500
Subject: [PATCH 1/3] Updated .gitignore in sharpen branch

---
 .gitignore | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index 1445c123..98b901c9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,17 +1,38 @@
 # ignore Visual Studio user files
 *.suo
 *.csproj.user
+*.xproj.user
 *.sln.cache
 
+# User files related to NuGet project.json
+*.lock.json
+*.nuget.props
+*.nuget.targets
+[nN]u[gG]et.exe
+
+# Ignored testing and profiling files
+TestResults/
+*.vsp
+*.testsettings
+
+# Roslyn Cache
+.vs/
+
 # ignore C# build directories
-[Dd]ebug/
-[Rr]elease/
+bin/
+obj/
 reference/.metadata/
 reference/reference.net/
 /runtime/CSharp/packages/
+/build/DotnetValidation*/packages/
 
 # ignore Java (Maven) build directory
 tool/target/
+.idea/
+*.iml
 
 # ignore NuGet output folders
 /build/nuget/
+
+# Ignore generated test suite
+Generated/

From d5e942ddee9037e61af989dc0ecd6a6f6534865c Mon Sep 17 00:00:00 2001
From: Sam Harwell <sam@tunnelvisionlabs.com>
Date: Tue, 8 Aug 2017 23:17:52 -0500
Subject: [PATCH 2/3] Update to the mono/develop branch of sharpen

---
 reference/sharpen                             |   2 +-
 .../CSharp/Antlr4.Runtime/ANTLRFileStream.cs  |  14 +-
 .../CSharp/Antlr4.Runtime/ANTLRInputStream.cs |   8 +-
 runtime/CSharp/Antlr4.Runtime/Atn/ATN.cs      |  24 +-
 .../CSharp/Antlr4.Runtime/Atn/ATNConfig.cs    |  40 +--
 .../CSharp/Antlr4.Runtime/Atn/ATNConfigSet.cs |  10 +-
 .../Atn/ATNDeserializationOptions.cs          |   8 +-
 .../Antlr4.Runtime/Atn/ATNDeserializer.cs     |  36 +--
 .../Antlr4.Runtime/Atn/ATNSerializer.cs       |   8 +-
 .../CSharp/Antlr4.Runtime/Atn/ATNSimulator.cs |  36 +--
 runtime/CSharp/Antlr4.Runtime/Atn/ATNState.cs |   8 +-
 runtime/CSharp/Antlr4.Runtime/Atn/ATNType.cs  |   8 +-
 .../Atn/AbstractPredicateTransition.cs        |   8 +-
 .../Antlr4.Runtime/Atn/ActionTransition.cs    |  13 +-
 .../Antlr4.Runtime/Atn/AmbiguityInfo.cs       |  10 +-
 .../Atn/ArrayPredictionContext.cs             |  16 +-
 .../Antlr4.Runtime/Atn/AtomTransition.cs      |  10 +-
 .../Atn/BasicBlockStartState.cs               |   8 +-
 .../CSharp/Antlr4.Runtime/Atn/BasicState.cs   |   8 +-
 .../Antlr4.Runtime/Atn/BlockEndState.cs       |   8 +-
 .../Antlr4.Runtime/Atn/BlockStartState.cs     |   8 +-
 .../CSharp/Antlr4.Runtime/Atn/ConflictInfo.cs |   8 +-
 .../Atn/ContextSensitivityInfo.cs             |  11 +-
 .../Antlr4.Runtime/Atn/DecisionEventInfo.cs   |  10 +-
 .../CSharp/Antlr4.Runtime/Atn/DecisionInfo.cs |   8 +-
 .../Antlr4.Runtime/Atn/DecisionState.cs       |   8 +-
 .../Atn/EmptyPredictionContext.cs             |   8 +-
 .../Antlr4.Runtime/Atn/EpsilonTransition.cs   |  12 +-
 .../CSharp/Antlr4.Runtime/Atn/ErrorInfo.cs    |  11 +-
 .../CSharp/Antlr4.Runtime/Atn/ILexerAction.cs |  11 +-
 .../CSharp/Antlr4.Runtime/Atn/LL1Analyzer.cs  |  18 +-
 .../Antlr4.Runtime/Atn/LexerATNSimulator.cs   | 112 ++++----
 .../Antlr4.Runtime/Atn/LexerActionExecutor.cs |  14 +-
 .../Antlr4.Runtime/Atn/LexerActionType.cs     |   8 +-
 .../Antlr4.Runtime/Atn/LexerChannelAction.cs  |  10 +-
 .../Antlr4.Runtime/Atn/LexerCustomAction.cs   |  10 +-
 .../Atn/LexerIndexedCustomAction.cs           |  10 +-
 .../Antlr4.Runtime/Atn/LexerModeAction.cs     |  10 +-
 .../Antlr4.Runtime/Atn/LexerMoreAction.cs     |  10 +-
 .../Antlr4.Runtime/Atn/LexerPopModeAction.cs  |  10 +-
 .../Antlr4.Runtime/Atn/LexerPushModeAction.cs |  10 +-
 .../Antlr4.Runtime/Atn/LexerSkipAction.cs     |  10 +-
 .../Antlr4.Runtime/Atn/LexerTypeAction.cs     |  10 +-
 .../Antlr4.Runtime/Atn/LookaheadEventInfo.cs  |  11 +-
 .../CSharp/Antlr4.Runtime/Atn/LoopEndState.cs |   8 +-
 .../Antlr4.Runtime/Atn/NotSetTransition.cs    |  10 +-
 .../Antlr4.Runtime/Atn/OrderedATNConfigSet.cs |   8 +-
 .../CSharp/Antlr4.Runtime/Atn/ParseInfo.cs    |  10 +-
 .../Antlr4.Runtime/Atn/ParserATNSimulator.cs  | 258 +++++++++---------
 .../Antlr4.Runtime/Atn/PlusBlockStartState.cs |   8 +-
 .../Antlr4.Runtime/Atn/PlusLoopbackState.cs   |   8 +-
 .../Atn/PrecedencePredicateTransition.cs      |  11 +-
 .../Antlr4.Runtime/Atn/PredicateEvalInfo.cs   |  11 +-
 .../Antlr4.Runtime/Atn/PredicateTransition.cs |  10 +-
 .../Antlr4.Runtime/Atn/PredictionContext.cs   |  18 +-
 .../Atn/PredictionContextCache.cs             |   8 +-
 .../Antlr4.Runtime/Atn/PredictionMode.cs      |  46 ++--
 .../Atn/ProfilingATNSimulator.cs              |  11 +-
 .../Antlr4.Runtime/Atn/RangeTransition.cs     |  10 +-
 .../Antlr4.Runtime/Atn/RuleStartState.cs      |   8 +-
 .../Antlr4.Runtime/Atn/RuleStopState.cs       |   8 +-
 .../Antlr4.Runtime/Atn/RuleTransition.cs      |  12 +-
 .../Antlr4.Runtime/Atn/SemanticContext.cs     |  14 +-
 .../Antlr4.Runtime/Atn/SetTransition.cs       |  10 +-
 .../Antlr4.Runtime/Atn/SimulatorState.cs      |   9 +-
 .../Atn/SingletonPredictionContext.cs         |  12 +-
 .../Antlr4.Runtime/Atn/StarBlockStartState.cs |   8 +-
 .../Antlr4.Runtime/Atn/StarLoopEntryState.cs  |   8 +-
 .../Antlr4.Runtime/Atn/StarLoopbackState.cs   |   8 +-
 .../CSharp/Antlr4.Runtime/Atn/StateType.cs    |  56 ++--
 .../Antlr4.Runtime/Atn/TokensStartState.cs    |   8 +-
 .../CSharp/Antlr4.Runtime/Atn/Transition.cs   |  10 +-
 .../Antlr4.Runtime/Atn/TransitionType.cs      |  56 ++--
 .../Antlr4.Runtime/Atn/WildcardTransition.cs  |  10 +-
 .../Antlr4.Runtime/BailErrorStrategy.cs       |   8 +-
 .../Antlr4.Runtime/BaseErrorListener.cs       |  17 +-
 .../Antlr4.Runtime/BufferedTokenStream.cs     |  10 +-
 runtime/CSharp/Antlr4.Runtime/CommonToken.cs  |  12 +-
 .../Antlr4.Runtime/CommonTokenFactory.cs      |   8 +-
 .../Antlr4.Runtime/CommonTokenStream.cs       |  13 +-
 .../Antlr4.Runtime/ConsoleErrorListener.cs    |   8 +-
 .../Antlr4.Runtime/DefaultErrorStrategy.cs    | 238 ++++++++--------
 runtime/CSharp/Antlr4.Runtime/Dependents.cs   |   8 +-
 .../Antlr4.Runtime/Dfa/AbstractEdgeMap`1.cs   |  10 +-
 .../Antlr4.Runtime/Dfa/AcceptStateInfo.cs     |   6 +-
 .../Antlr4.Runtime/Dfa/ArrayEdgeMap`1.cs      |  16 +-
 runtime/CSharp/Antlr4.Runtime/Dfa/DFA.cs      |  20 +-
 .../Antlr4.Runtime/Dfa/DFASerializer.cs       |  18 +-
 runtime/CSharp/Antlr4.Runtime/Dfa/DFAState.cs |  14 +-
 .../Antlr4.Runtime/Dfa/EmptyEdgeMap`1.cs      |   8 +-
 .../CSharp/Antlr4.Runtime/Dfa/IEdgeMap`1.cs   |   8 +-
 .../Antlr4.Runtime/Dfa/LexerDFASerializer.cs  |  10 +-
 .../Antlr4.Runtime/Dfa/SingletonEdgeMap`1.cs  |   8 +-
 .../Antlr4.Runtime/Dfa/SparseEdgeMap`1.cs     |  11 +-
 .../Antlr4.Runtime/DiagnosticErrorListener.cs |  18 +-
 .../FailedPredicateException.cs               |  16 +-
 .../Antlr4.Runtime/IAntlrErrorListener`1.cs   |  11 +-
 .../Antlr4.Runtime/IAntlrErrorStrategy.cs     |  22 +-
 runtime/CSharp/Antlr4.Runtime/ICharStream.cs  |  10 +-
 runtime/CSharp/Antlr4.Runtime/IIntStream.cs   |   8 +-
 .../Antlr4.Runtime/IParserErrorListener.cs    |  15 +-
 runtime/CSharp/Antlr4.Runtime/IToken.cs       |   8 +-
 .../CSharp/Antlr4.Runtime/ITokenFactory.cs    |   8 +-
 runtime/CSharp/Antlr4.Runtime/ITokenSource.cs |   8 +-
 runtime/CSharp/Antlr4.Runtime/ITokenStream.cs |  12 +-
 runtime/CSharp/Antlr4.Runtime/IVocabulary.cs  |   8 +-
 .../CSharp/Antlr4.Runtime/IWritableToken.cs   |   8 +-
 .../Antlr4.Runtime/InputMismatchException.cs  |  11 +-
 .../Antlr4.Runtime/InterpreterRuleContext.cs  |  11 +-
 runtime/CSharp/Antlr4.Runtime/Lexer.cs        |   8 +-
 .../CSharp/Antlr4.Runtime/LexerInterpreter.cs |  10 +-
 .../LexerNoViableAltException.cs              |  10 +-
 .../CSharp/Antlr4.Runtime/ListTokenSource.cs  |  13 +-
 runtime/CSharp/Antlr4.Runtime/Misc/Args.cs    |   8 +-
 .../Antlr4.Runtime/Misc/Array2DHashSet`1.cs   |  16 +-
 .../Antlr4.Runtime/Misc/DoubleKeyMap`3.cs     |   8 +-
 runtime/CSharp/Antlr4.Runtime/Misc/IIntSet.cs |  18 +-
 .../CSharp/Antlr4.Runtime/Misc/Interval.cs    |   8 +-
 .../CSharp/Antlr4.Runtime/Misc/IntervalSet.cs |  34 +--
 .../CSharp/Antlr4.Runtime/Misc/MultiMap`2.cs  |   8 +-
 .../CSharp/Antlr4.Runtime/Misc/MurmurHash.cs  |   8 +-
 .../Antlr4.Runtime/Misc/OrderedHashSet`1.cs   |   8 +-
 .../Misc/ParseCanceledException.cs            |   8 +-
 .../Misc/RuleDependencyChecker.cs             |   8 +-
 .../Misc/RuleDependencyProcessor.cs           |  12 +-
 runtime/CSharp/Antlr4.Runtime/Misc/TestRig.cs |   8 +-
 runtime/CSharp/Antlr4.Runtime/Misc/Utils.cs   |  12 +-
 .../Antlr4.Runtime/NoViableAltException.cs    |  12 +-
 runtime/CSharp/Antlr4.Runtime/Parser.cs       |  18 +-
 .../Antlr4.Runtime/ParserInterpreter.cs       |  12 +-
 .../Antlr4.Runtime/ParserRuleContext.cs       |  10 +-
 .../Antlr4.Runtime/ProxyErrorListener`1.cs    |  13 +-
 .../ProxyParserErrorListener.cs               |   8 +-
 .../Antlr4.Runtime/RecognitionException.cs    |  14 +-
 runtime/CSharp/Antlr4.Runtime/Recognizer`2.cs |  16 +-
 runtime/CSharp/Antlr4.Runtime/RuleContext.cs  |  18 +-
 .../Antlr4.Runtime/RuleContextWithAltNum.cs   |   8 +-
 .../Antlr4.Runtime/TokenStreamRewriter.cs     |  12 +-
 .../Tree/AbstractParseTreeVisitor`1.cs        |  19 +-
 .../Antlr4.Runtime/Tree/ErrorNodeImpl.cs      |   8 +-
 .../CSharp/Antlr4.Runtime/Tree/IErrorNode.cs  |   8 +-
 .../CSharp/Antlr4.Runtime/Tree/IParseTree.cs  |   8 +-
 .../Antlr4.Runtime/Tree/IParseTreeListener.cs |  17 +-
 .../Tree/IParseTreeVisitor`1.cs               |  17 +-
 .../CSharp/Antlr4.Runtime/Tree/IRuleNode.cs   |   8 +-
 .../CSharp/Antlr4.Runtime/Tree/ISyntaxTree.cs |   8 +-
 .../Antlr4.Runtime/Tree/ITerminalNode.cs      |   8 +-
 runtime/CSharp/Antlr4.Runtime/Tree/ITree.cs   |   8 +-
 .../Tree/ParseTreeProperty`1.cs               |   8 +-
 .../Antlr4.Runtime/Tree/ParseTreeWalker.cs    |   8 +-
 .../Antlr4.Runtime/Tree/Pattern/Chunk.cs      |   8 +-
 .../Tree/Pattern/ParseTreeMatch.cs            |  12 +-
 .../Tree/Pattern/ParseTreePattern.cs          |  16 +-
 .../Tree/Pattern/ParseTreePatternMatcher.cs   |  12 +-
 .../Tree/Pattern/RuleTagToken.cs              |  13 +-
 .../Antlr4.Runtime/Tree/Pattern/TagChunk.cs   |   8 +-
 .../Antlr4.Runtime/Tree/Pattern/TextChunk.cs  |  10 +-
 .../Tree/Pattern/TokenTagToken.cs             |  12 +-
 .../Antlr4.Runtime/Tree/TerminalNodeImpl.cs   |   8 +-
 runtime/CSharp/Antlr4.Runtime/Tree/Trees.cs   |  22 +-
 .../CSharp/Antlr4.Runtime/Tree/Xpath/XPath.cs |   8 +-
 .../Antlr4.Runtime/Tree/Xpath/XPathElement.cs |   8 +-
 .../Tree/Xpath/XPathLexerErrorListener.cs     |   8 +-
 .../Tree/Xpath/XPathRuleAnywhereElement.cs    |   8 +-
 .../Tree/Xpath/XPathRuleElement.cs            |   8 +-
 .../Tree/Xpath/XPathTokenAnywhereElement.cs   |   8 +-
 .../Tree/Xpath/XPathTokenElement.cs           |   8 +-
 .../Xpath/XPathWildcardAnywhereElement.cs     |   8 +-
 .../Tree/Xpath/XPathWildcardElement.cs        |   8 +-
 .../Antlr4.Runtime/UnbufferedCharStream.cs    |   8 +-
 .../Antlr4.Runtime/UnbufferedTokenStream.cs   |  10 +-
 runtime/CSharp/Antlr4.Runtime/Vocabulary.cs   |  14 +-
 172 files changed, 1323 insertions(+), 1301 deletions(-)

diff --git a/reference/sharpen b/reference/sharpen
index d6ea9528..2fab3583 160000
--- a/reference/sharpen
+++ b/reference/sharpen
@@ -1 +1 @@
-Subproject commit d6ea9528fc18d71e715eee4638675d9ad7160bb0
+Subproject commit 2fab3583dd6687c48103524c7740ef73b28b0118
diff --git a/runtime/CSharp/Antlr4.Runtime/ANTLRFileStream.cs b/runtime/CSharp/Antlr4.Runtime/ANTLRFileStream.cs
index aeae59f0..59b60f6d 100644
--- a/runtime/CSharp/Antlr4.Runtime/ANTLRFileStream.cs
+++ b/runtime/CSharp/Antlr4.Runtime/ANTLRFileStream.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
@@ -22,20 +22,20 @@ public class AntlrFileStream : AntlrInputStream
         protected internal string fileName;
 
         /// <exception cref="System.IO.IOException"/>
-        public AntlrFileStream(string fileName)
+        public AntlrFileStream([NotNull] string fileName)
             : this(fileName, null)
         {
         }
 
         /// <exception cref="System.IO.IOException"/>
-        public AntlrFileStream(string fileName, string encoding)
+        public AntlrFileStream([NotNull] string fileName, string encoding)
         {
             this.fileName = fileName;
             Load(fileName, encoding);
         }
 
         /// <exception cref="System.IO.IOException"/>
-        public virtual void Load(string fileName, string encoding)
+        public virtual void Load([NotNull] string fileName, [Nullable] string encoding)
         {
             data = Utils.ReadFile(fileName, encoding);
             this.n = data.Length;
diff --git a/runtime/CSharp/Antlr4.Runtime/ANTLRInputStream.cs b/runtime/CSharp/Antlr4.Runtime/ANTLRInputStream.cs
index 049a8d2d..1d61c962 100644
--- a/runtime/CSharp/Antlr4.Runtime/ANTLRInputStream.cs
+++ b/runtime/CSharp/Antlr4.Runtime/ANTLRInputStream.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.IO;
 using Antlr4.Runtime.Misc;
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/ATN.cs b/runtime/CSharp/Antlr4.Runtime/Atn/ATN.cs
index b75b5f5f..0f610be9 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/ATN.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/ATN.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
@@ -84,7 +84,7 @@ public class ATN
         protected internal readonly ConcurrentDictionary<int, int> LL1Table = new ConcurrentDictionary<int, int>();
 
         /// <summary>Used for runtime deserialization of ATNs from strings</summary>
-        public ATN(ATNType grammarType, int maxTokenType)
+        public ATN([NotNull] ATNType grammarType, int maxTokenType)
         {
             this.grammarType = grammarType;
             this.maxTokenType = maxTokenType;
@@ -145,7 +145,7 @@ public DFA[] DecisionToDfa
         /// 's rule.
         /// </summary>
         [NotNull]
-        public virtual IntervalSet NextTokens(ATNState s, PredictionContext ctx)
+        public virtual IntervalSet NextTokens(ATNState s, [NotNull] PredictionContext ctx)
         {
             Args.NotNull("ctx", ctx);
             LL1Analyzer anal = new LL1Analyzer(this);
@@ -163,7 +163,7 @@ public virtual IntervalSet NextTokens(ATNState s, PredictionContext ctx)
         /// rule.
         /// </summary>
         [NotNull]
-        public virtual IntervalSet NextTokens(ATNState s)
+        public virtual IntervalSet NextTokens([NotNull] ATNState s)
         {
             if (s.nextTokenWithinRule != null)
             {
@@ -174,7 +174,7 @@ public virtual IntervalSet NextTokens(ATNState s)
             return s.nextTokenWithinRule;
         }
 
-        public virtual void AddState(ATNState state)
+        public virtual void AddState([Nullable] ATNState state)
         {
             if (state != null)
             {
@@ -184,13 +184,13 @@ public virtual void AddState(ATNState state)
             states.Add(state);
         }
 
-        public virtual void RemoveState(ATNState state)
+        public virtual void RemoveState([NotNull] ATNState state)
         {
             states.Set(state.stateNumber, null);
         }
 
         // just free mem, don't shift states in list
-        public virtual void DefineMode(string name, TokensStartState s)
+        public virtual void DefineMode([NotNull] string name, [NotNull] TokensStartState s)
         {
             modeNameToStartState[name] = s;
             modeToStartState.Add(s);
@@ -199,7 +199,7 @@ public virtual void DefineMode(string name, TokensStartState s)
             DefineDecisionState(s);
         }
 
-        public virtual int DefineDecisionState(DecisionState s)
+        public virtual int DefineDecisionState([NotNull] DecisionState s)
         {
             decisionToState.Add(s);
             s.decision = decisionToState.Count - 1;
@@ -272,7 +272,7 @@ public virtual int NumberOfDecisions
         /// <paramref name="stateNumber"/>
         /// </exception>
         [NotNull]
-        public virtual IntervalSet GetExpectedTokens(int stateNumber, RuleContext context)
+        public virtual IntervalSet GetExpectedTokens(int stateNumber, [Nullable] RuleContext context)
         {
             if (stateNumber < 0 || stateNumber >= states.Count)
             {
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/ATNConfig.cs b/runtime/CSharp/Antlr4.Runtime/Atn/ATNConfig.cs
index c2d6fcd7..d232091c 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/ATNConfig.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/ATNConfig.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using System.Text;
@@ -63,7 +63,7 @@ public class ATNConfig
         [NotNull]
         private PredictionContext context;
 
-        protected internal ATNConfig(ATNState state, int alt, PredictionContext context)
+        protected internal ATNConfig([NotNull] ATNState state, int alt, [NotNull] PredictionContext context)
         {
             System.Diagnostics.Debug.Assert((alt & unchecked((int)(0xFFFFFF))) == alt);
             this.state = state;
@@ -71,24 +71,24 @@ protected internal ATNConfig(ATNState state, int alt, PredictionContext context)
             this.context = context;
         }
 
-        protected internal ATNConfig(Antlr4.Runtime.Atn.ATNConfig c, ATNState state, PredictionContext context)
+        protected internal ATNConfig([NotNull] Antlr4.Runtime.Atn.ATNConfig c, [NotNull] ATNState state, [NotNull] PredictionContext context)
         {
             this.state = state;
             this.altAndOuterContextDepth = c.altAndOuterContextDepth;
             this.context = context;
         }
 
-        public static Antlr4.Runtime.Atn.ATNConfig Create(ATNState state, int alt, PredictionContext context)
+        public static Antlr4.Runtime.Atn.ATNConfig Create([NotNull] ATNState state, int alt, [Nullable] PredictionContext context)
         {
             return Create(state, alt, context, Antlr4.Runtime.Atn.SemanticContext.None, null);
         }
 
-        public static Antlr4.Runtime.Atn.ATNConfig Create(ATNState state, int alt, PredictionContext context, Antlr4.Runtime.Atn.SemanticContext semanticContext)
+        public static Antlr4.Runtime.Atn.ATNConfig Create([NotNull] ATNState state, int alt, [Nullable] PredictionContext context, [NotNull] Antlr4.Runtime.Atn.SemanticContext semanticContext)
         {
             return Create(state, alt, context, semanticContext, null);
         }
 
-        public static Antlr4.Runtime.Atn.ATNConfig Create(ATNState state, int alt, PredictionContext context, Antlr4.Runtime.Atn.SemanticContext semanticContext, LexerActionExecutor lexerActionExecutor)
+        public static Antlr4.Runtime.Atn.ATNConfig Create([NotNull] ATNState state, int alt, [Nullable] PredictionContext context, [NotNull] Antlr4.Runtime.Atn.SemanticContext semanticContext, LexerActionExecutor lexerActionExecutor)
         {
             if (semanticContext != Antlr4.Runtime.Atn.SemanticContext.None)
             {
@@ -213,27 +213,27 @@ public Antlr4.Runtime.Atn.ATNConfig Clone()
             return Transform(this.State, false);
         }
 
-        public Antlr4.Runtime.Atn.ATNConfig Transform(ATNState state, bool checkNonGreedy)
+        public Antlr4.Runtime.Atn.ATNConfig Transform([NotNull] ATNState state, bool checkNonGreedy)
         {
             return Transform(state, this.context, this.SemanticContext, checkNonGreedy, this.ActionExecutor);
         }
 
-        public Antlr4.Runtime.Atn.ATNConfig Transform(ATNState state, Antlr4.Runtime.Atn.SemanticContext semanticContext, bool checkNonGreedy)
+        public Antlr4.Runtime.Atn.ATNConfig Transform([NotNull] ATNState state, [NotNull] Antlr4.Runtime.Atn.SemanticContext semanticContext, bool checkNonGreedy)
         {
             return Transform(state, this.context, semanticContext, checkNonGreedy, this.ActionExecutor);
         }
 
-        public Antlr4.Runtime.Atn.ATNConfig Transform(ATNState state, PredictionContext context, bool checkNonGreedy)
+        public Antlr4.Runtime.Atn.ATNConfig Transform([NotNull] ATNState state, [Nullable] PredictionContext context, bool checkNonGreedy)
         {
             return Transform(state, context, this.SemanticContext, checkNonGreedy, this.ActionExecutor);
         }
 
-        public Antlr4.Runtime.Atn.ATNConfig Transform(ATNState state, LexerActionExecutor lexerActionExecutor, bool checkNonGreedy)
+        public Antlr4.Runtime.Atn.ATNConfig Transform([NotNull] ATNState state, LexerActionExecutor lexerActionExecutor, bool checkNonGreedy)
         {
             return Transform(state, context, this.SemanticContext, checkNonGreedy, lexerActionExecutor);
         }
 
-        private Antlr4.Runtime.Atn.ATNConfig Transform(ATNState state, PredictionContext context, Antlr4.Runtime.Atn.SemanticContext semanticContext, bool checkNonGreedy, LexerActionExecutor lexerActionExecutor)
+        private Antlr4.Runtime.Atn.ATNConfig Transform([NotNull] ATNState state, [Nullable] PredictionContext context, [NotNull] Antlr4.Runtime.Atn.SemanticContext semanticContext, bool checkNonGreedy, LexerActionExecutor lexerActionExecutor)
         {
             bool passedThroughNonGreedy = checkNonGreedy && CheckNonGreedyDecision(this, state);
             if (semanticContext != Antlr4.Runtime.Atn.SemanticContext.None)
@@ -482,13 +482,13 @@ private class SemanticContextATNConfig : ATNConfig
             [NotNull]
             private readonly Antlr4.Runtime.Atn.SemanticContext semanticContext;
 
-            public SemanticContextATNConfig(Antlr4.Runtime.Atn.SemanticContext semanticContext, ATNState state, int alt, PredictionContext context)
+            public SemanticContextATNConfig(Antlr4.Runtime.Atn.SemanticContext semanticContext, [NotNull] ATNState state, int alt, [Nullable] PredictionContext context)
                 : base(state, alt, context)
             {
                 this.semanticContext = semanticContext;
             }
 
-            public SemanticContextATNConfig(Antlr4.Runtime.Atn.SemanticContext semanticContext, ATNConfig c, ATNState state, PredictionContext context)
+            public SemanticContextATNConfig(Antlr4.Runtime.Atn.SemanticContext semanticContext, [NotNull] ATNConfig c, [NotNull] ATNState state, [Nullable] PredictionContext context)
                 : base(c, state, context)
             {
                 this.semanticContext = semanticContext;
@@ -509,14 +509,14 @@ private class ActionATNConfig : ATNConfig
 
             private readonly bool passedThroughNonGreedyDecision;
 
-            public ActionATNConfig(LexerActionExecutor lexerActionExecutor, ATNState state, int alt, PredictionContext context, bool passedThroughNonGreedyDecision)
+            public ActionATNConfig(LexerActionExecutor lexerActionExecutor, [NotNull] ATNState state, int alt, [Nullable] PredictionContext context, bool passedThroughNonGreedyDecision)
                 : base(state, alt, context)
             {
                 this.lexerActionExecutor = lexerActionExecutor;
                 this.passedThroughNonGreedyDecision = passedThroughNonGreedyDecision;
             }
 
-            protected internal ActionATNConfig(LexerActionExecutor lexerActionExecutor, ATNConfig c, ATNState state, PredictionContext context, bool passedThroughNonGreedyDecision)
+            protected internal ActionATNConfig(LexerActionExecutor lexerActionExecutor, [NotNull] ATNConfig c, [NotNull] ATNState state, [Nullable] PredictionContext context, bool passedThroughNonGreedyDecision)
                 : base(c, state, context)
             {
                 if (c.SemanticContext != SemanticContext.None)
@@ -550,14 +550,14 @@ private class ActionSemanticContextATNConfig : ATNConfig.SemanticContextATNConfi
 
             private readonly bool passedThroughNonGreedyDecision;
 
-            public ActionSemanticContextATNConfig(LexerActionExecutor lexerActionExecutor, SemanticContext semanticContext, ATNState state, int alt, PredictionContext context, bool passedThroughNonGreedyDecision)
+            public ActionSemanticContextATNConfig(LexerActionExecutor lexerActionExecutor, [NotNull] SemanticContext semanticContext, [NotNull] ATNState state, int alt, [Nullable] PredictionContext context, bool passedThroughNonGreedyDecision)
                 : base(semanticContext, state, alt, context)
             {
                 this.lexerActionExecutor = lexerActionExecutor;
                 this.passedThroughNonGreedyDecision = passedThroughNonGreedyDecision;
             }
 
-            public ActionSemanticContextATNConfig(LexerActionExecutor lexerActionExecutor, SemanticContext semanticContext, ATNConfig c, ATNState state, PredictionContext context, bool passedThroughNonGreedyDecision)
+            public ActionSemanticContextATNConfig(LexerActionExecutor lexerActionExecutor, [NotNull] SemanticContext semanticContext, [NotNull] ATNConfig c, [NotNull] ATNState state, [Nullable] PredictionContext context, bool passedThroughNonGreedyDecision)
                 : base(semanticContext, c, state, context)
             {
                 this.lexerActionExecutor = lexerActionExecutor;
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/ATNConfigSet.cs b/runtime/CSharp/Antlr4.Runtime/Atn/ATNConfigSet.cs
index 4ff45328..409e0eee 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/ATNConfigSet.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/ATNConfigSet.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using System.Text;
@@ -260,7 +260,7 @@ public virtual bool Add(ATNConfig e)
             return Add(e, null);
         }
 
-        public virtual bool Add(ATNConfig e, PredictionContextCache contextCache)
+        public virtual bool Add(ATNConfig e, [Nullable] PredictionContextCache contextCache)
         {
             EnsureWritable();
             System.Diagnostics.Debug.Assert(!outermostConfigSet || !e.ReachesIntoOuterContext);
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/ATNDeserializationOptions.cs b/runtime/CSharp/Antlr4.Runtime/Atn/ATNDeserializationOptions.cs
index 3fb7526b..297b31ca 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/ATNDeserializationOptions.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/ATNDeserializationOptions.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using Antlr4.Runtime.Sharpen;
 
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/ATNDeserializer.cs b/runtime/CSharp/Antlr4.Runtime/Atn/ATNDeserializer.cs
index c0aafaba..6e327802 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/ATNDeserializer.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/ATNDeserializer.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using System.Globalization;
@@ -23,9 +23,9 @@ public class ATNDeserializer
 
         static ATNDeserializer()
         {
-            /* This value should never change. Updates following this version are
-            * reflected as change in the unique ID SERIALIZED_UUID.
-            */
+		/* This value should never change. Updates following this version are
+		 * reflected as change in the unique ID SERIALIZED_UUID.
+		 */
             SerializedVersion = 3;
         }
 
@@ -52,9 +52,9 @@ static ATNDeserializer()
 
         static ATNDeserializer()
         {
-            /* WARNING: DO NOT MERGE THESE LINES. If UUIDs differ during a merge,
-            * resolve the conflict by generating a new ID!
-            */
+		/* WARNING: DO NOT MERGE THESE LINES. If UUIDs differ during a merge,
+		 * resolve the conflict by generating a new ID!
+		 */
             BaseSerializedUuid = Guid.FromString("E4178468-DF95-44D0-AD87-F22A5D5FB6D3");
             AddedLexerActions = Guid.FromString("AB35191A-1603-487E-B75A-479B831EAF6D");
             SupportedUuids = new List<Guid>();
@@ -71,7 +71,7 @@ public ATNDeserializer()
         {
         }
 
-        public ATNDeserializer(ATNDeserializationOptions deserializationOptions)
+        public ATNDeserializer([Nullable] ATNDeserializationOptions deserializationOptions)
         {
             if (deserializationOptions == null)
             {
@@ -122,7 +122,7 @@ protected internal virtual bool IsFeatureSupported(Guid feature, Guid actualUuid
             return SupportedUuids.IndexOf(actualUuid) >= featureIndex;
         }
 
-        public virtual ATN Deserialize(char[] data)
+        public virtual ATN Deserialize([NotNull] char[] data)
         {
             data = data.MemberwiseClone();
             // don't adjust the first value since that's the version number
@@ -590,7 +590,7 @@ public virtual ATN Deserialize(char[] data)
         /// correct value.
         /// </summary>
         /// <param name="atn">The ATN.</param>
-        protected internal virtual void MarkPrecedenceDecisions(ATN atn)
+        protected internal virtual void MarkPrecedenceDecisions([NotNull] ATN atn)
         {
             // Map rule index -> precedence decision for that rule
             IDictionary<int, StarLoopEntryState> rulePrecedenceDecisions = new Dictionary<int, StarLoopEntryState>();
@@ -600,10 +600,10 @@ protected internal virtual void MarkPrecedenceDecisions(ATN atn)
                 {
                     continue;
                 }
-                /* We analyze the ATN to determine if this ATN decision state is the
-                * decision for the closure block that determines whether a
-                * precedence rule should continue or complete.
-                */
+			/* We analyze the ATN to determine if this ATN decision state is the
+			 * decision for the closure block that determines whether a
+			 * precedence rule should continue or complete.
+			 */
                 if (atn.ruleToStartState[state.ruleIndex].isPrecedenceRule)
                 {
                     ATNState maybeLoopEndState = state.Transition(state.NumberOfTransitions - 1).target;
@@ -1124,7 +1124,7 @@ protected internal static Guid ToUUID(char[] data, int offset)
         }
 
         [NotNull]
-        protected internal virtual Transition EdgeFactory(ATN atn, TransitionType type, int src, int trg, int arg1, int arg2, int arg3, IList<IntervalSet> sets)
+        protected internal virtual Transition EdgeFactory([NotNull] ATN atn, TransitionType type, int src, int trg, int arg1, int arg2, int arg3, IList<IntervalSet> sets)
         {
             ATNState target = atn.states[trg];
             switch (type)
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/ATNSerializer.cs b/runtime/CSharp/Antlr4.Runtime/Atn/ATNSerializer.cs
index dc3432cd..2ed8f10a 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/ATNSerializer.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/ATNSerializer.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using System.Globalization;
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/ATNSimulator.cs b/runtime/CSharp/Antlr4.Runtime/Atn/ATNSimulator.cs
index 03784f2c..d71ba858 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/ATNSimulator.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/ATNSimulator.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using Antlr4.Runtime.Dfa;
@@ -52,7 +52,7 @@ static ATNSimulator()
             Error.stateNumber = int.MaxValue;
         }
 
-        public ATNSimulator(ATN atn)
+        public ATNSimulator([NotNull] ATN atn)
         {
             this.atn = atn;
         }
@@ -77,7 +77,7 @@ public virtual void ClearDFA()
         }
 
         [System.ObsoleteAttribute(@"Use ATNDeserializer.Deserialize(char[]) instead.")]
-        public static ATN Deserialize(char[] data)
+        public static ATN Deserialize([NotNull] char[] data)
         {
             return new ATNDeserializer().Deserialize(data);
         }
@@ -120,7 +120,7 @@ public static Guid ToUUID(char[] data, int offset)
 
         [NotNull]
         [System.ObsoleteAttribute(@"Use ATNDeserializer.EdgeFactory(ATN, TransitionType, int, int, int, int, int, System.Collections.Generic.IList{E}) instead.")]
-        public static Transition EdgeFactory(ATN atn, TransitionType type, int src, int trg, int arg1, int arg2, int arg3, IList<IntervalSet> sets)
+        public static Transition EdgeFactory([NotNull] ATN atn, TransitionType type, int src, int trg, int arg1, int arg2, int arg3, IList<IntervalSet> sets)
         {
             return new ATNDeserializer().EdgeFactory(atn, type, src, trg, arg1, arg2, arg3, sets);
         }
@@ -130,16 +130,16 @@ public static ATNState StateFactory(StateType type, int ruleIndex)
         {
             return new ATNDeserializer().StateFactory(type, ruleIndex);
         }
-        /*
-        public static void dump(DFA dfa, Grammar g) {
-        DOTGenerator dot = new DOTGenerator(g);
-        String output = dot.getDOT(dfa, false);
-        System.out.println(output);
-        }
-        
-        public static void dump(DFA dfa) {
-        dump(dfa, null);
-        }
-        */
+/*
+	public static void dump(DFA dfa, Grammar g) {
+		DOTGenerator dot = new DOTGenerator(g);
+		String output = dot.getDOT(dfa, false);
+		System.out.println(output);
+	}
+
+	public static void dump(DFA dfa) {
+		dump(dfa, null);
+	}
+	 */
     }
 }
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/ATNState.cs b/runtime/CSharp/Antlr4.Runtime/Atn/ATNState.cs
index 665fc54c..e09e6899 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/ATNState.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/ATNState.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using System.Globalization;
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/ATNType.cs b/runtime/CSharp/Antlr4.Runtime/Atn/ATNType.cs
index 619c6882..61549162 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/ATNType.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/ATNType.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/AbstractPredicateTransition.cs b/runtime/CSharp/Antlr4.Runtime/Atn/AbstractPredicateTransition.cs
index 0cd715c8..ccf2b0d1 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/AbstractPredicateTransition.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/AbstractPredicateTransition.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/ActionTransition.cs b/runtime/CSharp/Antlr4.Runtime/Atn/ActionTransition.cs
index 39a6efa4..4cde2816 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/ActionTransition.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/ActionTransition.cs
@@ -2,10 +2,11 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
@@ -18,12 +19,12 @@ public sealed class ActionTransition : Transition
 
         public readonly bool isCtxDependent;
 
-        public ActionTransition(ATNState target, int ruleIndex)
+        public ActionTransition([NotNull] ATNState target, int ruleIndex)
             : this(target, ruleIndex, -1, false)
         {
         }
 
-        public ActionTransition(ATNState target, int ruleIndex, int actionIndex, bool isCtxDependent)
+        public ActionTransition([NotNull] ATNState target, int ruleIndex, int actionIndex, bool isCtxDependent)
             : base(target)
         {
             // e.g., $i ref in action
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/AmbiguityInfo.cs b/runtime/CSharp/Antlr4.Runtime/Atn/AmbiguityInfo.cs
index c128cce9..4bb251fe 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/AmbiguityInfo.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/AmbiguityInfo.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -70,7 +70,7 @@ public class AmbiguityInfo : DecisionEventInfo
         /// The index at which the ambiguity was identified during
         /// prediction
         /// </param>
-        public AmbiguityInfo(int decision, SimulatorState state, BitSet ambigAlts, ITokenStream input, int startIndex, int stopIndex)
+        public AmbiguityInfo(int decision, [NotNull] SimulatorState state, [NotNull] BitSet ambigAlts, [NotNull] ITokenStream input, int startIndex, int stopIndex)
             : base(decision, state, input, startIndex, stopIndex, state.useContext)
         {
             this.ambigAlts = ambigAlts;
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/ArrayPredictionContext.cs b/runtime/CSharp/Antlr4.Runtime/Atn/ArrayPredictionContext.cs
index 41e267f2..a7530108 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/ArrayPredictionContext.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/ArrayPredictionContext.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using Antlr4.Runtime.Misc;
@@ -21,20 +21,20 @@ public class ArrayPredictionContext : PredictionContext
         [NotNull]
         public readonly int[] returnStates;
 
-        internal ArrayPredictionContext(PredictionContext[] parents, int[] returnStates)
+        internal ArrayPredictionContext([NotNull] PredictionContext[] parents, int[] returnStates)
             : base(CalculateHashCode(parents, returnStates))
         {
-            /*package*/
+	/*package*/
             System.Diagnostics.Debug.Assert(parents.Length == returnStates.Length);
             System.Diagnostics.Debug.Assert(returnStates.Length > 1 || returnStates[0] != EmptyFullStateKey, "Should be using PredictionContext.EMPTY instead.");
             this.parents = parents;
             this.returnStates = returnStates;
         }
 
-        internal ArrayPredictionContext(PredictionContext[] parents, int[] returnStates, int hashCode)
+        internal ArrayPredictionContext([NotNull] PredictionContext[] parents, int[] returnStates, int hashCode)
             : base(hashCode)
         {
-            /*package*/
+	/*package*/
             System.Diagnostics.Debug.Assert(parents.Length == returnStates.Length);
             System.Diagnostics.Debug.Assert(returnStates.Length > 1 || returnStates[0] != EmptyFullStateKey, "Should be using PredictionContext.EMPTY instead.");
             this.parents = parents;
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/AtomTransition.cs b/runtime/CSharp/Antlr4.Runtime/Atn/AtomTransition.cs
index 456b5294..1f8dca9a 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/AtomTransition.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/AtomTransition.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
@@ -17,7 +17,7 @@ public sealed class AtomTransition : Transition
         /// <summary>The token type or character value; or, signifies special label.</summary>
         public readonly int label;
 
-        public AtomTransition(ATNState target, int label)
+        public AtomTransition([NotNull] ATNState target, int label)
             : base(target)
         {
             this.label = label;
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/BasicBlockStartState.cs b/runtime/CSharp/Antlr4.Runtime/Atn/BasicBlockStartState.cs
index fce46044..2b7eab82 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/BasicBlockStartState.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/BasicBlockStartState.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/BasicState.cs b/runtime/CSharp/Antlr4.Runtime/Atn/BasicState.cs
index 90b92527..17f84c85 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/BasicState.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/BasicState.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/BlockEndState.cs b/runtime/CSharp/Antlr4.Runtime/Atn/BlockEndState.cs
index fb19f9f7..8ba0abcc 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/BlockEndState.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/BlockEndState.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/BlockStartState.cs b/runtime/CSharp/Antlr4.Runtime/Atn/BlockStartState.cs
index dba9b952..65276d92 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/BlockStartState.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/BlockStartState.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/ConflictInfo.cs b/runtime/CSharp/Antlr4.Runtime/Atn/ConflictInfo.cs
index f6b42ee2..b7cbdec7 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/ConflictInfo.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/ConflictInfo.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/ContextSensitivityInfo.cs b/runtime/CSharp/Antlr4.Runtime/Atn/ContextSensitivityInfo.cs
index e66377de..9a2dc5df 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/ContextSensitivityInfo.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/ContextSensitivityInfo.cs
@@ -2,11 +2,12 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
+using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
@@ -48,7 +49,7 @@ public class ContextSensitivityInfo : DecisionEventInfo
         /// The index at which the context sensitivity was
         /// identified during full-context prediction
         /// </param>
-        public ContextSensitivityInfo(int decision, SimulatorState state, ITokenStream input, int startIndex, int stopIndex)
+        public ContextSensitivityInfo(int decision, [NotNull] SimulatorState state, [NotNull] ITokenStream input, int startIndex, int stopIndex)
             : base(decision, state, input, startIndex, stopIndex, true)
         {
         }
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/DecisionEventInfo.cs b/runtime/CSharp/Antlr4.Runtime/Atn/DecisionEventInfo.cs
index 9cea97c0..49ce1f8c 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/DecisionEventInfo.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/DecisionEventInfo.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -69,7 +69,7 @@ public class DecisionEventInfo
         /// </summary>
         public readonly bool fullCtx;
 
-        public DecisionEventInfo(int decision, SimulatorState state, ITokenStream input, int startIndex, int stopIndex, bool fullCtx)
+        public DecisionEventInfo(int decision, [Nullable] SimulatorState state, [NotNull] ITokenStream input, int startIndex, int stopIndex, bool fullCtx)
         {
             this.decision = decision;
             this.fullCtx = fullCtx;
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/DecisionInfo.cs b/runtime/CSharp/Antlr4.Runtime/Atn/DecisionInfo.cs
index d2308f14..9af7fc09 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/DecisionInfo.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/DecisionInfo.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using Antlr4.Runtime.Sharpen;
 
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/DecisionState.cs b/runtime/CSharp/Antlr4.Runtime/Atn/DecisionState.cs
index d4865185..3eee32f7 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/DecisionState.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/DecisionState.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/EmptyPredictionContext.cs b/runtime/CSharp/Antlr4.Runtime/Atn/EmptyPredictionContext.cs
index ef4b15eb..06394d0a 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/EmptyPredictionContext.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/EmptyPredictionContext.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using Antlr4.Runtime;
 using Antlr4.Runtime.Sharpen;
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/EpsilonTransition.cs b/runtime/CSharp/Antlr4.Runtime/Atn/EpsilonTransition.cs
index 25d8fc30..18bce1d1 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/EpsilonTransition.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/EpsilonTransition.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
@@ -15,12 +15,12 @@ public sealed class EpsilonTransition : Transition
     {
         private readonly int outermostPrecedenceReturn;
 
-        public EpsilonTransition(ATNState target)
+        public EpsilonTransition([NotNull] ATNState target)
             : this(target, -1)
         {
         }
 
-        public EpsilonTransition(ATNState target, int outermostPrecedenceReturn)
+        public EpsilonTransition([NotNull] ATNState target, int outermostPrecedenceReturn)
             : base(target)
         {
             this.outermostPrecedenceReturn = outermostPrecedenceReturn;
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/ErrorInfo.cs b/runtime/CSharp/Antlr4.Runtime/Atn/ErrorInfo.cs
index 840f80cf..fcbb415f 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/ErrorInfo.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/ErrorInfo.cs
@@ -2,11 +2,12 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
+using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
@@ -42,7 +43,7 @@ public class ErrorInfo : DecisionEventInfo
         /// <param name="input">The input token stream</param>
         /// <param name="startIndex">The start index for the current prediction</param>
         /// <param name="stopIndex">The index at which the syntax error was identified</param>
-        public ErrorInfo(int decision, SimulatorState state, ITokenStream input, int startIndex, int stopIndex)
+        public ErrorInfo(int decision, [NotNull] SimulatorState state, [NotNull] ITokenStream input, int startIndex, int stopIndex)
             : base(decision, state, input, startIndex, stopIndex, state.useContext)
         {
         }
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/ILexerAction.cs b/runtime/CSharp/Antlr4.Runtime/Atn/ILexerAction.cs
index 77e195f6..dd7c060d 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/ILexerAction.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/ILexerAction.cs
@@ -2,11 +2,12 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
+using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
@@ -73,6 +74,6 @@ bool IsPositionDependent
         /// positioned correctly prior to calling this method.</p>
         /// </summary>
         /// <param name="lexer">The lexer instance.</param>
-        void Execute(Lexer lexer);
+        void Execute([NotNull] Lexer lexer);
     }
 }
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/LL1Analyzer.cs b/runtime/CSharp/Antlr4.Runtime/Atn/LL1Analyzer.cs
index 7c20bace..99cb51ab 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/LL1Analyzer.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/LL1Analyzer.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -25,7 +25,7 @@ public class LL1Analyzer
         [NotNull]
         public readonly ATN atn;
 
-        public LL1Analyzer(ATN atn)
+        public LL1Analyzer([NotNull] ATN atn)
         {
             this.atn = atn;
         }
@@ -50,7 +50,7 @@ public LL1Analyzer(ATN atn)
         /// .
         /// </returns>
         [Nullable]
-        public virtual IntervalSet[] GetDecisionLookahead(ATNState s)
+        public virtual IntervalSet[] GetDecisionLookahead([Nullable] ATNState s)
         {
             //		System.out.println("LOOK("+s.stateNumber+")");
             if (s == null)
@@ -116,7 +116,7 @@ public virtual IntervalSet[] GetDecisionLookahead(ATNState s)
         /// .
         /// </returns>
         [NotNull]
-        public virtual IntervalSet Look(ATNState s, PredictionContext ctx)
+        public virtual IntervalSet Look([NotNull] ATNState s, [NotNull] PredictionContext ctx)
         {
             return Look(s, s.atn.ruleToStopState[s.ruleIndex], ctx);
         }
@@ -167,7 +167,7 @@ public virtual IntervalSet Look(ATNState s, PredictionContext ctx)
         /// .
         /// </returns>
         [NotNull]
-        public virtual IntervalSet Look(ATNState s, ATNState stopState, PredictionContext ctx)
+        public virtual IntervalSet Look([NotNull] ATNState s, [Nullable] ATNState stopState, [NotNull] PredictionContext ctx)
         {
             IntervalSet r = new IntervalSet();
             bool seeThruPreds = true;
@@ -257,7 +257,7 @@ public virtual IntervalSet Look(ATNState s, ATNState stopState, PredictionContex
         /// <see cref="PredictionContext.EmptyLocal"/>
         /// .
         /// </param>
-        protected internal virtual void Look(ATNState s, ATNState stopState, PredictionContext ctx, IntervalSet look, HashSet<ATNConfig> lookBusy, BitSet calledRuleStack, bool seeThruPreds, bool addEOF)
+        protected internal virtual void Look([NotNull] ATNState s, [Nullable] ATNState stopState, [NotNull] PredictionContext ctx, [NotNull] IntervalSet look, [NotNull] HashSet<ATNConfig> lookBusy, [NotNull] BitSet calledRuleStack, bool seeThruPreds, bool addEOF)
         {
             //		System.out.println("_LOOK("+s.stateNumber+", ctx="+ctx);
             ATNConfig c = ATNConfig.Create(s, 0, ctx);
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/LexerATNSimulator.cs b/runtime/CSharp/Antlr4.Runtime/Atn/LexerATNSimulator.cs
index 025923a6..839e0d45 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/LexerATNSimulator.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/LexerATNSimulator.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using Antlr4.Runtime;
 using Antlr4.Runtime.Dfa;
@@ -90,18 +90,18 @@ protected internal virtual void Reset()
 
         public static int match_calls = 0;
 
-        public LexerATNSimulator(ATN atn)
+        public LexerATNSimulator([NotNull] ATN atn)
             : this(null, atn)
         {
         }
 
-        public LexerATNSimulator(Lexer recog, ATN atn)
+        public LexerATNSimulator([Nullable] Lexer recog, [NotNull] ATN atn)
             : base(atn)
         {
             this.recog = recog;
         }
 
-        public virtual void CopyState(LexerATNSimulator simulator)
+        public virtual void CopyState([NotNull] LexerATNSimulator simulator)
         {
             this.charPositionInLine = simulator.charPositionInLine;
             this.line = simulator.line;
@@ -109,7 +109,7 @@ public virtual void CopyState(LexerATNSimulator simulator)
             this.startIndex = simulator.startIndex;
         }
 
-        public virtual int Match(ICharStream input, int mode)
+        public virtual int Match([NotNull] ICharStream input, int mode)
         {
             match_calls++;
             this.mode = mode;
@@ -143,7 +143,7 @@ public override void Reset()
             mode = Lexer.DefaultMode;
         }
 
-        protected internal virtual int MatchATN(ICharStream input)
+        protected internal virtual int MatchATN([NotNull] ICharStream input)
         {
             ATNState startState = atn.modeToStartState[mode];
             int old_mode = mode;
@@ -165,7 +165,7 @@ protected internal virtual int MatchATN(ICharStream input)
             return predict;
         }
 
-        protected internal virtual int ExecATN(ICharStream input, DFAState ds0)
+        protected internal virtual int ExecATN([NotNull] ICharStream input, [NotNull] DFAState ds0)
         {
             //System.out.println("enter exec index "+input.index()+" from "+ds0.configs);
             if (ds0.IsAcceptState)
@@ -247,7 +247,7 @@ protected internal virtual int ExecATN(ICharStream input, DFAState ds0)
         /// already cached
         /// </returns>
         [Nullable]
-        protected internal virtual DFAState GetExistingTargetState(DFAState s, int t)
+        protected internal virtual DFAState GetExistingTargetState([NotNull] DFAState s, int t)
         {
             DFAState target = s.GetTarget(t);
             if (debug && target != null)
@@ -275,7 +275,7 @@ protected internal virtual DFAState GetExistingTargetState(DFAState s, int t)
         /// .
         /// </returns>
         [NotNull]
-        protected internal virtual DFAState ComputeTargetState(ICharStream input, DFAState s, int t)
+        protected internal virtual DFAState ComputeTargetState([NotNull] ICharStream input, [NotNull] DFAState s, int t)
         {
             ATNConfigSet reach = new OrderedATNConfigSet();
             // if we don't find an existing DFA state
@@ -325,7 +325,7 @@ protected internal virtual int FailOrAccept(LexerATNSimulator.SimState prevAccep
         /// is a return
         /// parameter.
         /// </summary>
-        protected internal virtual void GetReachableConfigSet(ICharStream input, ATNConfigSet closure, ATNConfigSet reach, int t)
+        protected internal virtual void GetReachableConfigSet([NotNull] ICharStream input, [NotNull] ATNConfigSet closure, [NotNull] ATNConfigSet reach, int t)
         {
             // this is used to skip processing for configs which have a lower priority
             // than a config that already reached an accept state for the same rule
@@ -363,7 +363,7 @@ protected internal virtual void GetReachableConfigSet(ICharStream input, ATNConf
             }
         }
 
-        protected internal virtual void Accept(ICharStream input, LexerActionExecutor lexerActionExecutor, int startIndex, int index, int line, int charPos)
+        protected internal virtual void Accept([NotNull] ICharStream input, LexerActionExecutor lexerActionExecutor, int startIndex, int index, int line, int charPos)
         {
             // seek to after last char in token
             input.Seek(index);
@@ -386,7 +386,7 @@ protected internal virtual ATNState GetReachableTarget(Transition trans, int t)
         }
 
         [NotNull]
-        protected internal virtual ATNConfigSet ComputeStartState(ICharStream input, ATNState p)
+        protected internal virtual ATNConfigSet ComputeStartState([NotNull] ICharStream input, [NotNull] ATNState p)
         {
             PredictionContext initialContext = PredictionContext.EmptyFull;
             ATNConfigSet configs = new OrderedATNConfigSet();
@@ -420,7 +420,7 @@ protected internal virtual ATNConfigSet ComputeStartState(ICharStream input, ATN
         /// <see langword="false"/>
         /// .
         /// </returns>
-        protected internal virtual bool Closure(ICharStream input, ATNConfig config, ATNConfigSet configs, bool currentAltReachedAcceptState, bool speculative, bool treatEofAsEpsilon)
+        protected internal virtual bool Closure([NotNull] ICharStream input, [NotNull] ATNConfig config, [NotNull] ATNConfigSet configs, bool currentAltReachedAcceptState, bool speculative, bool treatEofAsEpsilon)
         {
             if (config.State is RuleStopState)
             {
@@ -476,7 +476,7 @@ protected internal virtual bool Closure(ICharStream input, ATNConfig config, ATN
 
         // side-effect: can alter configs.hasSemanticContext
         [Nullable]
-        protected internal virtual ATNConfig GetEpsilonTarget(ICharStream input, ATNConfig config, Transition t, ATNConfigSet configs, bool speculative, bool treatEofAsEpsilon)
+        protected internal virtual ATNConfig GetEpsilonTarget([NotNull] ICharStream input, [NotNull] ATNConfig config, [NotNull] Transition t, [NotNull] ATNConfigSet configs, bool speculative, bool treatEofAsEpsilon)
         {
             ATNConfig c;
             switch (t.TransitionType)
@@ -503,24 +503,24 @@ protected internal virtual ATNConfig GetEpsilonTarget(ICharStream input, ATNConf
 
                 case TransitionType.Predicate:
                 {
-                    /*  Track traversing semantic predicates. If we traverse,
-                    we cannot add a DFA state for this "reach" computation
-                    because the DFA would not test the predicate again in the
-                    future. Rather than creating collections of semantic predicates
-                    like v3 and testing them on prediction, v4 will test them on the
-                    fly all the time using the ATN not the DFA. This is slower but
-                    semantically it's not used that often. One of the key elements to
-                    this predicate mechanism is not adding DFA states that see
-                    predicates immediately afterwards in the ATN. For example,
-                    
-                    a : ID {p1}? | ID {p2}? ;
-                    
-                    should create the start state for rule 'a' (to save start state
-                    competition), but should not create target of ID state. The
-                    collection of ATN states the following ID references includes
-                    states reached by traversing predicates. Since this is when we
-                    test them, we cannot cash the DFA state target of ID.
-                    */
+			/*  Track traversing semantic predicates. If we traverse,
+			    we cannot add a DFA state for this "reach" computation
+				because the DFA would not test the predicate again in the
+				future. Rather than creating collections of semantic predicates
+				like v3 and testing them on prediction, v4 will test them on the
+				fly all the time using the ATN not the DFA. This is slower but
+				semantically it's not used that often. One of the key elements to
+				this predicate mechanism is not adding DFA states that see
+				predicates immediately afterwards in the ATN. For example,
+
+				a : ID {p1}? | ID {p2}? ;
+
+				should create the start state for rule 'a' (to save start state
+				competition), but should not create target of ID state. The
+				collection of ATN states the following ID references includes
+				states reached by traversing predicates. Since this is when we
+				test them, we cannot cash the DFA state target of ID.
+			*/
                     PredicateTransition pt = (PredicateTransition)t;
                     configs.MarkExplicitSemanticContext();
                     if (EvaluatePredicate(input, pt.ruleIndex, pt.predIndex, speculative))
@@ -640,7 +640,7 @@ states reached by traversing predicates. Since this is when we
         /// <see langword="true"/>
         /// .
         /// </returns>
-        protected internal virtual bool EvaluatePredicate(ICharStream input, int ruleIndex, int predIndex, bool speculative)
+        protected internal virtual bool EvaluatePredicate([NotNull] ICharStream input, int ruleIndex, int predIndex, bool speculative)
         {
             // assume true if no recognizer was provided
             if (recog == null)
@@ -669,7 +669,7 @@ protected internal virtual bool EvaluatePredicate(ICharStream input, int ruleInd
             }
         }
 
-        protected internal virtual void CaptureSimState(LexerATNSimulator.SimState settings, ICharStream input, DFAState dfaState)
+        protected internal virtual void CaptureSimState([NotNull] LexerATNSimulator.SimState settings, [NotNull] ICharStream input, [NotNull] DFAState dfaState)
         {
             settings.index = input.Index;
             settings.line = line;
@@ -678,19 +678,19 @@ protected internal virtual void CaptureSimState(LexerATNSimulator.SimState setti
         }
 
         [NotNull]
-        protected internal virtual DFAState AddDFAEdge(DFAState from, int t, ATNConfigSet q)
+        protected internal virtual DFAState AddDFAEdge([NotNull] DFAState from, int t, [NotNull] ATNConfigSet q)
         {
-            /* leading to this call, ATNConfigSet.hasSemanticContext is used as a
-            * marker indicating dynamic predicate evaluation makes this edge
-            * dependent on the specific input sequence, so the static edge in the
-            * DFA should be omitted. The target DFAState is still created since
-            * execATN has the ability to resynchronize with the DFA state cache
-            * following the predicate evaluation step.
-            *
-            * TJP notes: next time through the DFA, we see a pred again and eval.
-            * If that gets us to a previously created (but dangling) DFA
-            * state, we can continue in pure DFA mode from there.
-            */
+		/* leading to this call, ATNConfigSet.hasSemanticContext is used as a
+		 * marker indicating dynamic predicate evaluation makes this edge
+		 * dependent on the specific input sequence, so the static edge in the
+		 * DFA should be omitted. The target DFAState is still created since
+		 * execATN has the ability to resynchronize with the DFA state cache
+		 * following the predicate evaluation step.
+		 *
+		 * TJP notes: next time through the DFA, we see a pred again and eval.
+		 * If that gets us to a previously created (but dangling) DFA
+		 * state, we can continue in pure DFA mode from there.
+		 */
             bool suppressEdge = q.HasSemanticContext;
             if (suppressEdge)
             {
@@ -705,7 +705,7 @@ protected internal virtual DFAState AddDFAEdge(DFAState from, int t, ATNConfigSe
             return to;
         }
 
-        protected internal virtual void AddDFAEdge(DFAState p, int t, DFAState q)
+        protected internal virtual void AddDFAEdge([NotNull] DFAState p, int t, [NotNull] DFAState q)
         {
             if (p != null)
             {
@@ -724,11 +724,11 @@ protected internal virtual void AddDFAEdge(DFAState p, int t, DFAState q)
         /// traversing the DFA, we will know which rule to accept.
         /// </remarks>
         [NotNull]
-        protected internal virtual DFAState AddDFAState(ATNConfigSet configs)
+        protected internal virtual DFAState AddDFAState([NotNull] ATNConfigSet configs)
         {
-            /* the lexer evaluates predicates on-the-fly; by this point configs
-            * should not contain any configurations with unevaluated predicates.
-            */
+		/* the lexer evaluates predicates on-the-fly; by this point configs
+		 * should not contain any configurations with unevaluated predicates.
+		 */
             System.Diagnostics.Debug.Assert(!configs.HasSemanticContext);
             DFAState proposed = new DFAState(atn.modeToDFA[mode], configs);
             DFAState existing = atn.modeToDFA[mode].states[proposed];
@@ -764,7 +764,7 @@ public DFA GetDFA(int mode)
 
         /// <summary>Get the text matched so far for the current token.</summary>
         [NotNull]
-        public virtual string GetText(ICharStream input)
+        public virtual string GetText([NotNull] ICharStream input)
         {
             // index is first lookahead char, don't include.
             return input.GetText(Interval.Of(startIndex, input.Index - 1));
@@ -796,7 +796,7 @@ public virtual int Column
             }
         }
 
-        public virtual void Consume(ICharStream input)
+        public virtual void Consume([NotNull] ICharStream input)
         {
             int curChar = input.La(1);
             if (curChar == '\n')
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/LexerActionExecutor.cs b/runtime/CSharp/Antlr4.Runtime/Atn/LexerActionExecutor.cs
index bfce610a..c10ee657 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/LexerActionExecutor.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/LexerActionExecutor.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -48,7 +48,7 @@ public class LexerActionExecutor
         /// actions.
         /// </summary>
         /// <param name="lexerActions">The lexer actions to execute.</param>
-        public LexerActionExecutor(ILexerAction[] lexerActions)
+        public LexerActionExecutor([NotNull] ILexerAction[] lexerActions)
         {
             this.lexerActions = lexerActions;
             int hash = MurmurHash.Initialize();
@@ -95,7 +95,7 @@ public LexerActionExecutor(ILexerAction[] lexerActions)
         /// .
         /// </returns>
         [NotNull]
-        public static Antlr4.Runtime.Atn.LexerActionExecutor Append(Antlr4.Runtime.Atn.LexerActionExecutor lexerActionExecutor, ILexerAction lexerAction)
+        public static Antlr4.Runtime.Atn.LexerActionExecutor Append([Nullable] Antlr4.Runtime.Atn.LexerActionExecutor lexerActionExecutor, [NotNull] ILexerAction lexerAction)
         {
             if (lexerActionExecutor == null)
             {
@@ -212,7 +212,7 @@ public virtual ILexerAction[] LexerActions
         /// position to the beginning
         /// of the token.
         /// </param>
-        public virtual void Execute(Lexer lexer, ICharStream input, int startIndex)
+        public virtual void Execute([NotNull] Lexer lexer, ICharStream input, int startIndex)
         {
             bool requiresSeek = false;
             int stopIndex = input.Index;
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/LexerActionType.cs b/runtime/CSharp/Antlr4.Runtime/Atn/LexerActionType.cs
index 203db4f4..c374186c 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/LexerActionType.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/LexerActionType.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/LexerChannelAction.cs b/runtime/CSharp/Antlr4.Runtime/Atn/LexerChannelAction.cs
index cf6e546c..9c7d7097 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/LexerChannelAction.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/LexerChannelAction.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -95,7 +95,7 @@ public bool IsPositionDependent
         /// <see cref="Channel()"/>
         /// .</p>
         /// </summary>
-        public void Execute(Lexer lexer)
+        public void Execute([NotNull] Lexer lexer)
         {
             lexer.Channel = channel;
         }
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/LexerCustomAction.cs b/runtime/CSharp/Antlr4.Runtime/Atn/LexerCustomAction.cs
index 9d256d25..85963f30 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/LexerCustomAction.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/LexerCustomAction.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -126,7 +126,7 @@ public bool IsPositionDependent
         /// with the
         /// appropriate rule and action indexes.</p>
         /// </summary>
-        public void Execute(Lexer lexer)
+        public void Execute([NotNull] Lexer lexer)
         {
             lexer.Action(null, ruleIndex, actionIndex);
         }
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/LexerIndexedCustomAction.cs b/runtime/CSharp/Antlr4.Runtime/Atn/LexerIndexedCustomAction.cs
index fca0d6b1..044309e8 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/LexerIndexedCustomAction.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/LexerIndexedCustomAction.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -60,7 +60,7 @@ public sealed class LexerIndexedCustomAction : ILexerAction
         /// <see cref="Antlr4.Runtime.ICharStream"/>
         /// .
         /// </param>
-        public LexerIndexedCustomAction(int offset, ILexerAction action)
+        public LexerIndexedCustomAction(int offset, [NotNull] ILexerAction action)
         {
             this.offset = offset;
             this.action = action;
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/LexerModeAction.cs b/runtime/CSharp/Antlr4.Runtime/Atn/LexerModeAction.cs
index 4a1c51e9..0b08cece 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/LexerModeAction.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/LexerModeAction.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -92,7 +92,7 @@ public bool IsPositionDependent
         /// <see cref="Mode()"/>
         /// .</p>
         /// </summary>
-        public void Execute(Lexer lexer)
+        public void Execute([NotNull] Lexer lexer)
         {
             lexer.Mode(mode);
         }
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/LexerMoreAction.cs b/runtime/CSharp/Antlr4.Runtime/Atn/LexerMoreAction.cs
index 4a2f1751..5331df41 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/LexerMoreAction.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/LexerMoreAction.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -75,7 +75,7 @@ public bool IsPositionDependent
         /// <see cref="Antlr4.Runtime.Lexer.More()"/>
         /// .</p>
         /// </summary>
-        public void Execute(Lexer lexer)
+        public void Execute([NotNull] Lexer lexer)
         {
             lexer.More();
         }
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/LexerPopModeAction.cs b/runtime/CSharp/Antlr4.Runtime/Atn/LexerPopModeAction.cs
index c75f6b31..e3601f1f 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/LexerPopModeAction.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/LexerPopModeAction.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -75,7 +75,7 @@ public bool IsPositionDependent
         /// <see cref="Antlr4.Runtime.Lexer.PopMode()"/>
         /// .</p>
         /// </summary>
-        public void Execute(Lexer lexer)
+        public void Execute([NotNull] Lexer lexer)
         {
             lexer.PopMode();
         }
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/LexerPushModeAction.cs b/runtime/CSharp/Antlr4.Runtime/Atn/LexerPushModeAction.cs
index 07a9c217..8dc06bd4 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/LexerPushModeAction.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/LexerPushModeAction.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -91,7 +91,7 @@ public bool IsPositionDependent
         /// <see cref="Mode()"/>
         /// .</p>
         /// </summary>
-        public void Execute(Lexer lexer)
+        public void Execute([NotNull] Lexer lexer)
         {
             lexer.PushMode(mode);
         }
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/LexerSkipAction.cs b/runtime/CSharp/Antlr4.Runtime/Atn/LexerSkipAction.cs
index 5b11bfad..1849ad67 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/LexerSkipAction.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/LexerSkipAction.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -75,7 +75,7 @@ public bool IsPositionDependent
         /// <see cref="Antlr4.Runtime.Lexer.Skip()"/>
         /// .</p>
         /// </summary>
-        public void Execute(Lexer lexer)
+        public void Execute([NotNull] Lexer lexer)
         {
             lexer.Skip();
         }
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/LexerTypeAction.cs b/runtime/CSharp/Antlr4.Runtime/Atn/LexerTypeAction.cs
index ddee0da6..21c7dcf5 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/LexerTypeAction.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/LexerTypeAction.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -87,7 +87,7 @@ public virtual bool IsPositionDependent
         /// <see cref="Type()"/>
         /// .</p>
         /// </summary>
-        public virtual void Execute(Lexer lexer)
+        public virtual void Execute([NotNull] Lexer lexer)
         {
             lexer.Type = type;
         }
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/LookaheadEventInfo.cs b/runtime/CSharp/Antlr4.Runtime/Atn/LookaheadEventInfo.cs
index 772de082..dddba7c6 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/LookaheadEventInfo.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/LookaheadEventInfo.cs
@@ -2,11 +2,12 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
+using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
@@ -46,7 +47,7 @@ public class LookaheadEventInfo : DecisionEventInfo
         /// if the current lookahead is part of
         /// an SLL prediction
         /// </param>
-        public LookaheadEventInfo(int decision, SimulatorState state, int predictedAlt, ITokenStream input, int startIndex, int stopIndex, bool fullCtx)
+        public LookaheadEventInfo(int decision, [Nullable] SimulatorState state, int predictedAlt, [NotNull] ITokenStream input, int startIndex, int stopIndex, bool fullCtx)
             : base(decision, state, input, startIndex, stopIndex, fullCtx)
         {
             this.predictedAlt = predictedAlt;
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/LoopEndState.cs b/runtime/CSharp/Antlr4.Runtime/Atn/LoopEndState.cs
index d4dabff4..e274aca0 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/LoopEndState.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/LoopEndState.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/NotSetTransition.cs b/runtime/CSharp/Antlr4.Runtime/Atn/NotSetTransition.cs
index 48610853..451e743c 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/NotSetTransition.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/NotSetTransition.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
@@ -13,7 +13,7 @@ namespace Antlr4.Runtime.Atn
 {
     public sealed class NotSetTransition : SetTransition
     {
-        public NotSetTransition(ATNState target, IntervalSet set)
+        public NotSetTransition([NotNull] ATNState target, [Nullable] IntervalSet set)
             : base(target, set)
         {
         }
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/OrderedATNConfigSet.cs b/runtime/CSharp/Antlr4.Runtime/Atn/OrderedATNConfigSet.cs
index 12bae59a..26aef8f0 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/OrderedATNConfigSet.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/OrderedATNConfigSet.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/ParseInfo.cs b/runtime/CSharp/Antlr4.Runtime/Atn/ParseInfo.cs
index 4121b50c..db3a6a5f 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/ParseInfo.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/ParseInfo.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using Antlr4.Runtime.Dfa;
 using Antlr4.Runtime.Misc;
@@ -22,7 +22,7 @@ public class ParseInfo
     {
         protected internal readonly ProfilingATNSimulator atnSimulator;
 
-        public ParseInfo(ProfilingATNSimulator atnSimulator)
+        public ParseInfo([NotNull] ProfilingATNSimulator atnSimulator)
         {
             this.atnSimulator = atnSimulator;
         }
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/ParserATNSimulator.cs b/runtime/CSharp/Antlr4.Runtime/Atn/ParserATNSimulator.cs
index 7fa1e2b0..9fe59618 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/ParserATNSimulator.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/ParserATNSimulator.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using Antlr4.Runtime;
@@ -368,12 +368,12 @@ public class ParserATNSimulator : ATNSimulator
         private DFA dfa;
 
         /// <summary>Testing only!</summary>
-        public ParserATNSimulator(ATN atn)
+        public ParserATNSimulator([NotNull] ATN atn)
             : this(null, atn)
         {
         }
 
-        public ParserATNSimulator(Antlr4.Runtime.Parser parser, ATN atn)
+        public ParserATNSimulator([Nullable] Antlr4.Runtime.Parser parser, [NotNull] ATN atn)
             : base(atn)
         {
             this.parser = parser;
@@ -396,12 +396,12 @@ public override void Reset()
         {
         }
 
-        public virtual int AdaptivePredict(ITokenStream input, int decision, ParserRuleContext outerContext)
+        public virtual int AdaptivePredict([NotNull] ITokenStream input, int decision, [Nullable] ParserRuleContext outerContext)
         {
             return AdaptivePredict(input, decision, outerContext, false);
         }
 
-        public virtual int AdaptivePredict(ITokenStream input, int decision, ParserRuleContext outerContext, bool useContext)
+        public virtual int AdaptivePredict([NotNull] ITokenStream input, int decision, [Nullable] ParserRuleContext outerContext, bool useContext)
         {
             DFA dfa = atn.decisionToDFA[decision];
             System.Diagnostics.Debug.Assert(dfa != null);
@@ -463,7 +463,7 @@ public virtual int AdaptivePredict(ITokenStream input, int decision, ParserRuleC
             }
         }
 
-        protected internal virtual SimulatorState GetStartState(DFA dfa, ITokenStream input, ParserRuleContext outerContext, bool useContext)
+        protected internal virtual SimulatorState GetStartState([NotNull] DFA dfa, [NotNull] ITokenStream input, [NotNull] ParserRuleContext outerContext, bool useContext)
         {
             if (!useContext)
             {
@@ -522,7 +522,7 @@ protected internal virtual SimulatorState GetStartState(DFA dfa, ITokenStream in
             return new SimulatorState(outerContext, s0, useContext, remainingContext);
         }
 
-        protected internal virtual int ExecDFA(DFA dfa, ITokenStream input, int startIndex, SimulatorState state)
+        protected internal virtual int ExecDFA([NotNull] DFA dfa, [NotNull] ITokenStream input, int startIndex, [NotNull] SimulatorState state)
         {
             ParserRuleContext outerContext = state.outerContext;
             DFAState s = state.s0;
@@ -799,7 +799,7 @@ protected internal virtual bool IsAcceptState(DFAState state, bool useContext)
         /// conflict + preds
         /// TODO: greedy + those
         /// </remarks>
-        protected internal virtual int ExecATN(DFA dfa, ITokenStream input, int startIndex, SimulatorState initialState)
+        protected internal virtual int ExecATN([NotNull] DFA dfa, [NotNull] ITokenStream input, int startIndex, [NotNull] SimulatorState initialState)
         {
             ParserRuleContext outerContext = initialState.outerContext;
             bool useContext = initialState.useContext;
@@ -1008,7 +1008,7 @@ protected internal virtual int ExecATN(DFA dfa, ITokenStream input, int startInd
         /// <see cref="AdaptivePredict(Antlr4.Runtime.ITokenStream, int, Antlr4.Runtime.ParserRuleContext)"/>
         /// should report an error instead.
         /// </returns>
-        protected internal virtual int HandleNoViableAlt(ITokenStream input, int startIndex, SimulatorState previous)
+        protected internal virtual int HandleNoViableAlt([NotNull] ITokenStream input, int startIndex, [NotNull] SimulatorState previous)
         {
             if (previous.s0 != null)
             {
@@ -1042,10 +1042,10 @@ protected internal virtual int HandleNoViableAlt(ITokenStream input, int startIn
                             // filtering code below would be pointless
                             return alts.NextSetBit(0);
                         }
-                        /*
-                        * Try to find a configuration set that not only dipped into the outer
-                        * context, but also isn't eliminated by a predicate.
-                        */
+				/*
+				 * Try to find a configuration set that not only dipped into the outer
+				 * context, but also isn't eliminated by a predicate.
+				 */
                         ATNConfigSet filteredConfigs = new ATNConfigSet();
                         foreach (ATNConfig config_1 in previous.s0.configs)
                         {
@@ -1054,14 +1054,14 @@ protected internal virtual int HandleNoViableAlt(ITokenStream input, int startIn
                                 filteredConfigs.Add(config_1);
                             }
                         }
-                        /* The following code blocks are adapted from predicateDFAState with
-                        * the following key changes.
-                        *
-                        *  1. The code operates on an ATNConfigSet rather than a DFAState.
-                        *  2. Predicates are collected for all alternatives represented in
-                        *     filteredConfigs, rather than restricting the evaluation to
-                        *     conflicting and/or unique configurations.
-                        */
+				/* The following code blocks are adapted from predicateDFAState with
+				 * the following key changes.
+				 *
+				 *  1. The code operates on an ATNConfigSet rather than a DFAState.
+				 *  2. Predicates are collected for all alternatives represented in
+				 *     filteredConfigs, rather than restricting the evaluation to
+				 *     conflicting and/or unique configurations.
+				 */
                         SemanticContext[] altToPred = GetPredsForAmbigAlts(alts, filteredConfigs, maxAlt);
                         if (altToPred != null)
                         {
@@ -1155,7 +1155,7 @@ protected internal virtual SimulatorState ComputeReachSet(DFA dfa, SimulatorStat
         /// already cached
         /// </returns>
         [Nullable]
-        protected internal virtual DFAState GetExistingTargetState(DFAState s, int t)
+        protected internal virtual DFAState GetExistingTargetState([NotNull] DFAState s, int t)
         {
             return s.GetTarget(t);
         }
@@ -1181,7 +1181,7 @@ protected internal virtual DFAState GetExistingTargetState(DFAState s, int t)
         /// .
         /// </returns>
         [NotNull]
-        protected internal virtual Tuple<DFAState, ParserRuleContext> ComputeTargetState(DFA dfa, DFAState s, ParserRuleContext remainingGlobalContext, int t, bool useContext, PredictionContextCache contextCache)
+        protected internal virtual Tuple<DFAState, ParserRuleContext> ComputeTargetState([NotNull] DFA dfa, [NotNull] DFAState s, ParserRuleContext remainingGlobalContext, int t, bool useContext, PredictionContextCache contextCache)
         {
             IList<ATNConfig> closureConfigs = new List<ATNConfig>(s.configs);
             List<int> contextElements = null;
@@ -1195,16 +1195,16 @@ protected internal virtual Tuple<DFAState, ParserRuleContext> ComputeTargetState
                     reach.IsOutermostConfigSet = true;
                 }
                 ATNConfigSet reachIntermediate = new ATNConfigSet();
-                /* Configurations already in a rule stop state indicate reaching the end
-                * of the decision rule (local context) or end of the start rule (full
-                * context). Once reached, these configurations are never updated by a
-                * closure operation, so they are handled separately for the performance
-                * advantage of having a smaller intermediate set when calling closure.
-                *
-                * For full-context reach operations, separate handling is required to
-                * ensure that the alternative matching the longest overall sequence is
-                * chosen when multiple such configurations can match the input.
-                */
+			/* Configurations already in a rule stop state indicate reaching the end
+			 * of the decision rule (local context) or end of the start rule (full
+			 * context). Once reached, these configurations are never updated by a
+			 * closure operation, so they are handled separately for the performance
+			 * advantage of having a smaller intermediate set when calling closure.
+			 *
+			 * For full-context reach operations, separate handling is required to
+			 * ensure that the alternative matching the longest overall sequence is
+			 * chosen when multiple such configurations can match the input.
+			 */
                 IList<ATNConfig> skippedStopStates = null;
                 foreach (ATNConfig c in closureConfigs)
                 {
@@ -1233,52 +1233,52 @@ protected internal virtual Tuple<DFAState, ParserRuleContext> ComputeTargetState
                         }
                     }
                 }
-                /* This block optimizes the reach operation for intermediate sets which
-                * trivially indicate a termination state for the overall
-                * adaptivePredict operation.
-                *
-                * The conditions assume that intermediate
-                * contains all configurations relevant to the reach set, but this
-                * condition is not true when one or more configurations have been
-                * withheld in skippedStopStates, or when the current symbol is EOF.
-                */
+			/* This block optimizes the reach operation for intermediate sets which
+			 * trivially indicate a termination state for the overall
+			 * adaptivePredict operation.
+			 *
+			 * The conditions assume that intermediate
+			 * contains all configurations relevant to the reach set, but this
+			 * condition is not true when one or more configurations have been
+			 * withheld in skippedStopStates, or when the current symbol is EOF.
+			 */
                 if (optimize_unique_closure && skippedStopStates == null && t != TokenConstants.Eof && reachIntermediate.UniqueAlt != ATN.InvalidAltNumber)
                 {
                     reachIntermediate.IsOutermostConfigSet = reach.IsOutermostConfigSet;
                     reach = reachIntermediate;
                     break;
                 }
-                /* If the reach set could not be trivially determined, perform a closure
-                * operation on the intermediate set to compute its initial value.
-                */
+			/* If the reach set could not be trivially determined, perform a closure
+			 * operation on the intermediate set to compute its initial value.
+			 */
                 bool collectPredicates = false;
                 bool treatEofAsEpsilon = t == TokenConstants.Eof;
                 Closure(reachIntermediate, reach, collectPredicates, hasMoreContext, contextCache, treatEofAsEpsilon);
                 stepIntoGlobal = reach.DipsIntoOuterContext;
                 if (t == IntStreamConstants.Eof)
                 {
-                    /* After consuming EOF no additional input is possible, so we are
-                    * only interested in configurations which reached the end of the
-                    * decision rule (local context) or end of the start rule (full
-                    * context). Update reach to contain only these configurations. This
-                    * handles both explicit EOF transitions in the grammar and implicit
-                    * EOF transitions following the end of the decision or start rule.
-                    *
-                    * This is handled before the configurations in skippedStopStates,
-                    * because any configurations potentially added from that list are
-                    * already guaranteed to meet this condition whether or not it's
-                    * required.
-                    */
+				/* After consuming EOF no additional input is possible, so we are
+				 * only interested in configurations which reached the end of the
+				 * decision rule (local context) or end of the start rule (full
+				 * context). Update reach to contain only these configurations. This
+				 * handles both explicit EOF transitions in the grammar and implicit
+				 * EOF transitions following the end of the decision or start rule.
+				 *
+				 * This is handled before the configurations in skippedStopStates,
+				 * because any configurations potentially added from that list are
+				 * already guaranteed to meet this condition whether or not it's
+				 * required.
+				 */
                     reach = RemoveAllConfigsNotInRuleStopState(reach, contextCache);
                 }
-                /* If skippedStopStates is not null, then it contains at least one
-                * configuration. For full-context reach operations, these
-                * configurations reached the end of the start rule, in which case we
-                * only add them back to reach if no configuration during the current
-                * closure operation reached such a state. This ensures adaptivePredict
-                * chooses an alternative matching the longest overall sequence when
-                * multiple alternatives are viable.
-                */
+			/* If skippedStopStates is not null, then it contains at least one
+			 * configuration. For full-context reach operations, these
+			 * configurations reached the end of the start rule, in which case we
+			 * only add them back to reach if no configuration during the current
+			 * closure operation reached such a state. This ensures adaptivePredict
+			 * chooses an alternative matching the longest overall sequence when
+			 * multiple alternatives are viable.
+			 */
                 if (skippedStopStates != null && (!useContext || !Antlr4.Runtime.Atn.PredictionMode.HasConfigInRuleStopState(reach)))
                 {
                     System.Diagnostics.Debug.Assert(!skippedStopStates.IsEmpty());
@@ -1355,7 +1355,7 @@ protected internal virtual Tuple<DFAState, ParserRuleContext> ComputeTargetState
         /// which are in a rule stop state
         /// </returns>
         [NotNull]
-        protected internal virtual ATNConfigSet RemoveAllConfigsNotInRuleStopState(ATNConfigSet configs, PredictionContextCache contextCache)
+        protected internal virtual ATNConfigSet RemoveAllConfigsNotInRuleStopState([NotNull] ATNConfigSet configs, PredictionContextCache contextCache)
         {
             if (Antlr4.Runtime.Atn.PredictionMode.AllConfigsInRuleStopStates(configs))
             {
@@ -1479,12 +1479,12 @@ protected internal virtual SimulatorState ComputeStartState(DFA dfa, ParserRuleC
                         }
                         else
                         {
-                            /* If this is a precedence DFA, we use applyPrecedenceFilter
-                            * to convert the computed start state to a precedence start
-                            * state. We then use DFA.setPrecedenceStartState to set the
-                            * appropriate start state for the precedence level rather
-                            * than simply setting DFA.s0.
-                            */
+					/* If this is a precedence DFA, we use applyPrecedenceFilter
+					 * to convert the computed start state to a precedence start
+					 * state. We then use DFA.setPrecedenceStartState to set the
+					 * appropriate start state for the precedence level rather
+					 * than simply setting DFA.s0.
+					 */
                             configs = ApplyPrecedenceFilter(configs, globalContext, contextCache);
                             next = AddDFAState(dfa, configs, contextCache);
                             dfa.SetPrecedenceStartState(parser.Precedence, useContext, next);
@@ -1607,7 +1607,7 @@ protected internal virtual SimulatorState ComputeStartState(DFA dfa, ParserRuleC
         /// ).
         /// </returns>
         [NotNull]
-        protected internal virtual ATNConfigSet ApplyPrecedenceFilter(ATNConfigSet configs, ParserRuleContext globalContext, PredictionContextCache contextCache)
+        protected internal virtual ATNConfigSet ApplyPrecedenceFilter([NotNull] ATNConfigSet configs, ParserRuleContext globalContext, PredictionContextCache contextCache)
         {
             IDictionary<int, PredictionContext> statesFromAlt1 = new Dictionary<int, PredictionContext>();
             ATNConfigSet configSet = new ATNConfigSet();
@@ -1643,10 +1643,10 @@ protected internal virtual ATNConfigSet ApplyPrecedenceFilter(ATNConfigSet confi
                 }
                 if (!config_1.PrecedenceFilterSuppressed)
                 {
-                    /* In the future, this elimination step could be updated to also
-                    * filter the prediction context for alternatives predicting alt>1
-                    * (basically a graph subtraction algorithm).
-                    */
+				/* In the future, this elimination step could be updated to also
+				 * filter the prediction context for alternatives predicting alt>1
+				 * (basically a graph subtraction algorithm).
+				 */
                     PredictionContext context = statesFromAlt1[config_1.State.stateNumber];
                     if (context != null && context.Equals(config_1.Context))
                     {
@@ -1660,7 +1660,7 @@ protected internal virtual ATNConfigSet ApplyPrecedenceFilter(ATNConfigSet confi
         }
 
         [Nullable]
-        protected internal virtual ATNState GetReachableTarget(ATNConfig source, Transition trans, int ttype)
+        protected internal virtual ATNState GetReachableTarget([NotNull] ATNConfig source, [NotNull] Transition trans, int ttype)
         {
             if (trans.Matches(ttype, 0, atn.maxTokenType))
             {
@@ -1686,20 +1686,20 @@ protected internal virtual DFAState.PredPrediction[] PredicateDFAState(DFAState
             return predPredictions;
         }
 
-        protected internal virtual SemanticContext[] GetPredsForAmbigAlts(BitSet ambigAlts, ATNConfigSet configs, int nalts)
+        protected internal virtual SemanticContext[] GetPredsForAmbigAlts([NotNull] BitSet ambigAlts, [NotNull] ATNConfigSet configs, int nalts)
         {
             // REACH=[1|1|[]|0:0, 1|2|[]|0:1]
-            /* altToPred starts as an array of all null contexts. The entry at index i
-            * corresponds to alternative i. altToPred[i] may have one of three values:
-            *   1. null: no ATNConfig c is found such that c.alt==i
-            *   2. SemanticContext.NONE: At least one ATNConfig c exists such that
-            *      c.alt==i and c.semanticContext==SemanticContext.NONE. In other words,
-            *      alt i has at least one unpredicated config.
-            *   3. Non-NONE Semantic Context: There exists at least one, and for all
-            *      ATNConfig c such that c.alt==i, c.semanticContext!=SemanticContext.NONE.
-            *
-            * From this, it is clear that NONE||anything==NONE.
-            */
+		/* altToPred starts as an array of all null contexts. The entry at index i
+		 * corresponds to alternative i. altToPred[i] may have one of three values:
+		 *   1. null: no ATNConfig c is found such that c.alt==i
+		 *   2. SemanticContext.NONE: At least one ATNConfig c exists such that
+		 *      c.alt==i and c.semanticContext==SemanticContext.NONE. In other words,
+		 *      alt i has at least one unpredicated config.
+		 *   3. Non-NONE Semantic Context: There exists at least one, and for all
+		 *      ATNConfig c such that c.alt==i, c.semanticContext!=SemanticContext.NONE.
+		 *
+		 * From this, it is clear that NONE||anything==NONE.
+		 */
             SemanticContext[] altToPred = new SemanticContext[nalts + 1];
             int n = altToPred.Length;
             foreach (ATNConfig c in configs)
@@ -1778,7 +1778,7 @@ protected internal virtual DFAState.PredPrediction[] GetPredicatePredictions(Bit
         /// predicate indicates an alt containing an
         /// unpredicated config which behaves as "always true."
         /// </remarks>
-        protected internal virtual BitSet EvalSemanticContext(DFAState.PredPrediction[] predPredictions, ParserRuleContext outerContext, bool complete)
+        protected internal virtual BitSet EvalSemanticContext([NotNull] DFAState.PredPrediction[] predPredictions, ParserRuleContext outerContext, bool complete)
         {
             BitSet predictions = new BitSet();
             foreach (DFAState.PredPrediction pair in predPredictions)
@@ -1846,18 +1846,18 @@ protected internal virtual BitSet EvalSemanticContext(DFAState.PredPrediction[]
         /// <paramref name="pred"/>
         /// </param>
         /// <since>4.3</since>
-        protected internal virtual bool EvalSemanticContext(SemanticContext pred, ParserRuleContext parserCallStack, int alt)
+        protected internal virtual bool EvalSemanticContext([NotNull] SemanticContext pred, ParserRuleContext parserCallStack, int alt)
         {
             return pred.Eval(parser, parserCallStack);
         }
 
-        /* TODO: If we are doing predicates, there is no point in pursuing
-        closure operations if we reach a DFA state that uniquely predicts
-        alternative. We will not be caching that DFA state and it is a
-        waste to pursue the closure. Might have to advance when we do
-        ambig detection thought :(
-        */
-        protected internal virtual void Closure(ATNConfigSet sourceConfigs, ATNConfigSet configs, bool collectPredicates, bool hasMoreContext, PredictionContextCache contextCache, bool treatEofAsEpsilon)
+	/* TODO: If we are doing predicates, there is no point in pursuing
+		 closure operations if we reach a DFA state that uniquely predicts
+		 alternative. We will not be caching that DFA state and it is a
+		 waste to pursue the closure. Might have to advance when we do
+		 ambig detection thought :(
+		  */
+        protected internal virtual void Closure(ATNConfigSet sourceConfigs, [NotNull] ATNConfigSet configs, bool collectPredicates, bool hasMoreContext, [Nullable] PredictionContextCache contextCache, bool treatEofAsEpsilon)
         {
             if (contextCache == null)
             {
@@ -1876,7 +1876,7 @@ protected internal virtual void Closure(ATNConfigSet sourceConfigs, ATNConfigSet
             }
         }
 
-        protected internal virtual void Closure(ATNConfig config, ATNConfigSet configs, ATNConfigSet intermediate, HashSet<ATNConfig> closureBusy, bool collectPredicates, bool hasMoreContexts, PredictionContextCache contextCache, int depth, bool treatEofAsEpsilon)
+        protected internal virtual void Closure([NotNull] ATNConfig config, [NotNull] ATNConfigSet configs, [Nullable] ATNConfigSet intermediate, [NotNull] HashSet<ATNConfig> closureBusy, bool collectPredicates, bool hasMoreContexts, [NotNull] PredictionContextCache contextCache, int depth, bool treatEofAsEpsilon)
         {
             if (config.State is RuleStopState)
             {
@@ -2053,7 +2053,7 @@ public virtual string GetRuleName(int index)
         }
 
         [Nullable]
-        protected internal virtual ATNConfig GetEpsilonTarget(ATNConfig config, Transition t, bool collectPredicates, bool inContext, PredictionContextCache contextCache, bool treatEofAsEpsilon)
+        protected internal virtual ATNConfig GetEpsilonTarget([NotNull] ATNConfig config, [NotNull] Transition t, bool collectPredicates, bool inContext, PredictionContextCache contextCache, bool treatEofAsEpsilon)
         {
             switch (t.TransitionType)
             {
@@ -2106,13 +2106,13 @@ protected internal virtual ATNConfig GetEpsilonTarget(ATNConfig config, Transiti
         }
 
         [NotNull]
-        protected internal virtual ATNConfig ActionTransition(ATNConfig config, Antlr4.Runtime.Atn.ActionTransition t)
+        protected internal virtual ATNConfig ActionTransition([NotNull] ATNConfig config, [NotNull] Antlr4.Runtime.Atn.ActionTransition t)
         {
             return config.Transform(t.target, false);
         }
 
         [Nullable]
-        protected internal virtual ATNConfig PrecedenceTransition(ATNConfig config, PrecedencePredicateTransition pt, bool collectPredicates, bool inContext)
+        protected internal virtual ATNConfig PrecedenceTransition([NotNull] ATNConfig config, [NotNull] PrecedencePredicateTransition pt, bool collectPredicates, bool inContext)
         {
             ATNConfig c;
             if (collectPredicates && inContext)
@@ -2128,7 +2128,7 @@ protected internal virtual ATNConfig PrecedenceTransition(ATNConfig config, Prec
         }
 
         [Nullable]
-        protected internal virtual ATNConfig PredTransition(ATNConfig config, PredicateTransition pt, bool collectPredicates, bool inContext)
+        protected internal virtual ATNConfig PredTransition([NotNull] ATNConfig config, [NotNull] PredicateTransition pt, bool collectPredicates, bool inContext)
         {
             ATNConfig c;
             if (collectPredicates && (!pt.isCtxDependent || (pt.isCtxDependent && inContext)))
@@ -2144,7 +2144,7 @@ protected internal virtual ATNConfig PredTransition(ATNConfig config, PredicateT
         }
 
         [NotNull]
-        protected internal virtual ATNConfig RuleTransition(ATNConfig config, Antlr4.Runtime.Atn.RuleTransition t, PredictionContextCache contextCache)
+        protected internal virtual ATNConfig RuleTransition([NotNull] ATNConfig config, [NotNull] Antlr4.Runtime.Atn.RuleTransition t, [Nullable] PredictionContextCache contextCache)
         {
             ATNState returnState = t.followState;
             PredictionContext newContext;
@@ -2190,7 +2190,7 @@ public int Compare(ATNConfig o1, ATNConfig o2)
 
         private static readonly IComparer<ATNConfig> StateAltSortComparator = new _IComparer_1991();
 
-        private ConflictInfo IsConflicted(ATNConfigSet configset, PredictionContextCache contextCache)
+        private ConflictInfo IsConflicted([NotNull] ATNConfigSet configset, PredictionContextCache contextCache)
         {
             if (configset.UniqueAlt != ATN.InvalidAltNumber || configset.Count <= 1)
             {
@@ -2202,14 +2202,14 @@ private ConflictInfo IsConflicted(ATNConfigSet configset, PredictionContextCache
             BitSet alts = new BitSet();
             int minAlt = configs[0].Alt;
             alts.Set(minAlt);
-            /* Quick checks come first (single pass, no context joining):
-            *  1. Make sure first config in the sorted list predicts the minimum
-            *     represented alternative.
-            *  2. Make sure every represented state has at least one configuration
-            *     which predicts the minimum represented alternative.
-            *  3. (exact only) make sure every represented state has at least one
-            *     configuration which predicts each represented alternative.
-            */
+		/* Quick checks come first (single pass, no context joining):
+		 *  1. Make sure first config in the sorted list predicts the minimum
+		 *     represented alternative.
+		 *  2. Make sure every represented state has at least one configuration
+		 *     which predicts the minimum represented alternative.
+		 *  3. (exact only) make sure every represented state has at least one
+		 *     configuration which predicts each represented alternative.
+		 */
             // quick check 1 & 2 => if we assume #1 holds and check #2 against the
             // minAlt from the first state, #2 will fail if the assumption was
             // incorrect
@@ -2381,7 +2381,7 @@ public virtual string GetLookaheadName(ITokenStream input)
             return GetTokenName(input.La(1));
         }
 
-        public virtual void DumpDeadEndConfigs(NoViableAltException nvae)
+        public virtual void DumpDeadEndConfigs([NotNull] NoViableAltException nvae)
         {
             System.Console.Error.WriteLine("dead end configs: ");
             foreach (ATNConfig c in nvae.DeadEndConfigs)
@@ -2410,12 +2410,12 @@ public virtual void DumpDeadEndConfigs(NoViableAltException nvae)
         }
 
         [NotNull]
-        protected internal virtual NoViableAltException NoViableAlt(ITokenStream input, ParserRuleContext outerContext, ATNConfigSet configs, int startIndex)
+        protected internal virtual NoViableAltException NoViableAlt([NotNull] ITokenStream input, [NotNull] ParserRuleContext outerContext, [NotNull] ATNConfigSet configs, int startIndex)
         {
             return new NoViableAltException(parser, input, input.Get(startIndex), input.Lt(1), configs, outerContext);
         }
 
-        protected internal virtual int GetUniqueAlt(IEnumerable<ATNConfig> configs)
+        protected internal virtual int GetUniqueAlt([NotNull] IEnumerable<ATNConfig> configs)
         {
             int alt = ATN.InvalidAltNumber;
             foreach (ATNConfig c in configs)
@@ -2436,7 +2436,7 @@ protected internal virtual int GetUniqueAlt(IEnumerable<ATNConfig> configs)
             return alt;
         }
 
-        protected internal virtual bool ConfigWithAltAtStopState(IEnumerable<ATNConfig> configs, int alt)
+        protected internal virtual bool ConfigWithAltAtStopState([NotNull] IEnumerable<ATNConfig> configs, int alt)
         {
             foreach (ATNConfig c in configs)
             {
@@ -2452,7 +2452,7 @@ protected internal virtual bool ConfigWithAltAtStopState(IEnumerable<ATNConfig>
         }
 
         [NotNull]
-        protected internal virtual DFAState AddDFAEdge(DFA dfa, DFAState fromState, int t, List<int> contextTransitions, ATNConfigSet toConfigs, PredictionContextCache contextCache)
+        protected internal virtual DFAState AddDFAEdge([NotNull] DFA dfa, [NotNull] DFAState fromState, int t, List<int> contextTransitions, [NotNull] ATNConfigSet toConfigs, PredictionContextCache contextCache)
         {
             System.Diagnostics.Debug.Assert(contextTransitions == null || contextTransitions.IsEmpty() || dfa.IsContextSensitive);
             DFAState from = fromState;
@@ -2486,7 +2486,7 @@ protected internal virtual DFAState AddDFAEdge(DFA dfa, DFAState fromState, int
             return to;
         }
 
-        protected internal virtual void AddDFAEdge(DFAState p, int t, DFAState q)
+        protected internal virtual void AddDFAEdge([Nullable] DFAState p, int t, [Nullable] DFAState q)
         {
             if (p != null)
             {
@@ -2496,7 +2496,7 @@ protected internal virtual void AddDFAEdge(DFAState p, int t, DFAState q)
 
         /// <summary>See comment on LexerInterpreter.addDFAState.</summary>
         [NotNull]
-        protected internal virtual DFAState AddDFAContextState(DFA dfa, ATNConfigSet configs, int returnContext, PredictionContextCache contextCache)
+        protected internal virtual DFAState AddDFAContextState([NotNull] DFA dfa, [NotNull] ATNConfigSet configs, int returnContext, PredictionContextCache contextCache)
         {
             if (returnContext != PredictionContext.EmptyFullStateKey)
             {
@@ -2518,7 +2518,7 @@ protected internal virtual DFAState AddDFAContextState(DFA dfa, ATNConfigSet con
 
         /// <summary>See comment on LexerInterpreter.addDFAState.</summary>
         [NotNull]
-        protected internal virtual DFAState AddDFAState(DFA dfa, ATNConfigSet configs, PredictionContextCache contextCache)
+        protected internal virtual DFAState AddDFAState([NotNull] DFA dfa, [NotNull] ATNConfigSet configs, PredictionContextCache contextCache)
         {
             bool enableDfa = enable_global_context_dfa || !configs.IsOutermostConfigSet;
             if (enableDfa)
@@ -2572,12 +2572,12 @@ protected internal virtual DFAState AddDFAState(DFA dfa, ATNConfigSet configs, P
         }
 
         [NotNull]
-        protected internal virtual DFAState CreateDFAState(DFA dfa, ATNConfigSet configs)
+        protected internal virtual DFAState CreateDFAState([NotNull] DFA dfa, [NotNull] ATNConfigSet configs)
         {
             return new DFAState(dfa, configs);
         }
 
-        protected internal virtual void ReportAttemptingFullContext(DFA dfa, BitSet conflictingAlts, SimulatorState conflictState, int startIndex, int stopIndex)
+        protected internal virtual void ReportAttemptingFullContext([NotNull] DFA dfa, [Nullable] BitSet conflictingAlts, [NotNull] SimulatorState conflictState, int startIndex, int stopIndex)
         {
             if (debug || retry_debug)
             {
@@ -2590,7 +2590,7 @@ protected internal virtual void ReportAttemptingFullContext(DFA dfa, BitSet conf
             }
         }
 
-        protected internal virtual void ReportContextSensitivity(DFA dfa, int prediction, SimulatorState acceptState, int startIndex, int stopIndex)
+        protected internal virtual void ReportContextSensitivity([NotNull] DFA dfa, int prediction, [NotNull] SimulatorState acceptState, int startIndex, int stopIndex)
         {
             if (debug || retry_debug)
             {
@@ -2604,7 +2604,7 @@ protected internal virtual void ReportContextSensitivity(DFA dfa, int prediction
         }
 
         /// <summary>If context sensitive parsing, we know it's ambiguity not conflict</summary>
-        protected internal virtual void ReportAmbiguity(DFA dfa, DFAState D, int startIndex, int stopIndex, bool exact, BitSet ambigAlts, ATNConfigSet configs)
+        protected internal virtual void ReportAmbiguity([NotNull] DFA dfa, DFAState D, int startIndex, int stopIndex, bool exact, [NotNull] BitSet ambigAlts, [NotNull] ATNConfigSet configs)
         {
             // the DFA state from execATN() that had SLL conflicts
             // configs that LL not SLL considered conflicting
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/PlusBlockStartState.cs b/runtime/CSharp/Antlr4.Runtime/Atn/PlusBlockStartState.cs
index 868dd8cd..438070f6 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/PlusBlockStartState.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/PlusBlockStartState.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/PlusLoopbackState.cs b/runtime/CSharp/Antlr4.Runtime/Atn/PlusLoopbackState.cs
index 006743c7..35b22ed5 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/PlusLoopbackState.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/PlusLoopbackState.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/PrecedencePredicateTransition.cs b/runtime/CSharp/Antlr4.Runtime/Atn/PrecedencePredicateTransition.cs
index 2e6ad6ed..8f74c5bf 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/PrecedencePredicateTransition.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/PrecedencePredicateTransition.cs
@@ -2,10 +2,11 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
@@ -15,7 +16,7 @@ public sealed class PrecedencePredicateTransition : AbstractPredicateTransition
     {
         public readonly int precedence;
 
-        public PrecedencePredicateTransition(ATNState target, int precedence)
+        public PrecedencePredicateTransition([NotNull] ATNState target, int precedence)
             : base(target)
         {
             this.precedence = precedence;
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/PredicateEvalInfo.cs b/runtime/CSharp/Antlr4.Runtime/Atn/PredicateEvalInfo.cs
index ee8e83c6..692b7ebc 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/PredicateEvalInfo.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/PredicateEvalInfo.cs
@@ -2,11 +2,12 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
+using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
@@ -68,7 +69,7 @@ public class PredicateEvalInfo : DecisionEventInfo
         /// </param>
         /// <seealso cref="ParserATNSimulator.EvalSemanticContext(SemanticContext, Antlr4.Runtime.ParserRuleContext, int)"/>
         /// <seealso cref="SemanticContext.Eval(Antlr4.Runtime.Recognizer{Symbol, ATNInterpreter}, Antlr4.Runtime.RuleContext)"/>
-        public PredicateEvalInfo(SimulatorState state, int decision, ITokenStream input, int startIndex, int stopIndex, SemanticContext semctx, bool evalResult, int predictedAlt)
+        public PredicateEvalInfo([NotNull] SimulatorState state, int decision, [NotNull] ITokenStream input, int startIndex, int stopIndex, [NotNull] SemanticContext semctx, bool evalResult, int predictedAlt)
             : base(decision, state, input, startIndex, stopIndex, state.useContext)
         {
             this.semctx = semctx;
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/PredicateTransition.cs b/runtime/CSharp/Antlr4.Runtime/Atn/PredicateTransition.cs
index 0387a8a0..40f4a7f7 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/PredicateTransition.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/PredicateTransition.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
@@ -30,7 +30,7 @@ public sealed class PredicateTransition : AbstractPredicateTransition
 
         public readonly bool isCtxDependent;
 
-        public PredicateTransition(ATNState target, int ruleIndex, int predIndex, bool isCtxDependent)
+        public PredicateTransition([NotNull] ATNState target, int ruleIndex, int predIndex, bool isCtxDependent)
             : base(target)
         {
             // e.g., $i ref in pred
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/PredictionContext.cs b/runtime/CSharp/Antlr4.Runtime/Atn/PredictionContext.cs
index 067b2066..0e2e8b28 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/PredictionContext.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/PredictionContext.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.Text;
@@ -122,12 +122,12 @@ public abstract int Size
 
         protected internal abstract Antlr4.Runtime.Atn.PredictionContext RemoveEmptyContext();
 
-        public static Antlr4.Runtime.Atn.PredictionContext FromRuleContext(ATN atn, RuleContext outerContext)
+        public static Antlr4.Runtime.Atn.PredictionContext FromRuleContext([NotNull] ATN atn, [NotNull] RuleContext outerContext)
         {
             return FromRuleContext(atn, outerContext, true);
         }
 
-        public static Antlr4.Runtime.Atn.PredictionContext FromRuleContext(ATN atn, RuleContext outerContext, bool fullContext)
+        public static Antlr4.Runtime.Atn.PredictionContext FromRuleContext([NotNull] ATN atn, [NotNull] RuleContext outerContext, bool fullContext)
         {
             if (outerContext.IsEmpty)
             {
@@ -162,8 +162,8 @@ public static Antlr4.Runtime.Atn.PredictionContext Join(Antlr4.Runtime.Atn.Predi
             return Join(context0, context1, PredictionContextCache.Uncached);
         }
 
-        /*package*/
-        internal static Antlr4.Runtime.Atn.PredictionContext Join(Antlr4.Runtime.Atn.PredictionContext context0, Antlr4.Runtime.Atn.PredictionContext context1, PredictionContextCache contextCache)
+	/*package*/
+        internal static Antlr4.Runtime.Atn.PredictionContext Join([NotNull] Antlr4.Runtime.Atn.PredictionContext context0, [NotNull] Antlr4.Runtime.Atn.PredictionContext context1, [NotNull] PredictionContextCache contextCache)
         {
             if (context0 == context1)
             {
@@ -294,7 +294,7 @@ public static bool IsEmptyLocal(Antlr4.Runtime.Atn.PredictionContext context)
             return context == EmptyLocal;
         }
 
-        public static Antlr4.Runtime.Atn.PredictionContext GetCachedContext(Antlr4.Runtime.Atn.PredictionContext context, ConcurrentDictionary<Antlr4.Runtime.Atn.PredictionContext, Antlr4.Runtime.Atn.PredictionContext> contextCache, PredictionContext.IdentityHashMap visited)
+        public static Antlr4.Runtime.Atn.PredictionContext GetCachedContext([NotNull] Antlr4.Runtime.Atn.PredictionContext context, [NotNull] ConcurrentDictionary<Antlr4.Runtime.Atn.PredictionContext, Antlr4.Runtime.Atn.PredictionContext> contextCache, [NotNull] PredictionContext.IdentityHashMap visited)
         {
             if (context.IsEmpty)
             {
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/PredictionContextCache.cs b/runtime/CSharp/Antlr4.Runtime/Atn/PredictionContextCache.cs
index b0a8d865..5a919e80 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/PredictionContextCache.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/PredictionContextCache.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using Antlr4.Runtime.Sharpen;
 
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/PredictionMode.cs b/runtime/CSharp/Antlr4.Runtime/Atn/PredictionMode.cs
index 49d86d4e..a9e59cdd 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/PredictionMode.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/PredictionMode.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -237,13 +237,13 @@ public override bool Equals(ATNConfig a, ATNConfig b)
         /// <see cref="ATNConfigSet"/>
         /// will merge everything ignoring predicates.</p>
         /// </remarks>
-        public static bool HasSLLConflictTerminatingPrediction(PredictionMode mode, ATNConfigSet configs)
+        public static bool HasSLLConflictTerminatingPrediction(PredictionMode mode, [NotNull] ATNConfigSet configs)
         {
-            /* Configs in rule stop states indicate reaching the end of the decision
-            * rule (local context) or end of start rule (full context). If all
-            * configs meet this condition, then none of the configurations is able
-            * to match additional input so we terminate prediction.
-            */
+		/* Configs in rule stop states indicate reaching the end of the decision
+		 * rule (local context) or end of start rule (full context). If all
+		 * configs meet this condition, then none of the configurations is able
+		 * to match additional input so we terminate prediction.
+		 */
             if (AllConfigsInRuleStopStates(configs))
             {
                 return true;
@@ -325,7 +325,7 @@ public static bool HasConfigInRuleStopState(IEnumerable<ATNConfig> configs)
         /// , otherwise
         /// <see langword="false"/>
         /// </returns>
-        public static bool AllConfigsInRuleStopStates(IEnumerable<ATNConfig> configs)
+        public static bool AllConfigsInRuleStopStates([NotNull] IEnumerable<ATNConfig> configs)
         {
             foreach (ATNConfig config in configs)
             {
@@ -627,7 +627,7 @@ public static bool AllConfigsInRuleStopStates(IEnumerable<ATNConfig> configs)
         /// 
         /// {1,2},{1,2}}}, etc...</p>
         /// </remarks>
-        public static int ResolvesToJustOneViableAlt(IEnumerable<BitSet> altsets)
+        public static int ResolvesToJustOneViableAlt([NotNull] IEnumerable<BitSet> altsets)
         {
             return GetSingleViableAlt(altsets);
         }
@@ -651,7 +651,7 @@ public static int ResolvesToJustOneViableAlt(IEnumerable<BitSet> altsets)
         /// &gt; 1, otherwise
         /// <see langword="false"/>
         /// </returns>
-        public static bool AllSubsetsConflict(IEnumerable<BitSet> altsets)
+        public static bool AllSubsetsConflict([NotNull] IEnumerable<BitSet> altsets)
         {
             return !HasNonConflictingAltSet(altsets);
         }
@@ -675,7 +675,7 @@ public static bool AllSubsetsConflict(IEnumerable<BitSet> altsets)
         /// 1, otherwise
         /// <see langword="false"/>
         /// </returns>
-        public static bool HasNonConflictingAltSet(IEnumerable<BitSet> altsets)
+        public static bool HasNonConflictingAltSet([NotNull] IEnumerable<BitSet> altsets)
         {
             foreach (BitSet alts in altsets)
             {
@@ -706,7 +706,7 @@ public static bool HasNonConflictingAltSet(IEnumerable<BitSet> altsets)
         /// &gt; 1, otherwise
         /// <see langword="false"/>
         /// </returns>
-        public static bool HasConflictingAltSet(IEnumerable<BitSet> altsets)
+        public static bool HasConflictingAltSet([NotNull] IEnumerable<BitSet> altsets)
         {
             foreach (BitSet alts in altsets)
             {
@@ -733,7 +733,7 @@ public static bool HasConflictingAltSet(IEnumerable<BitSet> altsets)
         /// others, otherwise
         /// <see langword="false"/>
         /// </returns>
-        public static bool AllSubsetsEqual(IEnumerable<BitSet> altsets)
+        public static bool AllSubsetsEqual([NotNull] IEnumerable<BitSet> altsets)
         {
             IEnumerator<BitSet> it = altsets.GetEnumerator();
             BitSet first = it.Next();
@@ -756,7 +756,7 @@ public static bool AllSubsetsEqual(IEnumerable<BitSet> altsets)
         /// .
         /// </summary>
         /// <param name="altsets">a collection of alternative subsets</param>
-        public static int GetUniqueAlt(IEnumerable<BitSet> altsets)
+        public static int GetUniqueAlt([NotNull] IEnumerable<BitSet> altsets)
         {
             BitSet all = GetAlts(altsets);
             if (all.Cardinality() == 1)
@@ -783,7 +783,7 @@ public static int GetUniqueAlt(IEnumerable<BitSet> altsets)
         /// the set of represented alternatives in
         /// <paramref name="altsets"/>
         /// </returns>
-        public static BitSet GetAlts(IEnumerable<BitSet> altsets)
+        public static BitSet GetAlts([NotNull] IEnumerable<BitSet> altsets)
         {
             BitSet all = new BitSet();
             foreach (BitSet alts in altsets)
@@ -796,7 +796,7 @@ public static BitSet GetAlts(IEnumerable<BitSet> altsets)
         /// <summary>Get union of all alts from configs.</summary>
         /// <since>4.5</since>
         [NotNull]
-        public static BitSet GetAlts(ATNConfigSet configs)
+        public static BitSet GetAlts([NotNull] ATNConfigSet configs)
         {
             BitSet alts = new BitSet();
             foreach (ATNConfig config in configs)
@@ -822,7 +822,7 @@ public static BitSet GetAlts(ATNConfigSet configs)
         /// </pre>
         /// </remarks>
         [NotNull]
-        public static ICollection<BitSet> GetConflictingAltSubsets(IEnumerable<ATNConfig> configs)
+        public static ICollection<BitSet> GetConflictingAltSubsets([NotNull] IEnumerable<ATNConfig> configs)
         {
             PredictionMode.AltAndContextMap configToAlts = new PredictionMode.AltAndContextMap();
             foreach (ATNConfig c in configs)
@@ -854,7 +854,7 @@ public static ICollection<BitSet> GetConflictingAltSubsets(IEnumerable<ATNConfig
         /// </pre>
         /// </remarks>
         [NotNull]
-        public static IDictionary<ATNState, BitSet> GetStateToAltMap(IEnumerable<ATNConfig> configs)
+        public static IDictionary<ATNState, BitSet> GetStateToAltMap([NotNull] IEnumerable<ATNConfig> configs)
         {
             IDictionary<ATNState, BitSet> m = new Dictionary<ATNState, BitSet>();
             foreach (ATNConfig c in configs)
@@ -870,7 +870,7 @@ public static IDictionary<ATNState, BitSet> GetStateToAltMap(IEnumerable<ATNConf
             return m;
         }
 
-        public static bool HasStateAssociatedWithOneAlt(IEnumerable<ATNConfig> configs)
+        public static bool HasStateAssociatedWithOneAlt([NotNull] IEnumerable<ATNConfig> configs)
         {
             IDictionary<ATNState, BitSet> x = GetStateToAltMap(configs);
             foreach (BitSet alts in x.Values)
@@ -883,7 +883,7 @@ public static bool HasStateAssociatedWithOneAlt(IEnumerable<ATNConfig> configs)
             return false;
         }
 
-        public static int GetSingleViableAlt(IEnumerable<BitSet> altsets)
+        public static int GetSingleViableAlt([NotNull] IEnumerable<BitSet> altsets)
         {
             BitSet viableAlts = new BitSet();
             foreach (BitSet alts in altsets)
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/ProfilingATNSimulator.cs b/runtime/CSharp/Antlr4.Runtime/Atn/ProfilingATNSimulator.cs
index 32c2b2fd..e2d6713f 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/ProfilingATNSimulator.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/ProfilingATNSimulator.cs
@@ -2,13 +2,14 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using Antlr4.Runtime;
 using Antlr4.Runtime.Dfa;
+using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
@@ -219,7 +220,7 @@ protected internal override void ReportAttemptingFullContext(DFA dfa, BitSet con
             base.ReportAttemptingFullContext(dfa, conflictingAlts, conflictState, startIndex, stopIndex);
         }
 
-        protected internal override void ReportAmbiguity(DFA dfa, DFAState D, int startIndex, int stopIndex, bool exact, BitSet ambigAlts, ATNConfigSet configs)
+        protected internal override void ReportAmbiguity([NotNull] DFA dfa, DFAState D, int startIndex, int stopIndex, bool exact, [NotNull] BitSet ambigAlts, [NotNull] ATNConfigSet configs)
         {
             int prediction;
             if (ambigAlts != null)
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/RangeTransition.cs b/runtime/CSharp/Antlr4.Runtime/Atn/RangeTransition.cs
index 2ff991d5..c67a0e95 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/RangeTransition.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/RangeTransition.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
@@ -17,7 +17,7 @@ public sealed class RangeTransition : Transition
 
         public readonly int to;
 
-        public RangeTransition(ATNState target, int from, int to)
+        public RangeTransition([NotNull] ATNState target, int from, int to)
             : base(target)
         {
             this.from = from;
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/RuleStartState.cs b/runtime/CSharp/Antlr4.Runtime/Atn/RuleStartState.cs
index 8bc41392..a3602d43 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/RuleStartState.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/RuleStartState.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/RuleStopState.cs b/runtime/CSharp/Antlr4.Runtime/Atn/RuleStopState.cs
index e0f16aa9..b4f19704 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/RuleStopState.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/RuleStopState.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/RuleTransition.cs b/runtime/CSharp/Antlr4.Runtime/Atn/RuleTransition.cs
index 7c7c8276..67c55ff1 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/RuleTransition.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/RuleTransition.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -28,12 +28,12 @@ public sealed class RuleTransition : Transition
         public bool optimizedTailCall;
 
         [System.ObsoleteAttribute(@"UseRuleTransition(RuleStartState, int, int, ATNState) instead.")]
-        public RuleTransition(RuleStartState ruleStart, int ruleIndex, ATNState followState)
+        public RuleTransition([NotNull] RuleStartState ruleStart, int ruleIndex, [NotNull] ATNState followState)
             : this(ruleStart, ruleIndex, 0, followState)
         {
         }
 
-        public RuleTransition(RuleStartState ruleStart, int ruleIndex, int precedence, ATNState followState)
+        public RuleTransition([NotNull] RuleStartState ruleStart, int ruleIndex, int precedence, [NotNull] ATNState followState)
             : base(ruleStart)
         {
             // no Rule object at runtime
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/SemanticContext.cs b/runtime/CSharp/Antlr4.Runtime/Atn/SemanticContext.cs
index 5c112f2d..7b82a10a 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/SemanticContext.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/SemanticContext.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using Antlr4.Runtime;
@@ -256,7 +256,7 @@ public class AND : SemanticContext.Operator
             [NotNull]
             public readonly SemanticContext[] opnds;
 
-            public AND(SemanticContext a, SemanticContext b)
+            public AND([NotNull] SemanticContext a, [NotNull] SemanticContext b)
             {
                 HashSet<SemanticContext> operands = new HashSet<SemanticContext>();
                 if (a is SemanticContext.AND)
@@ -384,7 +384,7 @@ public class OR : SemanticContext.Operator
             [NotNull]
             public readonly SemanticContext[] opnds;
 
-            public OR(SemanticContext a, SemanticContext b)
+            public OR([NotNull] SemanticContext a, [NotNull] SemanticContext b)
             {
                 HashSet<SemanticContext> operands = new HashSet<SemanticContext>();
                 if (a is SemanticContext.OR)
@@ -548,7 +548,7 @@ public static SemanticContext Or(SemanticContext a, SemanticContext b)
             where _T0 : SemanticContext
         {
             List<SemanticContext.PrecedencePredicate> result = null;
-            for (IEnumerator<SemanticContext> iterator = collection.GetEnumerator(); iterator.HasNext(); )
+            for (IEnumerator<_T0> iterator = collection.GetEnumerator(); iterator.HasNext(); )
             {
                 SemanticContext context = iterator.Next();
                 if (context is SemanticContext.PrecedencePredicate)
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/SetTransition.cs b/runtime/CSharp/Antlr4.Runtime/Atn/SetTransition.cs
index 16b3f827..a54c8d84 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/SetTransition.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/SetTransition.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
@@ -17,7 +17,7 @@ public class SetTransition : Transition
         [NotNull]
         public readonly IntervalSet set;
 
-        public SetTransition(ATNState target, IntervalSet set)
+        public SetTransition([NotNull] ATNState target, [Nullable] IntervalSet set)
             : base(target)
         {
             // TODO (sam): should we really allow null here?
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/SimulatorState.cs b/runtime/CSharp/Antlr4.Runtime/Atn/SimulatorState.cs
index 7729e5d4..f12bb3e9 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/SimulatorState.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/SimulatorState.cs
@@ -2,11 +2,12 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
 using Antlr4.Runtime.Dfa;
+using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
@@ -22,7 +23,7 @@ public class SimulatorState
 
         public readonly ParserRuleContext remainingOuterContext;
 
-        public SimulatorState(ParserRuleContext outerContext, DFAState s0, bool useContext, ParserRuleContext remainingOuterContext)
+        public SimulatorState(ParserRuleContext outerContext, [NotNull] DFAState s0, bool useContext, ParserRuleContext remainingOuterContext)
         {
             this.outerContext = outerContext != null ? outerContext : ParserRuleContext.EmptyContext;
             this.s0 = s0;
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/SingletonPredictionContext.cs b/runtime/CSharp/Antlr4.Runtime/Atn/SingletonPredictionContext.cs
index 2066557b..8e9d1b83 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/SingletonPredictionContext.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/SingletonPredictionContext.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
@@ -18,10 +18,10 @@ public class SingletonPredictionContext : PredictionContext
 
         public readonly int returnState;
 
-        internal SingletonPredictionContext(PredictionContext parent, int returnState)
+        internal SingletonPredictionContext([NotNull] PredictionContext parent, int returnState)
             : base(CalculateHashCode(parent, returnState))
         {
-            /*package*/
+	/*package*/
             System.Diagnostics.Debug.Assert(returnState != EmptyFullStateKey && returnState != EmptyLocalStateKey);
             this.parent = parent;
             this.returnState = returnState;
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/StarBlockStartState.cs b/runtime/CSharp/Antlr4.Runtime/Atn/StarBlockStartState.cs
index 934f54ef..071e4733 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/StarBlockStartState.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/StarBlockStartState.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/StarLoopEntryState.cs b/runtime/CSharp/Antlr4.Runtime/Atn/StarLoopEntryState.cs
index 7ea33b58..adf09361 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/StarLoopEntryState.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/StarLoopEntryState.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/StarLoopbackState.cs b/runtime/CSharp/Antlr4.Runtime/Atn/StarLoopbackState.cs
index 758709f3..75417afe 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/StarLoopbackState.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/StarLoopbackState.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/StateType.cs b/runtime/CSharp/Antlr4.Runtime/Atn/StateType.cs
index 21da0c7a..44d4e1bc 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/StateType.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/StateType.cs
@@ -2,34 +2,34 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* [The "BSD license"]
-*  Copyright (c) 2012 Terence Parr
-*  Copyright (c) 2012 Sam Harwell
-*  All rights reserved.
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*  1. Redistributions of source code must retain the above copyright
-*     notice, this list of conditions and the following disclaimer.
-*  2. Redistributions in binary form must reproduce the above copyright
-*     notice, this list of conditions and the following disclaimer in the
-*     documentation and/or other materials provided with the distribution.
-*  3. The name of the author may not be used to endorse or promote products
-*     derived from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-*  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-*  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-*  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-*  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-*  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-*  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ * [The "BSD license"]
+ *  Copyright (c) 2012 Terence Parr
+ *  Copyright (c) 2012 Sam Harwell
+ *  All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *  3. The name of the author may not be used to endorse or promote products
+ *     derived from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ *  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ *  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/TokensStartState.cs b/runtime/CSharp/Antlr4.Runtime/Atn/TokensStartState.cs
index 3d7026f1..6ac36008 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/TokensStartState.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/TokensStartState.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/Transition.cs b/runtime/CSharp/Antlr4.Runtime/Atn/Transition.cs
index d5ce5017..de5b7ff2 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/Transition.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/Transition.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using Antlr4.Runtime.Misc;
@@ -33,7 +33,7 @@ public abstract class Transition
         [NotNull]
         public ATNState target;
 
-        protected internal Transition(ATNState target)
+        protected internal Transition([NotNull] ATNState target)
         {
             if (target == null)
             {
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/TransitionType.cs b/runtime/CSharp/Antlr4.Runtime/Atn/TransitionType.cs
index 12139b5d..e76156d9 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/TransitionType.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/TransitionType.cs
@@ -2,34 +2,34 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* [The "BSD license"]
-*  Copyright (c) 2012 Terence Parr
-*  Copyright (c) 2012 Sam Harwell
-*  All rights reserved.
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*  1. Redistributions of source code must retain the above copyright
-*     notice, this list of conditions and the following disclaimer.
-*  2. Redistributions in binary form must reproduce the above copyright
-*     notice, this list of conditions and the following disclaimer in the
-*     documentation and/or other materials provided with the distribution.
-*  3. The name of the author may not be used to endorse or promote products
-*     derived from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-*  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-*  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-*  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-*  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-*  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-*  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ * [The "BSD license"]
+ *  Copyright (c) 2012 Terence Parr
+ *  Copyright (c) 2012 Sam Harwell
+ *  All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *  3. The name of the author may not be used to endorse or promote products
+ *     derived from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ *  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ *  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Atn
diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/WildcardTransition.cs b/runtime/CSharp/Antlr4.Runtime/Atn/WildcardTransition.cs
index 6fce3a5c..9617c45d 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/WildcardTransition.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/WildcardTransition.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
@@ -13,7 +13,7 @@ namespace Antlr4.Runtime.Atn
 {
     public sealed class WildcardTransition : Transition
     {
-        public WildcardTransition(ATNState target)
+        public WildcardTransition([NotNull] ATNState target)
             : base(target)
         {
         }
diff --git a/runtime/CSharp/Antlr4.Runtime/BailErrorStrategy.cs b/runtime/CSharp/Antlr4.Runtime/BailErrorStrategy.cs
index ec8e3e41..55aa663a 100644
--- a/runtime/CSharp/Antlr4.Runtime/BailErrorStrategy.cs
+++ b/runtime/CSharp/Antlr4.Runtime/BailErrorStrategy.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime
diff --git a/runtime/CSharp/Antlr4.Runtime/BaseErrorListener.cs b/runtime/CSharp/Antlr4.Runtime/BaseErrorListener.cs
index 21f22997..818d1d3d 100644
--- a/runtime/CSharp/Antlr4.Runtime/BaseErrorListener.cs
+++ b/runtime/CSharp/Antlr4.Runtime/BaseErrorListener.cs
@@ -2,12 +2,13 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Atn;
 using Antlr4.Runtime.Dfa;
+using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime
@@ -22,20 +23,20 @@ namespace Antlr4.Runtime
     /// <author>Sam Harwell</author>
     public class BaseErrorListener : IParserErrorListener
     {
-        public virtual void SyntaxError<T>(Recognizer<T, object> recognizer, T offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
+        public virtual void SyntaxError<T>([NotNull] Recognizer<T, object> recognizer, [Nullable] T offendingSymbol, int line, int charPositionInLine, [NotNull] string msg, [Nullable] RecognitionException e)
             where T : IToken
         {
         }
 
-        public virtual void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, bool exact, BitSet ambigAlts, ATNConfigSet configs)
+        public virtual void ReportAmbiguity([NotNull] Parser recognizer, [NotNull] DFA dfa, int startIndex, int stopIndex, bool exact, [Nullable] BitSet ambigAlts, [NotNull] ATNConfigSet configs)
         {
         }
 
-        public virtual void ReportAttemptingFullContext(Parser recognizer, DFA dfa, int startIndex, int stopIndex, BitSet conflictingAlts, SimulatorState conflictState)
+        public virtual void ReportAttemptingFullContext([NotNull] Parser recognizer, [NotNull] DFA dfa, int startIndex, int stopIndex, [Nullable] BitSet conflictingAlts, [NotNull] SimulatorState conflictState)
         {
         }
 
-        public virtual void ReportContextSensitivity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, int prediction, SimulatorState acceptState)
+        public virtual void ReportContextSensitivity([NotNull] Parser recognizer, [NotNull] DFA dfa, int startIndex, int stopIndex, int prediction, [NotNull] SimulatorState acceptState)
         {
         }
     }
diff --git a/runtime/CSharp/Antlr4.Runtime/BufferedTokenStream.cs b/runtime/CSharp/Antlr4.Runtime/BufferedTokenStream.cs
index e0d1177d..63a405b4 100644
--- a/runtime/CSharp/Antlr4.Runtime/BufferedTokenStream.cs
+++ b/runtime/CSharp/Antlr4.Runtime/BufferedTokenStream.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using System.Text;
@@ -111,7 +111,7 @@ public class BufferedTokenStream : ITokenStream
         /// </summary>
         protected internal bool fetchedEOF;
 
-        public BufferedTokenStream(ITokenSource tokenSource)
+        public BufferedTokenStream([NotNull] ITokenSource tokenSource)
         {
             if (tokenSource == null)
             {
diff --git a/runtime/CSharp/Antlr4.Runtime/CommonToken.cs b/runtime/CSharp/Antlr4.Runtime/CommonToken.cs
index c5cf6de0..4f4bef67 100644
--- a/runtime/CSharp/Antlr4.Runtime/CommonToken.cs
+++ b/runtime/CSharp/Antlr4.Runtime/CommonToken.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -132,7 +132,7 @@ public CommonToken(int type)
             this.source = EmptySource;
         }
 
-        public CommonToken(Tuple<ITokenSource, ICharStream> source, int type, int channel, int start, int stop)
+        public CommonToken([NotNull] Tuple<ITokenSource, ICharStream> source, int type, int channel, int start, int stop)
         {
             this.source = source;
             this.type = type;
@@ -195,7 +195,7 @@ public CommonToken(int type, string text)
         /// .</p>
         /// </summary>
         /// <param name="oldToken">The token to copy.</param>
-        public CommonToken(IToken oldToken)
+        public CommonToken([NotNull] IToken oldToken)
         {
             type = oldToken.Type;
             line = oldToken.Line;
diff --git a/runtime/CSharp/Antlr4.Runtime/CommonTokenFactory.cs b/runtime/CSharp/Antlr4.Runtime/CommonTokenFactory.cs
index 7cf060d7..e35d9485 100644
--- a/runtime/CSharp/Antlr4.Runtime/CommonTokenFactory.cs
+++ b/runtime/CSharp/Antlr4.Runtime/CommonTokenFactory.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
diff --git a/runtime/CSharp/Antlr4.Runtime/CommonTokenStream.cs b/runtime/CSharp/Antlr4.Runtime/CommonTokenStream.cs
index 8dababdd..c01926ab 100644
--- a/runtime/CSharp/Antlr4.Runtime/CommonTokenStream.cs
+++ b/runtime/CSharp/Antlr4.Runtime/CommonTokenStream.cs
@@ -2,10 +2,11 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime
@@ -71,7 +72,7 @@ public class CommonTokenStream : BufferedTokenStream
         /// ).
         /// </summary>
         /// <param name="tokenSource">The token source.</param>
-        public CommonTokenStream(ITokenSource tokenSource)
+        public CommonTokenStream([NotNull] ITokenSource tokenSource)
             : base(tokenSource)
         {
         }
@@ -93,7 +94,7 @@ public CommonTokenStream(ITokenSource tokenSource)
         /// </summary>
         /// <param name="tokenSource">The token source.</param>
         /// <param name="channel">The channel to use for filtering tokens.</param>
-        public CommonTokenStream(ITokenSource tokenSource, int channel)
+        public CommonTokenStream([NotNull] ITokenSource tokenSource, int channel)
             : this(tokenSource)
         {
             this.channel = channel;
diff --git a/runtime/CSharp/Antlr4.Runtime/ConsoleErrorListener.cs b/runtime/CSharp/Antlr4.Runtime/ConsoleErrorListener.cs
index 7c658815..ca1858cd 100644
--- a/runtime/CSharp/Antlr4.Runtime/ConsoleErrorListener.cs
+++ b/runtime/CSharp/Antlr4.Runtime/ConsoleErrorListener.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime
diff --git a/runtime/CSharp/Antlr4.Runtime/DefaultErrorStrategy.cs b/runtime/CSharp/Antlr4.Runtime/DefaultErrorStrategy.cs
index 0cb0595e..9d76e9c0 100644
--- a/runtime/CSharp/Antlr4.Runtime/DefaultErrorStrategy.cs
+++ b/runtime/CSharp/Antlr4.Runtime/DefaultErrorStrategy.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using Antlr4.Runtime.Atn;
 using Antlr4.Runtime.Misc;
@@ -62,7 +62,7 @@ public virtual void Reset(Parser recognizer)
         /// exception is reported.
         /// </summary>
         /// <param name="recognizer">the parser instance</param>
-        protected internal virtual void BeginErrorCondition(Parser recognizer)
+        protected internal virtual void BeginErrorCondition([NotNull] Parser recognizer)
         {
             errorRecoveryMode = true;
         }
@@ -78,7 +78,7 @@ public virtual bool InErrorRecoveryMode(Parser recognizer)
         /// a recognition exception.
         /// </summary>
         /// <param name="recognizer"/>
-        protected internal virtual void EndErrorCondition(Parser recognizer)
+        protected internal virtual void EndErrorCondition([NotNull] Parser recognizer)
         {
             errorRecoveryMode = false;
             lastErrorStates = null;
@@ -162,7 +162,7 @@ public virtual void ReportError(Parser recognizer, RecognitionException e)
             }
         }
 
-        protected internal virtual void NotifyErrorListeners(Parser recognizer, string message, RecognitionException e)
+        protected internal virtual void NotifyErrorListeners([NotNull] Parser recognizer, string message, RecognitionException e)
         {
             recognizer.NotifyErrorListeners(e.OffendingToken, message, e);
         }
@@ -307,7 +307,7 @@ public virtual void Sync(Parser recognizer)
         /// <seealso cref="ReportError(Parser, RecognitionException)"/>
         /// <param name="recognizer">the parser instance</param>
         /// <param name="e">the recognition exception</param>
-        protected internal virtual void ReportNoViableAlternative(Parser recognizer, NoViableAltException e)
+        protected internal virtual void ReportNoViableAlternative([NotNull] Parser recognizer, [NotNull] NoViableAltException e)
         {
             ITokenStream tokens = ((ITokenStream)recognizer.InputStream);
             string input;
@@ -340,7 +340,7 @@ protected internal virtual void ReportNoViableAlternative(Parser recognizer, NoV
         /// <seealso cref="ReportError(Parser, RecognitionException)"/>
         /// <param name="recognizer">the parser instance</param>
         /// <param name="e">the recognition exception</param>
-        protected internal virtual void ReportInputMismatch(Parser recognizer, InputMismatchException e)
+        protected internal virtual void ReportInputMismatch([NotNull] Parser recognizer, [NotNull] InputMismatchException e)
         {
             string msg = "mismatched input " + GetTokenErrorDisplay(e.OffendingToken) + " expecting " + e.GetExpectedTokens().ToString(recognizer.Vocabulary);
             NotifyErrorListeners(recognizer, msg, e);
@@ -356,7 +356,7 @@ protected internal virtual void ReportInputMismatch(Parser recognizer, InputMism
         /// <seealso cref="ReportError(Parser, RecognitionException)"/>
         /// <param name="recognizer">the parser instance</param>
         /// <param name="e">the recognition exception</param>
-        protected internal virtual void ReportFailedPredicate(Parser recognizer, FailedPredicateException e)
+        protected internal virtual void ReportFailedPredicate([NotNull] Parser recognizer, [NotNull] FailedPredicateException e)
         {
             string ruleName = recognizer.RuleNames[recognizer._ctx.RuleIndex];
             string msg = "rule " + ruleName + " " + e.Message;
@@ -390,7 +390,7 @@ protected internal virtual void ReportFailedPredicate(Parser recognizer, FailedP
         /// .</p>
         /// </remarks>
         /// <param name="recognizer">the parser instance</param>
-        protected internal virtual void ReportUnwantedToken(Parser recognizer)
+        protected internal virtual void ReportUnwantedToken([NotNull] Parser recognizer)
         {
             if (InErrorRecoveryMode(recognizer))
             {
@@ -429,7 +429,7 @@ protected internal virtual void ReportUnwantedToken(Parser recognizer)
         /// .</p>
         /// </remarks>
         /// <param name="recognizer">the parser instance</param>
-        protected internal virtual void ReportMissingToken(Parser recognizer)
+        protected internal virtual void ReportMissingToken([NotNull] Parser recognizer)
         {
             if (InErrorRecoveryMode(recognizer))
             {
@@ -575,7 +575,7 @@ public virtual IToken RecoverInline(Parser recognizer)
         /// strategy for the current mismatched input, otherwise
         /// <see langword="false"/>
         /// </returns>
-        protected internal virtual bool SingleTokenInsertion(Parser recognizer)
+        protected internal virtual bool SingleTokenInsertion([NotNull] Parser recognizer)
         {
             int currentSymbolType = ((ITokenStream)recognizer.InputStream).La(1);
             // if current token is consistent with what could come after current
@@ -627,19 +627,19 @@ protected internal virtual bool SingleTokenInsertion(Parser recognizer)
         /// <see langword="null"/>
         /// </returns>
         [Nullable]
-        protected internal virtual IToken SingleTokenDeletion(Parser recognizer)
+        protected internal virtual IToken SingleTokenDeletion([NotNull] Parser recognizer)
         {
             int nextTokenType = ((ITokenStream)recognizer.InputStream).La(2);
             IntervalSet expecting = GetExpectedTokens(recognizer);
             if (expecting.Contains(nextTokenType))
             {
                 ReportUnwantedToken(recognizer);
-                /*
-                System.err.println("recoverFromMismatchedToken deleting "+
-                ((TokenStream)recognizer.getInputStream()).LT(1)+
-                " since "+((TokenStream)recognizer.getInputStream()).LT(2)+
-                " is what we want");
-                */
+			/*
+			System.err.println("recoverFromMismatchedToken deleting "+
+							   ((TokenStream)recognizer.getInputStream()).LT(1)+
+							   " since "+((TokenStream)recognizer.getInputStream()).LT(2)+
+							   " is what we want");
+			*/
                 recognizer.Consume();
                 // simply delete extra token
                 // we want to return the token we're actually matching
@@ -672,7 +672,7 @@ protected internal virtual IToken SingleTokenDeletion(Parser recognizer)
         /// override this method to create the appropriate tokens.
         /// </remarks>
         [NotNull]
-        protected internal virtual IToken GetMissingSymbol(Parser recognizer)
+        protected internal virtual IToken GetMissingSymbol([NotNull] Parser recognizer)
         {
             IToken currentSymbol = recognizer.CurrentToken;
             IntervalSet expecting = GetExpectedTokens(recognizer);
@@ -703,7 +703,7 @@ protected internal virtual IToken ConstructToken(ITokenSource tokenSource, int e
         }
 
         [NotNull]
-        protected internal virtual IntervalSet GetExpectedTokens(Parser recognizer)
+        protected internal virtual IntervalSet GetExpectedTokens([NotNull] Parser recognizer)
         {
             return recognizer.GetExpectedTokens();
         }
@@ -743,18 +743,18 @@ protected internal virtual string GetTokenErrorDisplay(IToken t)
             return EscapeWSAndQuote(s);
         }
 
-        protected internal virtual string GetSymbolText(IToken symbol)
+        protected internal virtual string GetSymbolText([NotNull] IToken symbol)
         {
             return symbol.Text;
         }
 
-        protected internal virtual int GetSymbolType(IToken symbol)
+        protected internal virtual int GetSymbolType([NotNull] IToken symbol)
         {
             return symbol.Type;
         }
 
         [NotNull]
-        protected internal virtual string EscapeWSAndQuote(string s)
+        protected internal virtual string EscapeWSAndQuote([NotNull] string s)
         {
             //		if ( s==null ) return s;
             s = s.Replace("\n", "\\n");
@@ -763,100 +763,100 @@ protected internal virtual string EscapeWSAndQuote(string s)
             return "'" + s + "'";
         }
 
-        /*  Compute the error recovery set for the current rule.  During
-        *  rule invocation, the parser pushes the set of tokens that can
-        *  follow that rule reference on the stack; this amounts to
-        *  computing FIRST of what follows the rule reference in the
-        *  enclosing rule. See LinearApproximator.FIRST().
-        *  This local follow set only includes tokens
-        *  from within the rule; i.e., the FIRST computation done by
-        *  ANTLR stops at the end of a rule.
-        *
-        *  EXAMPLE
-        *
-        *  When you find a "no viable alt exception", the input is not
-        *  consistent with any of the alternatives for rule r.  The best
-        *  thing to do is to consume tokens until you see something that
-        *  can legally follow a call to r *or* any rule that called r.
-        *  You don't want the exact set of viable next tokens because the
-        *  input might just be missing a token--you might consume the
-        *  rest of the input looking for one of the missing tokens.
-        *
-        *  Consider grammar:
-        *
-        *  a : '[' b ']'
-        *    | '(' b ')'
-        *    ;
-        *  b : c '^' INT ;
-        *  c : ID
-        *    | INT
-        *    ;
-        *
-        *  At each rule invocation, the set of tokens that could follow
-        *  that rule is pushed on a stack.  Here are the various
-        *  context-sensitive follow sets:
-        *
-        *  FOLLOW(b1_in_a) = FIRST(']') = ']'
-        *  FOLLOW(b2_in_a) = FIRST(')') = ')'
-        *  FOLLOW(c_in_b) = FIRST('^') = '^'
-        *
-        *  Upon erroneous input "[]", the call chain is
-        *
-        *  a -> b -> c
-        *
-        *  and, hence, the follow context stack is:
-        *
-        *  depth     follow set       start of rule execution
-        *    0         <EOF>                    a (from main())
-        *    1          ']'                     b
-        *    2          '^'                     c
-        *
-        *  Notice that ')' is not included, because b would have to have
-        *  been called from a different context in rule a for ')' to be
-        *  included.
-        *
-        *  For error recovery, we cannot consider FOLLOW(c)
-        *  (context-sensitive or otherwise).  We need the combined set of
-        *  all context-sensitive FOLLOW sets--the set of all tokens that
-        *  could follow any reference in the call chain.  We need to
-        *  resync to one of those tokens.  Note that FOLLOW(c)='^' and if
-        *  we resync'd to that token, we'd consume until EOF.  We need to
-        *  sync to context-sensitive FOLLOWs for a, b, and c: {']','^'}.
-        *  In this case, for input "[]", LA(1) is ']' and in the set, so we would
-        *  not consume anything. After printing an error, rule c would
-        *  return normally.  Rule b would not find the required '^' though.
-        *  At this point, it gets a mismatched token error and throws an
-        *  exception (since LA(1) is not in the viable following token
-        *  set).  The rule exception handler tries to recover, but finds
-        *  the same recovery set and doesn't consume anything.  Rule b
-        *  exits normally returning to rule a.  Now it finds the ']' (and
-        *  with the successful match exits errorRecovery mode).
-        *
-        *  So, you can see that the parser walks up the call chain looking
-        *  for the token that was a member of the recovery set.
-        *
-        *  Errors are not generated in errorRecovery mode.
-        *
-        *  ANTLR's error recovery mechanism is based upon original ideas:
-        *
-        *  "Algorithms + Data Structures = Programs" by Niklaus Wirth
-        *
-        *  and
-        *
-        *  "A note on error recovery in recursive descent parsers":
-        *  http://portal.acm.org/citation.cfm?id=947902.947905
-        *
-        *  Later, Josef Grosch had some good ideas:
-        *
-        *  "Efficient and Comfortable Error Recovery in Recursive Descent
-        *  Parsers":
-        *  ftp://www.cocolab.com/products/cocktail/doca4.ps/ell.ps.zip
-        *
-        *  Like Grosch I implement context-sensitive FOLLOW sets that are combined
-        *  at run-time upon error to avoid overhead during parsing.
-        */
+	/*  Compute the error recovery set for the current rule.  During
+	 *  rule invocation, the parser pushes the set of tokens that can
+	 *  follow that rule reference on the stack; this amounts to
+	 *  computing FIRST of what follows the rule reference in the
+	 *  enclosing rule. See LinearApproximator.FIRST().
+	 *  This local follow set only includes tokens
+	 *  from within the rule; i.e., the FIRST computation done by
+	 *  ANTLR stops at the end of a rule.
+	 *
+	 *  EXAMPLE
+	 *
+	 *  When you find a "no viable alt exception", the input is not
+	 *  consistent with any of the alternatives for rule r.  The best
+	 *  thing to do is to consume tokens until you see something that
+	 *  can legally follow a call to r *or* any rule that called r.
+	 *  You don't want the exact set of viable next tokens because the
+	 *  input might just be missing a token--you might consume the
+	 *  rest of the input looking for one of the missing tokens.
+	 *
+	 *  Consider grammar:
+	 *
+	 *  a : '[' b ']'
+	 *    | '(' b ')'
+	 *    ;
+	 *  b : c '^' INT ;
+	 *  c : ID
+	 *    | INT
+	 *    ;
+	 *
+	 *  At each rule invocation, the set of tokens that could follow
+	 *  that rule is pushed on a stack.  Here are the various
+	 *  context-sensitive follow sets:
+	 *
+	 *  FOLLOW(b1_in_a) = FIRST(']') = ']'
+	 *  FOLLOW(b2_in_a) = FIRST(')') = ')'
+	 *  FOLLOW(c_in_b) = FIRST('^') = '^'
+	 *
+	 *  Upon erroneous input "[]", the call chain is
+	 *
+	 *  a -> b -> c
+	 *
+	 *  and, hence, the follow context stack is:
+	 *
+	 *  depth     follow set       start of rule execution
+	 *    0         <EOF>                    a (from main())
+	 *    1          ']'                     b
+	 *    2          '^'                     c
+	 *
+	 *  Notice that ')' is not included, because b would have to have
+	 *  been called from a different context in rule a for ')' to be
+	 *  included.
+	 *
+	 *  For error recovery, we cannot consider FOLLOW(c)
+	 *  (context-sensitive or otherwise).  We need the combined set of
+	 *  all context-sensitive FOLLOW sets--the set of all tokens that
+	 *  could follow any reference in the call chain.  We need to
+	 *  resync to one of those tokens.  Note that FOLLOW(c)='^' and if
+	 *  we resync'd to that token, we'd consume until EOF.  We need to
+	 *  sync to context-sensitive FOLLOWs for a, b, and c: {']','^'}.
+	 *  In this case, for input "[]", LA(1) is ']' and in the set, so we would
+	 *  not consume anything. After printing an error, rule c would
+	 *  return normally.  Rule b would not find the required '^' though.
+	 *  At this point, it gets a mismatched token error and throws an
+	 *  exception (since LA(1) is not in the viable following token
+	 *  set).  The rule exception handler tries to recover, but finds
+	 *  the same recovery set and doesn't consume anything.  Rule b
+	 *  exits normally returning to rule a.  Now it finds the ']' (and
+	 *  with the successful match exits errorRecovery mode).
+	 *
+	 *  So, you can see that the parser walks up the call chain looking
+	 *  for the token that was a member of the recovery set.
+	 *
+	 *  Errors are not generated in errorRecovery mode.
+	 *
+	 *  ANTLR's error recovery mechanism is based upon original ideas:
+	 *
+	 *  "Algorithms + Data Structures = Programs" by Niklaus Wirth
+	 *
+	 *  and
+	 *
+	 *  "A note on error recovery in recursive descent parsers":
+	 *  http://portal.acm.org/citation.cfm?id=947902.947905
+	 *
+	 *  Later, Josef Grosch had some good ideas:
+	 *
+	 *  "Efficient and Comfortable Error Recovery in Recursive Descent
+	 *  Parsers":
+	 *  ftp://www.cocolab.com/products/cocktail/doca4.ps/ell.ps.zip
+	 *
+	 *  Like Grosch I implement context-sensitive FOLLOW sets that are combined
+	 *  at run-time upon error to avoid overhead during parsing.
+	 */
         [NotNull]
-        protected internal virtual IntervalSet GetErrorRecoverySet(Parser recognizer)
+        protected internal virtual IntervalSet GetErrorRecoverySet([NotNull] Parser recognizer)
         {
             ATN atn = recognizer.Interpreter.atn;
             RuleContext ctx = recognizer._ctx;
@@ -876,7 +876,7 @@ protected internal virtual IntervalSet GetErrorRecoverySet(Parser recognizer)
         }
 
         /// <summary>Consume tokens until one matches the given token set.</summary>
-        protected internal virtual void ConsumeUntil(Parser recognizer, IntervalSet set)
+        protected internal virtual void ConsumeUntil([NotNull] Parser recognizer, [NotNull] IntervalSet set)
         {
             //		System.err.println("consumeUntil("+set.toString(recognizer.getTokenNames())+")");
             int ttype = ((ITokenStream)recognizer.InputStream).La(1);
diff --git a/runtime/CSharp/Antlr4.Runtime/Dependents.cs b/runtime/CSharp/Antlr4.Runtime/Dependents.cs
index f763d41c..d6397d72 100644
--- a/runtime/CSharp/Antlr4.Runtime/Dependents.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Dependents.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime
diff --git a/runtime/CSharp/Antlr4.Runtime/Dfa/AbstractEdgeMap`1.cs b/runtime/CSharp/Antlr4.Runtime/Dfa/AbstractEdgeMap`1.cs
index 14715a43..57bbe3c2 100644
--- a/runtime/CSharp/Antlr4.Runtime/Dfa/AbstractEdgeMap`1.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Dfa/AbstractEdgeMap`1.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using Antlr4.Runtime.Sharpen;
 
@@ -32,7 +32,7 @@ public virtual Antlr4.Runtime.Dfa.AbstractEdgeMap<T> PutAll<_T0>(IEdgeMap<_T0> m
             where _T0 : T
         {
             Antlr4.Runtime.Dfa.AbstractEdgeMap<T> result = this;
-            foreach (KeyValuePair<int, T> entry in m.EntrySet())
+            foreach (KeyValuePair<int, _T0> entry in m.EntrySet())
             {
                 result = result.Put(entry.Key, entry.Value);
             }
diff --git a/runtime/CSharp/Antlr4.Runtime/Dfa/AcceptStateInfo.cs b/runtime/CSharp/Antlr4.Runtime/Dfa/AcceptStateInfo.cs
index 30711ea8..a7430314 100644
--- a/runtime/CSharp/Antlr4.Runtime/Dfa/AcceptStateInfo.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Dfa/AcceptStateInfo.cs
@@ -2,9 +2,9 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Dfa
diff --git a/runtime/CSharp/Antlr4.Runtime/Dfa/ArrayEdgeMap`1.cs b/runtime/CSharp/Antlr4.Runtime/Dfa/ArrayEdgeMap`1.cs
index ffebed02..04f92221 100644
--- a/runtime/CSharp/Antlr4.Runtime/Dfa/ArrayEdgeMap`1.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Dfa/ArrayEdgeMap`1.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using Antlr4.Runtime.Sharpen;
@@ -92,7 +92,7 @@ public override AbstractEdgeMap<T> PutAll<_T0>(IEdgeMap<_T0> m)
             }
             if (m is Antlr4.Runtime.Dfa.ArrayEdgeMap<object>)
             {
-                Antlr4.Runtime.Dfa.ArrayEdgeMap<T> other = (Antlr4.Runtime.Dfa.ArrayEdgeMap<T>)m;
+                Antlr4.Runtime.Dfa.ArrayEdgeMap<_T0> other = (Antlr4.Runtime.Dfa.ArrayEdgeMap<_T0>)m;
                 int minOverlap = Math.Max(minIndex, other.minIndex);
                 int maxOverlap = Math.Min(maxIndex, other.maxIndex);
                 Antlr4.Runtime.Dfa.ArrayEdgeMap<T> result = this;
@@ -106,7 +106,7 @@ public override AbstractEdgeMap<T> PutAll<_T0>(IEdgeMap<_T0> m)
             {
                 if (m is SingletonEdgeMap<object>)
                 {
-                    SingletonEdgeMap<T> other = (SingletonEdgeMap<T>)m;
+                    SingletonEdgeMap<_T0> other = (SingletonEdgeMap<_T0>)m;
                     System.Diagnostics.Debug.Assert(!other.IsEmpty);
                     return ((Antlr4.Runtime.Dfa.ArrayEdgeMap<T>)Put(other.Key, other.Value));
                 }
@@ -114,11 +114,11 @@ public override AbstractEdgeMap<T> PutAll<_T0>(IEdgeMap<_T0> m)
                 {
                     if (m is SparseEdgeMap<object>)
                     {
-                        SparseEdgeMap<T> other = (SparseEdgeMap<T>)m;
+                        SparseEdgeMap<_T0> other = (SparseEdgeMap<_T0>)m;
                         lock (other)
                         {
                             int[] keys = other.Keys;
-                            IList<T> values = other.Values;
+                            IList<_T0> values = other.Values;
                             Antlr4.Runtime.Dfa.ArrayEdgeMap<T> result = this;
                             for (int i = 0; i < values.Count; i++)
                             {
diff --git a/runtime/CSharp/Antlr4.Runtime/Dfa/DFA.cs b/runtime/CSharp/Antlr4.Runtime/Dfa/DFA.cs
index 68a85971..7d23b6cf 100644
--- a/runtime/CSharp/Antlr4.Runtime/Dfa/DFA.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Dfa/DFA.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Concurrent;
 using Antlr4.Runtime;
@@ -66,12 +66,12 @@ public class DFA
         /// </summary>
         private readonly bool precedenceDfa;
 
-        public DFA(ATNState atnStartState)
+        public DFA([NotNull] ATNState atnStartState)
             : this(atnStartState, 0)
         {
         }
 
-        public DFA(ATNState atnStartState, int decision)
+        public DFA([NotNull] ATNState atnStartState, int decision)
         {
             this.atnStartState = atnStartState;
             this.decision = decision;
@@ -288,7 +288,7 @@ public override string ToString()
         }
 
         [System.ObsoleteAttribute(@"Use ToString(Antlr4.Runtime.IVocabulary) instead.")]
-        public virtual string ToString(string[] tokenNames)
+        public virtual string ToString([Nullable] string[] tokenNames)
         {
             if (s0.Get() == null)
             {
@@ -298,7 +298,7 @@ public virtual string ToString(string[] tokenNames)
             return serializer.ToString();
         }
 
-        public virtual string ToString(IVocabulary vocabulary)
+        public virtual string ToString([NotNull] IVocabulary vocabulary)
         {
             if (s0.Get() == null)
             {
@@ -309,7 +309,7 @@ public virtual string ToString(IVocabulary vocabulary)
         }
 
         [System.ObsoleteAttribute(@"Use ToString(Antlr4.Runtime.IVocabulary, string[]) instead.")]
-        public virtual string ToString(string[] tokenNames, string[] ruleNames)
+        public virtual string ToString([Nullable] string[] tokenNames, [Nullable] string[] ruleNames)
         {
             if (s0.Get() == null)
             {
@@ -319,7 +319,7 @@ public virtual string ToString(string[] tokenNames, string[] ruleNames)
             return serializer.ToString();
         }
 
-        public virtual string ToString(IVocabulary vocabulary, string[] ruleNames)
+        public virtual string ToString([NotNull] IVocabulary vocabulary, [Nullable] string[] ruleNames)
         {
             if (s0.Get() == null)
             {
diff --git a/runtime/CSharp/Antlr4.Runtime/Dfa/DFASerializer.cs b/runtime/CSharp/Antlr4.Runtime/Dfa/DFASerializer.cs
index 3b164c1e..2aac6d84 100644
--- a/runtime/CSharp/Antlr4.Runtime/Dfa/DFASerializer.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Dfa/DFASerializer.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using System.Text;
@@ -32,28 +32,28 @@ public class DFASerializer
         internal readonly ATN atn;
 
         [System.ObsoleteAttribute(@"Use DFASerializer(DFA, Antlr4.Runtime.IVocabulary) instead.")]
-        public DFASerializer(DFA dfa, string[] tokenNames)
+        public DFASerializer([NotNull] DFA dfa, [Nullable] string[] tokenNames)
             : this(dfa, Vocabulary.FromTokenNames(tokenNames), null, null)
         {
         }
 
-        public DFASerializer(DFA dfa, IVocabulary vocabulary)
+        public DFASerializer([NotNull] DFA dfa, [NotNull] IVocabulary vocabulary)
             : this(dfa, vocabulary, null, null)
         {
         }
 
-        public DFASerializer(DFA dfa, Recognizer<object, object> parser)
+        public DFASerializer([NotNull] DFA dfa, [Nullable] Recognizer<object, object> parser)
             : this(dfa, parser != null ? parser.Vocabulary : Vocabulary.EmptyVocabulary, parser != null ? parser.RuleNames : null, parser != null ? parser.Atn : null)
         {
         }
 
         [System.ObsoleteAttribute(@"Use DFASerializer(DFA, Antlr4.Runtime.IVocabulary, string[], Antlr4.Runtime.Atn.ATN) instead.")]
-        public DFASerializer(DFA dfa, string[] tokenNames, string[] ruleNames, ATN atn)
+        public DFASerializer([NotNull] DFA dfa, [Nullable] string[] tokenNames, [Nullable] string[] ruleNames, [Nullable] ATN atn)
             : this(dfa, Vocabulary.FromTokenNames(tokenNames), ruleNames, atn)
         {
         }
 
-        public DFASerializer(DFA dfa, IVocabulary vocabulary, string[] ruleNames, ATN atn)
+        public DFASerializer([NotNull] DFA dfa, [NotNull] IVocabulary vocabulary, [Nullable] string[] ruleNames, [Nullable] ATN atn)
         {
             this.dfa = dfa;
             this.vocabulary = vocabulary;
diff --git a/runtime/CSharp/Antlr4.Runtime/Dfa/DFAState.cs b/runtime/CSharp/Antlr4.Runtime/Dfa/DFAState.cs
index 415f7de4..46f81b5d 100644
--- a/runtime/CSharp/Antlr4.Runtime/Dfa/DFAState.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Dfa/DFAState.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using System.Text;
@@ -79,7 +79,7 @@ public class PredPrediction
 
             public int alt;
 
-            public PredPrediction(SemanticContext pred, int alt)
+            public PredPrediction([NotNull] SemanticContext pred, int alt)
             {
                 // never null; at least SemanticContext.NONE
                 this.alt = alt;
@@ -92,12 +92,12 @@ public override string ToString()
             }
         }
 
-        public DFAState(DFA dfa, ATNConfigSet configs)
+        public DFAState([NotNull] DFA dfa, [NotNull] ATNConfigSet configs)
             : this(dfa.EmptyEdgeMap, dfa.EmptyContextEdgeMap, configs)
         {
         }
 
-        public DFAState(EmptyEdgeMap<DFAState> emptyEdges, EmptyEdgeMap<DFAState> emptyContextEdges, ATNConfigSet configs)
+        public DFAState([NotNull] EmptyEdgeMap<DFAState> emptyEdges, [NotNull] EmptyEdgeMap<DFAState> emptyContextEdges, [NotNull] ATNConfigSet configs)
         {
             this.configs = configs;
             this.edges = emptyEdges;
diff --git a/runtime/CSharp/Antlr4.Runtime/Dfa/EmptyEdgeMap`1.cs b/runtime/CSharp/Antlr4.Runtime/Dfa/EmptyEdgeMap`1.cs
index e146349f..bbefc2f4 100644
--- a/runtime/CSharp/Antlr4.Runtime/Dfa/EmptyEdgeMap`1.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Dfa/EmptyEdgeMap`1.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using Antlr4.Runtime.Sharpen;
 
diff --git a/runtime/CSharp/Antlr4.Runtime/Dfa/IEdgeMap`1.cs b/runtime/CSharp/Antlr4.Runtime/Dfa/IEdgeMap`1.cs
index fedaa6a8..1011dd85 100644
--- a/runtime/CSharp/Antlr4.Runtime/Dfa/IEdgeMap`1.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Dfa/IEdgeMap`1.cs
@@ -2,9 +2,9 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -32,7 +32,7 @@ T this[int key]
         }
 
         [NotNull]
-        IEdgeMap<T> Put(int key, T value);
+        IEdgeMap<T> Put(int key, [Nullable] T value);
 
         [NotNull]
         IEdgeMap<T> Remove(int key);
diff --git a/runtime/CSharp/Antlr4.Runtime/Dfa/LexerDFASerializer.cs b/runtime/CSharp/Antlr4.Runtime/Dfa/LexerDFASerializer.cs
index ff805b0a..a6566ad0 100644
--- a/runtime/CSharp/Antlr4.Runtime/Dfa/LexerDFASerializer.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Dfa/LexerDFASerializer.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -14,7 +14,7 @@ namespace Antlr4.Runtime.Dfa
 {
     public class LexerDFASerializer : DFASerializer
     {
-        public LexerDFASerializer(DFA dfa)
+        public LexerDFASerializer([NotNull] DFA dfa)
             : base(dfa, Vocabulary.EmptyVocabulary)
         {
         }
diff --git a/runtime/CSharp/Antlr4.Runtime/Dfa/SingletonEdgeMap`1.cs b/runtime/CSharp/Antlr4.Runtime/Dfa/SingletonEdgeMap`1.cs
index 8da09cef..6072b686 100644
--- a/runtime/CSharp/Antlr4.Runtime/Dfa/SingletonEdgeMap`1.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Dfa/SingletonEdgeMap`1.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using Antlr4.Runtime.Sharpen;
 
diff --git a/runtime/CSharp/Antlr4.Runtime/Dfa/SparseEdgeMap`1.cs b/runtime/CSharp/Antlr4.Runtime/Dfa/SparseEdgeMap`1.cs
index f4b74b17..b1956296 100644
--- a/runtime/CSharp/Antlr4.Runtime/Dfa/SparseEdgeMap`1.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Dfa/SparseEdgeMap`1.cs
@@ -2,12 +2,13 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
+using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Dfa
@@ -33,7 +34,7 @@ public SparseEdgeMap(int minIndex, int maxIndex, int maxSparseSize)
             this.values = new List<T>(maxSparseSize);
         }
 
-        private SparseEdgeMap(Antlr4.Runtime.Dfa.SparseEdgeMap<T> map, int maxSparseSize)
+        private SparseEdgeMap([NotNull] Antlr4.Runtime.Dfa.SparseEdgeMap<T> map, int maxSparseSize)
             : base(map.minIndex, map.maxIndex)
         {
             lock (map)
diff --git a/runtime/CSharp/Antlr4.Runtime/DiagnosticErrorListener.cs b/runtime/CSharp/Antlr4.Runtime/DiagnosticErrorListener.cs
index 2bd052c8..2b399fd5 100644
--- a/runtime/CSharp/Antlr4.Runtime/DiagnosticErrorListener.cs
+++ b/runtime/CSharp/Antlr4.Runtime/DiagnosticErrorListener.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Atn;
 using Antlr4.Runtime.Dfa;
 using Antlr4.Runtime.Misc;
@@ -74,7 +74,7 @@ public DiagnosticErrorListener(bool exactOnly)
             this.exactOnly = exactOnly;
         }
 
-        public override void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, bool exact, BitSet ambigAlts, ATNConfigSet configs)
+        public override void ReportAmbiguity([NotNull] Parser recognizer, [NotNull] DFA dfa, int startIndex, int stopIndex, bool exact, [Nullable] BitSet ambigAlts, [NotNull] ATNConfigSet configs)
         {
             if (exactOnly && !exact)
             {
@@ -88,7 +88,7 @@ public override void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex,
             recognizer.NotifyErrorListeners(message);
         }
 
-        public override void ReportAttemptingFullContext(Parser recognizer, DFA dfa, int startIndex, int stopIndex, BitSet conflictingAlts, SimulatorState conflictState)
+        public override void ReportAttemptingFullContext([NotNull] Parser recognizer, [NotNull] DFA dfa, int startIndex, int stopIndex, [Nullable] BitSet conflictingAlts, [NotNull] SimulatorState conflictState)
         {
             string format = "reportAttemptingFullContext d=%s, input='%s'";
             string decision = GetDecisionDescription(recognizer, dfa);
@@ -97,7 +97,7 @@ public override void ReportAttemptingFullContext(Parser recognizer, DFA dfa, int
             recognizer.NotifyErrorListeners(message);
         }
 
-        public override void ReportContextSensitivity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, int prediction, SimulatorState acceptState)
+        public override void ReportContextSensitivity([NotNull] Parser recognizer, [NotNull] DFA dfa, int startIndex, int stopIndex, int prediction, [NotNull] SimulatorState acceptState)
         {
             string format = "reportContextSensitivity d=%s, input='%s'";
             string decision = GetDecisionDescription(recognizer, dfa);
@@ -106,7 +106,7 @@ public override void ReportContextSensitivity(Parser recognizer, DFA dfa, int st
             recognizer.NotifyErrorListeners(message);
         }
 
-        protected internal virtual string GetDecisionDescription<T>(Parser recognizer, DFA dfa)
+        protected internal virtual string GetDecisionDescription<T>([NotNull] Parser recognizer, [NotNull] DFA dfa)
             where T : IToken
         {
             int decision = dfa.decision;
@@ -145,7 +145,7 @@ protected internal virtual string GetDecisionDescription<T>(Parser recognizer, D
         /// .
         /// </returns>
         [NotNull]
-        protected internal virtual BitSet GetConflictingAlts(BitSet reportedAlts, ATNConfigSet configs)
+        protected internal virtual BitSet GetConflictingAlts([Nullable] BitSet reportedAlts, [NotNull] ATNConfigSet configs)
         {
             if (reportedAlts != null)
             {
diff --git a/runtime/CSharp/Antlr4.Runtime/FailedPredicateException.cs b/runtime/CSharp/Antlr4.Runtime/FailedPredicateException.cs
index de05fb29..3d774b71 100644
--- a/runtime/CSharp/Antlr4.Runtime/FailedPredicateException.cs
+++ b/runtime/CSharp/Antlr4.Runtime/FailedPredicateException.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Globalization;
 using Antlr4.Runtime.Atn;
 using Antlr4.Runtime.Misc;
@@ -31,17 +31,17 @@ public class FailedPredicateException : RecognitionException
 
         private readonly string predicate;
 
-        public FailedPredicateException(Parser recognizer)
+        public FailedPredicateException([NotNull] Parser recognizer)
             : this(recognizer, null)
         {
         }
 
-        public FailedPredicateException(Parser recognizer, string predicate)
+        public FailedPredicateException([NotNull] Parser recognizer, [Nullable] string predicate)
             : this(recognizer, predicate, null)
         {
         }
 
-        public FailedPredicateException(Parser recognizer, string predicate, string message)
+        public FailedPredicateException([NotNull] Parser recognizer, [Nullable] string predicate, [Nullable] string message)
             : base(FormatMessage(predicate, message), recognizer, ((ITokenStream)recognizer.InputStream), recognizer._ctx)
         {
             ATNState s = recognizer.Interpreter.atn.states[recognizer.State];
@@ -85,7 +85,7 @@ public virtual string Predicate
         }
 
         [NotNull]
-        private static string FormatMessage(string predicate, string message)
+        private static string FormatMessage([Nullable] string predicate, [Nullable] string message)
         {
             if (message != null)
             {
diff --git a/runtime/CSharp/Antlr4.Runtime/IAntlrErrorListener`1.cs b/runtime/CSharp/Antlr4.Runtime/IAntlrErrorListener`1.cs
index 5ef0f488..bd0de80b 100644
--- a/runtime/CSharp/Antlr4.Runtime/IAntlrErrorListener`1.cs
+++ b/runtime/CSharp/Antlr4.Runtime/IAntlrErrorListener`1.cs
@@ -2,10 +2,11 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime
@@ -50,7 +51,7 @@ public interface IAntlrErrorListener<Symbol>
         /// the parser was able to recover in line without exiting the
         /// surrounding rule.
         /// </param>
-        void SyntaxError<T>(Recognizer<T, object> recognizer, T offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
+        void SyntaxError<T>([NotNull] Recognizer<T, object> recognizer, [Nullable] T offendingSymbol, int line, int charPositionInLine, [NotNull] string msg, [Nullable] RecognitionException e)
             where T : Symbol;
     }
 }
diff --git a/runtime/CSharp/Antlr4.Runtime/IAntlrErrorStrategy.cs b/runtime/CSharp/Antlr4.Runtime/IAntlrErrorStrategy.cs
index 121f6575..3193a2b8 100644
--- a/runtime/CSharp/Antlr4.Runtime/IAntlrErrorStrategy.cs
+++ b/runtime/CSharp/Antlr4.Runtime/IAntlrErrorStrategy.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
@@ -38,7 +38,7 @@ public interface IAntlrErrorStrategy
         /// .
         /// </summary>
         /// <param name="recognizer">the parser instance</param>
-        void Reset(Parser recognizer);
+        void Reset([NotNull] Parser recognizer);
 
         /// <summary>
         /// This method is called when an unexpected symbol is encountered during an
@@ -67,7 +67,7 @@ public interface IAntlrErrorStrategy
         /// </exception>
         /// <exception cref="Antlr4.Runtime.RecognitionException"/>
         [NotNull]
-        IToken RecoverInline(Parser recognizer);
+        IToken RecoverInline([NotNull] Parser recognizer);
 
         /// <summary>
         /// This method is called to recover from exception
@@ -86,7 +86,7 @@ public interface IAntlrErrorStrategy
         /// the recognition exception
         /// </exception>
         /// <exception cref="Antlr4.Runtime.RecognitionException"/>
-        void Recover(Parser recognizer, RecognitionException e);
+        void Recover([NotNull] Parser recognizer, [NotNull] RecognitionException e);
 
         /// <summary>
         /// This method provides the error handler with an opportunity to handle
@@ -113,7 +113,7 @@ public interface IAntlrErrorStrategy
         /// the parsing process
         /// </exception>
         /// <exception cref="Antlr4.Runtime.RecognitionException"/>
-        void Sync(Parser recognizer);
+        void Sync([NotNull] Parser recognizer);
 
         /// <summary>
         /// Tests whether or not
@@ -136,14 +136,14 @@ public interface IAntlrErrorStrategy
         /// error, otherwise
         /// <see langword="false"/>
         /// </returns>
-        bool InErrorRecoveryMode(Parser recognizer);
+        bool InErrorRecoveryMode([NotNull] Parser recognizer);
 
         /// <summary>
         /// This method is called by when the parser successfully matches an input
         /// symbol.
         /// </summary>
         /// <param name="recognizer">the parser instance</param>
-        void ReportMatch(Parser recognizer);
+        void ReportMatch([NotNull] Parser recognizer);
 
         /// <summary>
         /// Report any kind of
@@ -153,6 +153,6 @@ public interface IAntlrErrorStrategy
         /// </summary>
         /// <param name="recognizer">the parser instance</param>
         /// <param name="e">the recognition exception to report</param>
-        void ReportError(Parser recognizer, RecognitionException e);
+        void ReportError([NotNull] Parser recognizer, [NotNull] RecognitionException e);
     }
 }
diff --git a/runtime/CSharp/Antlr4.Runtime/ICharStream.cs b/runtime/CSharp/Antlr4.Runtime/ICharStream.cs
index 899737da..2641c1f4 100644
--- a/runtime/CSharp/Antlr4.Runtime/ICharStream.cs
+++ b/runtime/CSharp/Antlr4.Runtime/ICharStream.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
@@ -51,6 +51,6 @@ public interface ICharStream : IIntStream
         /// getting the text of the specified interval
         /// </exception>
         [NotNull]
-        string GetText(Interval interval);
+        string GetText([NotNull] Interval interval);
     }
 }
diff --git a/runtime/CSharp/Antlr4.Runtime/IIntStream.cs b/runtime/CSharp/Antlr4.Runtime/IIntStream.cs
index 0edaf338..418cf44a 100644
--- a/runtime/CSharp/Antlr4.Runtime/IIntStream.cs
+++ b/runtime/CSharp/Antlr4.Runtime/IIntStream.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime
diff --git a/runtime/CSharp/Antlr4.Runtime/IParserErrorListener.cs b/runtime/CSharp/Antlr4.Runtime/IParserErrorListener.cs
index 2b7db691..2e93ddd3 100644
--- a/runtime/CSharp/Antlr4.Runtime/IParserErrorListener.cs
+++ b/runtime/CSharp/Antlr4.Runtime/IParserErrorListener.cs
@@ -2,12 +2,13 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Atn;
 using Antlr4.Runtime.Dfa;
+using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime
@@ -90,7 +91,7 @@ public interface IParserErrorListener : IAntlrErrorListener<IToken>
         /// the ATN configuration set where the ambiguity was
         /// identified
         /// </param>
-        void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, bool exact, BitSet ambigAlts, ATNConfigSet configs);
+        void ReportAmbiguity([NotNull] Parser recognizer, [NotNull] DFA dfa, int startIndex, int stopIndex, bool exact, [Nullable] BitSet ambigAlts, [NotNull] ATNConfigSet configs);
 
         /// <summary>
         /// This method is called when an SLL conflict occurs and the parser is about
@@ -124,7 +125,7 @@ public interface IParserErrorListener : IAntlrErrorListener<IToken>
         /// the simulator state when the SLL conflict was
         /// detected
         /// </param>
-        void ReportAttemptingFullContext(Parser recognizer, DFA dfa, int startIndex, int stopIndex, BitSet conflictingAlts, SimulatorState conflictState);
+        void ReportAttemptingFullContext([NotNull] Parser recognizer, [NotNull] DFA dfa, int startIndex, int stopIndex, [Nullable] BitSet conflictingAlts, [NotNull] SimulatorState conflictState);
 
         /// <summary>
         /// This method is called by the parser when a full-context prediction has a
@@ -175,6 +176,6 @@ public interface IParserErrorListener : IAntlrErrorListener<IToken>
         /// the simulator state when the unambiguous prediction
         /// was determined
         /// </param>
-        void ReportContextSensitivity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, int prediction, SimulatorState acceptState);
+        void ReportContextSensitivity([NotNull] Parser recognizer, [NotNull] DFA dfa, int startIndex, int stopIndex, int prediction, [NotNull] SimulatorState acceptState);
     }
 }
diff --git a/runtime/CSharp/Antlr4.Runtime/IToken.cs b/runtime/CSharp/Antlr4.Runtime/IToken.cs
index e3bf5177..8dd383f1 100644
--- a/runtime/CSharp/Antlr4.Runtime/IToken.cs
+++ b/runtime/CSharp/Antlr4.Runtime/IToken.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime
diff --git a/runtime/CSharp/Antlr4.Runtime/ITokenFactory.cs b/runtime/CSharp/Antlr4.Runtime/ITokenFactory.cs
index 1af8e32a..341a805a 100644
--- a/runtime/CSharp/Antlr4.Runtime/ITokenFactory.cs
+++ b/runtime/CSharp/Antlr4.Runtime/ITokenFactory.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
diff --git a/runtime/CSharp/Antlr4.Runtime/ITokenSource.cs b/runtime/CSharp/Antlr4.Runtime/ITokenSource.cs
index 9eab36c1..506cd744 100644
--- a/runtime/CSharp/Antlr4.Runtime/ITokenSource.cs
+++ b/runtime/CSharp/Antlr4.Runtime/ITokenSource.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
diff --git a/runtime/CSharp/Antlr4.Runtime/ITokenStream.cs b/runtime/CSharp/Antlr4.Runtime/ITokenStream.cs
index 9eeccbd8..a676c7c4 100644
--- a/runtime/CSharp/Antlr4.Runtime/ITokenStream.cs
+++ b/runtime/CSharp/Antlr4.Runtime/ITokenStream.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
@@ -117,7 +117,7 @@ ITokenSource TokenSource
         /// <see langword="null"/>
         /// </exception>
         [NotNull]
-        string GetText(Interval interval);
+        string GetText([NotNull] Interval interval);
 
         /// <summary>Return the text of all tokens in the stream.</summary>
         /// <remarks>
@@ -167,7 +167,7 @@ ITokenSource TokenSource
         /// .
         /// </returns>
         [NotNull]
-        string GetText(RuleContext ctx);
+        string GetText([NotNull] RuleContext ctx);
 
         /// <summary>
         /// Return the text of all tokens in this stream between
diff --git a/runtime/CSharp/Antlr4.Runtime/IVocabulary.cs b/runtime/CSharp/Antlr4.Runtime/IVocabulary.cs
index c447f24a..b313dc62 100644
--- a/runtime/CSharp/Antlr4.Runtime/IVocabulary.cs
+++ b/runtime/CSharp/Antlr4.Runtime/IVocabulary.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
diff --git a/runtime/CSharp/Antlr4.Runtime/IWritableToken.cs b/runtime/CSharp/Antlr4.Runtime/IWritableToken.cs
index bf29bb23..c7bb88ea 100644
--- a/runtime/CSharp/Antlr4.Runtime/IWritableToken.cs
+++ b/runtime/CSharp/Antlr4.Runtime/IWritableToken.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime
diff --git a/runtime/CSharp/Antlr4.Runtime/InputMismatchException.cs b/runtime/CSharp/Antlr4.Runtime/InputMismatchException.cs
index 61e02d90..015cb7fc 100644
--- a/runtime/CSharp/Antlr4.Runtime/InputMismatchException.cs
+++ b/runtime/CSharp/Antlr4.Runtime/InputMismatchException.cs
@@ -2,10 +2,11 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime
@@ -19,7 +20,7 @@ public class InputMismatchException : RecognitionException
     {
         private const long serialVersionUID = 1532568338707443067L;
 
-        public InputMismatchException(Parser recognizer)
+        public InputMismatchException([NotNull] Parser recognizer)
             : base(recognizer, ((ITokenStream)recognizer.InputStream), recognizer._ctx)
         {
             this.OffendingToken = recognizer.CurrentToken;
diff --git a/runtime/CSharp/Antlr4.Runtime/InterpreterRuleContext.cs b/runtime/CSharp/Antlr4.Runtime/InterpreterRuleContext.cs
index 1e4a35a3..72693d16 100644
--- a/runtime/CSharp/Antlr4.Runtime/InterpreterRuleContext.cs
+++ b/runtime/CSharp/Antlr4.Runtime/InterpreterRuleContext.cs
@@ -2,10 +2,11 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime
@@ -44,7 +45,7 @@ public class InterpreterRuleContext : ParserRuleContext
         /// <param name="parent">The parent context.</param>
         /// <param name="invokingStateNumber">The invoking state number.</param>
         /// <param name="ruleIndex">The rule index for the current context.</param>
-        public InterpreterRuleContext(ParserRuleContext parent, int invokingStateNumber, int ruleIndex)
+        public InterpreterRuleContext([Nullable] ParserRuleContext parent, int invokingStateNumber, int ruleIndex)
             : base(parent, invokingStateNumber)
         {
             this.ruleIndex = ruleIndex;
diff --git a/runtime/CSharp/Antlr4.Runtime/Lexer.cs b/runtime/CSharp/Antlr4.Runtime/Lexer.cs
index 4e948c7b..965eec68 100644
--- a/runtime/CSharp/Antlr4.Runtime/Lexer.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Lexer.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using System.Text;
diff --git a/runtime/CSharp/Antlr4.Runtime/LexerInterpreter.cs b/runtime/CSharp/Antlr4.Runtime/LexerInterpreter.cs
index 209618b9..144531b7 100644
--- a/runtime/CSharp/Antlr4.Runtime/LexerInterpreter.cs
+++ b/runtime/CSharp/Antlr4.Runtime/LexerInterpreter.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using Antlr4.Runtime.Atn;
@@ -36,7 +36,7 @@ public LexerInterpreter(string grammarFileName, ICollection<string> tokenNames,
         {
         }
 
-        public LexerInterpreter(string grammarFileName, IVocabulary vocabulary, ICollection<string> ruleNames, ICollection<string> modeNames, ATN atn, ICharStream input)
+        public LexerInterpreter(string grammarFileName, [NotNull] IVocabulary vocabulary, ICollection<string> ruleNames, ICollection<string> modeNames, ATN atn, ICharStream input)
             : base(input)
         {
             if (atn.grammarType != ATNType.Lexer)
diff --git a/runtime/CSharp/Antlr4.Runtime/LexerNoViableAltException.cs b/runtime/CSharp/Antlr4.Runtime/LexerNoViableAltException.cs
index eb3f95d1..03c0315b 100644
--- a/runtime/CSharp/Antlr4.Runtime/LexerNoViableAltException.cs
+++ b/runtime/CSharp/Antlr4.Runtime/LexerNoViableAltException.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Globalization;
 using Antlr4.Runtime.Atn;
 using Antlr4.Runtime.Misc;
@@ -25,7 +25,7 @@ public class LexerNoViableAltException : RecognitionException
         [Nullable]
         private readonly ATNConfigSet deadEndConfigs;
 
-        public LexerNoViableAltException(Lexer lexer, ICharStream input, int startIndex, ATNConfigSet deadEndConfigs)
+        public LexerNoViableAltException([Nullable] Lexer lexer, [NotNull] ICharStream input, int startIndex, [Nullable] ATNConfigSet deadEndConfigs)
             : base(lexer, input)
         {
             this.startIndex = startIndex;
diff --git a/runtime/CSharp/Antlr4.Runtime/ListTokenSource.cs b/runtime/CSharp/Antlr4.Runtime/ListTokenSource.cs
index e28f7615..858d467c 100644
--- a/runtime/CSharp/Antlr4.Runtime/ListTokenSource.cs
+++ b/runtime/CSharp/Antlr4.Runtime/ListTokenSource.cs
@@ -2,12 +2,13 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
+using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime
@@ -96,7 +97,7 @@ public class ListTokenSource : ITokenSource
         /// is
         /// <see langword="null"/>
         /// </exception>
-        public ListTokenSource(IList<IToken> tokens)
+        public ListTokenSource([NotNull] IList<IToken> tokens)
             : this(tokens, null)
         {
         }
@@ -136,7 +137,7 @@ public ListTokenSource(IList<IToken> tokens)
         /// is
         /// <see langword="null"/>
         /// </exception>
-        public ListTokenSource(IList<IToken> tokens, string sourceName)
+        public ListTokenSource([NotNull] IList<IToken> tokens, string sourceName)
         {
             if (tokens == null)
             {
diff --git a/runtime/CSharp/Antlr4.Runtime/Misc/Args.cs b/runtime/CSharp/Antlr4.Runtime/Misc/Args.cs
index 30dcbacb..a6633e1d 100644
--- a/runtime/CSharp/Antlr4.Runtime/Misc/Args.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Misc/Args.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using Antlr4.Runtime.Sharpen;
 
diff --git a/runtime/CSharp/Antlr4.Runtime/Misc/Array2DHashSet`1.cs b/runtime/CSharp/Antlr4.Runtime/Misc/Array2DHashSet`1.cs
index 3b76712c..db0dad0c 100644
--- a/runtime/CSharp/Antlr4.Runtime/Misc/Array2DHashSet`1.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Misc/Array2DHashSet`1.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using System.Text;
@@ -44,12 +44,12 @@ public Array2DHashSet()
         {
         }
 
-        public Array2DHashSet(EqualityComparer<T> comparator)
+        public Array2DHashSet([Nullable] EqualityComparer<T> comparator)
             : this(comparator, InitalCapacity, InitalBucketCapacity)
         {
         }
 
-        public Array2DHashSet(EqualityComparer<T> comparator, int initialCapacity, int initialBucketCapacity)
+        public Array2DHashSet([Nullable] EqualityComparer<T> comparator, int initialCapacity, int initialBucketCapacity)
         {
             // must be power of 2
             // when to expand
@@ -272,7 +272,7 @@ public bool Contains(object o)
             return ContainsFast(AsElementType(o));
         }
 
-        public virtual bool ContainsFast(T obj)
+        public virtual bool ContainsFast([Nullable] T obj)
         {
             if (obj == null)
             {
@@ -340,7 +340,7 @@ public bool Remove(object o)
             return RemoveFast(AsElementType(o));
         }
 
-        public virtual bool RemoveFast(T obj)
+        public virtual bool RemoveFast([Nullable] T obj)
         {
             if (obj == null)
             {
diff --git a/runtime/CSharp/Antlr4.Runtime/Misc/DoubleKeyMap`3.cs b/runtime/CSharp/Antlr4.Runtime/Misc/DoubleKeyMap`3.cs
index 00927346..9b37b5c1 100644
--- a/runtime/CSharp/Antlr4.Runtime/Misc/DoubleKeyMap`3.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Misc/DoubleKeyMap`3.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using Antlr4.Runtime.Sharpen;
 
diff --git a/runtime/CSharp/Antlr4.Runtime/Misc/IIntSet.cs b/runtime/CSharp/Antlr4.Runtime/Misc/IIntSet.cs
index 86f05c92..9367b259 100644
--- a/runtime/CSharp/Antlr4.Runtime/Misc/IIntSet.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Misc/IIntSet.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using Antlr4.Runtime.Sharpen;
 
@@ -47,7 +47,7 @@ public interface IIntSet
         /// if the current set is read-only
         /// </exception>
         [NotNull]
-        IIntSet AddAll(IIntSet set);
+        IIntSet AddAll([Nullable] IIntSet set);
 
         /// <summary>
         /// Return a new
@@ -74,7 +74,7 @@ public interface IIntSet
         /// place of an empty result set.
         /// </returns>
         [Nullable]
-        IIntSet And(IIntSet a);
+        IIntSet And([Nullable] IIntSet a);
 
         /// <summary>
         /// Return a new
@@ -114,7 +114,7 @@ public interface IIntSet
         /// may be returned in place of an empty result set.
         /// </returns>
         [Nullable]
-        IIntSet Complement(IIntSet elements);
+        IIntSet Complement([Nullable] IIntSet elements);
 
         /// <summary>
         /// Return a new
@@ -148,7 +148,7 @@ public interface IIntSet
         /// empty result set.
         /// </returns>
         [Nullable]
-        IIntSet Or(IIntSet a);
+        IIntSet Or([Nullable] IIntSet a);
 
         /// <summary>
         /// Return a new
@@ -188,7 +188,7 @@ public interface IIntSet
         /// may be returned in place of an empty result set.
         /// </returns>
         [Nullable]
-        IIntSet Subtract(IIntSet a);
+        IIntSet Subtract([Nullable] IIntSet a);
 
         /// <summary>Return the total number of elements represented by the current set.</summary>
         /// <returns>
diff --git a/runtime/CSharp/Antlr4.Runtime/Misc/Interval.cs b/runtime/CSharp/Antlr4.Runtime/Misc/Interval.cs
index f2d76d06..d51dd722 100644
--- a/runtime/CSharp/Antlr4.Runtime/Misc/Interval.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Misc/Interval.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using Antlr4.Runtime.Sharpen;
 
diff --git a/runtime/CSharp/Antlr4.Runtime/Misc/IntervalSet.cs b/runtime/CSharp/Antlr4.Runtime/Misc/IntervalSet.cs
index 7a2e4aef..cbd95f4b 100644
--- a/runtime/CSharp/Antlr4.Runtime/Misc/IntervalSet.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Misc/IntervalSet.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using System.Text;
@@ -286,7 +286,7 @@ public virtual Antlr4.Runtime.Misc.IntervalSet Subtract(IIntSet a)
         /// , it is treated as though it was an empty set.
         /// </remarks>
         [NotNull]
-        public static Antlr4.Runtime.Misc.IntervalSet Subtract(Antlr4.Runtime.Misc.IntervalSet left, Antlr4.Runtime.Misc.IntervalSet right)
+        public static Antlr4.Runtime.Misc.IntervalSet Subtract([Nullable] Antlr4.Runtime.Misc.IntervalSet left, [Nullable] Antlr4.Runtime.Misc.IntervalSet right)
         {
             if (left == null || left.IsNil)
             {
@@ -511,18 +511,18 @@ public virtual bool IsNil
         {
             get
             {
-                /*
-                for (ListIterator iter = intervals.listIterator(); iter.hasNext();) {
-                Interval I = (Interval) iter.next();
-                if ( el<I.a ) {
+/*
+		for (ListIterator iter = intervals.listIterator(); iter.hasNext();) {
+            Interval I = (Interval) iter.next();
+            if ( el<I.a ) {
                 break; // list is sorted and el is before this interval; not here
-                }
-                if ( el>=I.a && el<=I.b ) {
+            }
+            if ( el>=I.a && el<=I.b ) {
                 return true; // found in this interval
-                }
-                }
-                return false;
-                */
+            }
+        }
+        return false;
+        */
                 return intervals == null || intervals.IsEmpty();
             }
         }
@@ -694,7 +694,7 @@ public virtual string ToString(string[] tokenNames)
             return ToString(Vocabulary.FromTokenNames(tokenNames));
         }
 
-        public virtual string ToString(IVocabulary vocabulary)
+        public virtual string ToString([NotNull] IVocabulary vocabulary)
         {
             StringBuilder buf = new StringBuilder();
             if (this.intervals == null || this.intervals.IsEmpty())
@@ -745,7 +745,7 @@ protected internal virtual string ElementName(string[] tokenNames, int a)
         }
 
         [NotNull]
-        protected internal virtual string ElementName(IVocabulary vocabulary, int a)
+        protected internal virtual string ElementName([NotNull] IVocabulary vocabulary, int a)
         {
             if (a == TokenConstants.Eof)
             {
diff --git a/runtime/CSharp/Antlr4.Runtime/Misc/MultiMap`2.cs b/runtime/CSharp/Antlr4.Runtime/Misc/MultiMap`2.cs
index 42ff0cca..d8411422 100644
--- a/runtime/CSharp/Antlr4.Runtime/Misc/MultiMap`2.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Misc/MultiMap`2.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using Antlr4.Runtime.Sharpen;
diff --git a/runtime/CSharp/Antlr4.Runtime/Misc/MurmurHash.cs b/runtime/CSharp/Antlr4.Runtime/Misc/MurmurHash.cs
index 7eb09cd4..264ce583 100644
--- a/runtime/CSharp/Antlr4.Runtime/Misc/MurmurHash.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Misc/MurmurHash.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Misc
diff --git a/runtime/CSharp/Antlr4.Runtime/Misc/OrderedHashSet`1.cs b/runtime/CSharp/Antlr4.Runtime/Misc/OrderedHashSet`1.cs
index 0870a047..6243fb6d 100644
--- a/runtime/CSharp/Antlr4.Runtime/Misc/OrderedHashSet`1.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Misc/OrderedHashSet`1.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using Antlr4.Runtime.Sharpen;
diff --git a/runtime/CSharp/Antlr4.Runtime/Misc/ParseCanceledException.cs b/runtime/CSharp/Antlr4.Runtime/Misc/ParseCanceledException.cs
index dee66fbf..915c7709 100644
--- a/runtime/CSharp/Antlr4.Runtime/Misc/ParseCanceledException.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Misc/ParseCanceledException.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using Antlr4.Runtime.Sharpen;
 
diff --git a/runtime/CSharp/Antlr4.Runtime/Misc/RuleDependencyChecker.cs b/runtime/CSharp/Antlr4.Runtime/Misc/RuleDependencyChecker.cs
index 04730515..4b6a93d5 100644
--- a/runtime/CSharp/Antlr4.Runtime/Misc/RuleDependencyChecker.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Misc/RuleDependencyChecker.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using System.Reflection;
diff --git a/runtime/CSharp/Antlr4.Runtime/Misc/RuleDependencyProcessor.cs b/runtime/CSharp/Antlr4.Runtime/Misc/RuleDependencyProcessor.cs
index f4ae8824..bfdb983a 100644
--- a/runtime/CSharp/Antlr4.Runtime/Misc/RuleDependencyProcessor.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Misc/RuleDependencyProcessor.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections;
 using System.Collections.Generic;
@@ -459,7 +459,7 @@ public enum RuleDependencyProperty
         }
 
         [Nullable]
-        private Tuple<IAnnotationMirror, IAnnotationValue> FindRuleDependencyProperty(Tuple<RuleDependency, IElement> dependency, RuleDependencyProcessor.RuleDependencyProperty property)
+        private Tuple<IAnnotationMirror, IAnnotationValue> FindRuleDependencyProperty([NotNull] Tuple<RuleDependency, IElement> dependency, [NotNull] RuleDependencyProcessor.RuleDependencyProperty property)
         {
             ITypeElement ruleDependencyTypeElement = processingEnv.GetElementUtils().GetTypeElement(RuleDependencyClassName);
             ITypeElement ruleDependenciesTypeElement = processingEnv.GetElementUtils().GetTypeElement(RuleDependenciesClassName);
@@ -516,7 +516,7 @@ private Tuple<IAnnotationMirror, IAnnotationValue> FindRuleDependencyProperty(Tu
         }
 
         [Nullable]
-        private IAnnotationValue FindRuleDependencyProperty(Tuple<RuleDependency, IElement> dependency, IAnnotationMirror annotationMirror, RuleDependencyProcessor.RuleDependencyProperty property)
+        private IAnnotationValue FindRuleDependencyProperty([NotNull] Tuple<RuleDependency, IElement> dependency, [NotNull] IAnnotationMirror annotationMirror, [NotNull] RuleDependencyProcessor.RuleDependencyProperty property)
         {
             IAnnotationValue recognizerValue = null;
             IAnnotationValue ruleValue = null;
diff --git a/runtime/CSharp/Antlr4.Runtime/Misc/TestRig.cs b/runtime/CSharp/Antlr4.Runtime/Misc/TestRig.cs
index aa351122..3f77d0dd 100644
--- a/runtime/CSharp/Antlr4.Runtime/Misc/TestRig.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Misc/TestRig.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Reflection;
 using Antlr4.Runtime.Sharpen;
diff --git a/runtime/CSharp/Antlr4.Runtime/Misc/Utils.cs b/runtime/CSharp/Antlr4.Runtime/Misc/Utils.cs
index a5d364d3..57c6b209 100644
--- a/runtime/CSharp/Antlr4.Runtime/Misc/Utils.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Misc/Utils.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using System.Text;
@@ -82,7 +82,7 @@ public static string EscapeWhitespace(string s, bool escapeSpaces)
             return buf.ToString();
         }
 
-        public static void RemoveAll<T, _T1>(IList<T> list, Predicate<_T1> predicate)
+        public static void RemoveAll<T, _T1>([NotNull] IList<T> list, Predicate<_T1> predicate)
         {
             int j = 0;
             for (int i = 0; i < list.Count; i++)
@@ -134,7 +134,7 @@ public static char[] ToCharArray(List<int> data)
 
         /// <since>4.5</since>
         [NotNull]
-        public static IntervalSet ToSet(BitSet bits)
+        public static IntervalSet ToSet([NotNull] BitSet bits)
         {
             IntervalSet s = new IntervalSet();
             int i = bits.NextSetBit(0);
diff --git a/runtime/CSharp/Antlr4.Runtime/NoViableAltException.cs b/runtime/CSharp/Antlr4.Runtime/NoViableAltException.cs
index e032de17..0677ce39 100644
--- a/runtime/CSharp/Antlr4.Runtime/NoViableAltException.cs
+++ b/runtime/CSharp/Antlr4.Runtime/NoViableAltException.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Atn;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -44,12 +44,12 @@ public class NoViableAltException : RecognitionException
         [NotNull]
         private readonly IToken startToken;
 
-        public NoViableAltException(Parser recognizer)
+        public NoViableAltException([NotNull] Parser recognizer)
             : this(recognizer, ((ITokenStream)recognizer.InputStream), recognizer.CurrentToken, recognizer.CurrentToken, null, recognizer._ctx)
         {
         }
 
-        public NoViableAltException(Recognizer<IToken, object> recognizer, ITokenStream input, IToken startToken, IToken offendingToken, ATNConfigSet deadEndConfigs, ParserRuleContext ctx)
+        public NoViableAltException([NotNull] Recognizer<IToken, object> recognizer, [NotNull] ITokenStream input, [NotNull] IToken startToken, [NotNull] IToken offendingToken, [Nullable] ATNConfigSet deadEndConfigs, [NotNull] ParserRuleContext ctx)
             : base(recognizer, input, ctx)
         {
             // LL(1) error
diff --git a/runtime/CSharp/Antlr4.Runtime/Parser.cs b/runtime/CSharp/Antlr4.Runtime/Parser.cs
index b0751715..b1e93a2f 100644
--- a/runtime/CSharp/Antlr4.Runtime/Parser.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Parser.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections;
 using System.Collections.Generic;
@@ -453,7 +453,7 @@ public virtual IList<IParseTreeListener> ParseListeners
         /// listener is
         /// <see langword="null"/>
         /// </exception>
-        public virtual void AddParseListener(IParseTreeListener listener)
+        public virtual void AddParseListener([NotNull] IParseTreeListener listener)
         {
             if (listener == null)
             {
@@ -659,12 +659,12 @@ public virtual IToken CurrentToken
             }
         }
 
-        public void NotifyErrorListeners(string msg)
+        public void NotifyErrorListeners([NotNull] string msg)
         {
             NotifyErrorListeners(CurrentToken, msg, null);
         }
 
-        public virtual void NotifyErrorListeners(IToken offendingToken, string msg, RecognitionException e)
+        public virtual void NotifyErrorListeners([NotNull] IToken offendingToken, [NotNull] string msg, [Nullable] RecognitionException e)
         {
             _syntaxErrors++;
             int line = -1;
@@ -763,7 +763,7 @@ protected internal virtual void AddContextToParseTree()
         /// <see cref="_ctx"/>
         /// get the current context.
         /// </remarks>
-        public virtual void EnterRule(ParserRuleContext localctx, int state, int ruleIndex)
+        public virtual void EnterRule([NotNull] ParserRuleContext localctx, int state, int ruleIndex)
         {
             State = state;
             _ctx = localctx;
@@ -955,7 +955,7 @@ public virtual ParserRuleContext Context
             }
         }
 
-        public override bool Precpred(RuleContext localctx, int precedence)
+        public override bool Precpred([Nullable] RuleContext localctx, int precedence)
         {
             return precedence >= _precedenceStack.Peek();
         }
diff --git a/runtime/CSharp/Antlr4.Runtime/ParserInterpreter.cs b/runtime/CSharp/Antlr4.Runtime/ParserInterpreter.cs
index 13e00e15..feab15d7 100644
--- a/runtime/CSharp/Antlr4.Runtime/ParserInterpreter.cs
+++ b/runtime/CSharp/Antlr4.Runtime/ParserInterpreter.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using Antlr4.Runtime.Atn;
@@ -103,7 +103,7 @@ public class ParserInterpreter : Parser
         /// </summary>
         /// <param name="old">The interpreter to copy</param>
         /// <since>4.5</since>
-        public ParserInterpreter(Antlr4.Runtime.ParserInterpreter old)
+        public ParserInterpreter([NotNull] Antlr4.Runtime.ParserInterpreter old)
             : base(((ITokenStream)old.InputStream))
         {
             // latch and only override once; error might trigger infinite loop
@@ -122,7 +122,7 @@ public ParserInterpreter(string grammarFileName, ICollection<string> tokenNames,
         {
         }
 
-        public ParserInterpreter(string grammarFileName, IVocabulary vocabulary, ICollection<string> ruleNames, ATN atn, ITokenStream input)
+        public ParserInterpreter(string grammarFileName, [NotNull] IVocabulary vocabulary, ICollection<string> ruleNames, ATN atn, ITokenStream input)
             : base(input)
         {
             this.grammarFileName = grammarFileName;
diff --git a/runtime/CSharp/Antlr4.Runtime/ParserRuleContext.cs b/runtime/CSharp/Antlr4.Runtime/ParserRuleContext.cs
index dc94029f..c464408d 100644
--- a/runtime/CSharp/Antlr4.Runtime/ParserRuleContext.cs
+++ b/runtime/CSharp/Antlr4.Runtime/ParserRuleContext.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using Antlr4.Runtime.Misc;
@@ -154,7 +154,7 @@ public virtual void CopyFrom(Antlr4.Runtime.ParserRuleContext ctx)
             }
         }
 
-        public ParserRuleContext(Antlr4.Runtime.ParserRuleContext parent, int invokingStateNumber)
+        public ParserRuleContext([Nullable] Antlr4.Runtime.ParserRuleContext parent, int invokingStateNumber)
             : base(parent, invokingStateNumber)
         {
         }
diff --git a/runtime/CSharp/Antlr4.Runtime/ProxyErrorListener`1.cs b/runtime/CSharp/Antlr4.Runtime/ProxyErrorListener`1.cs
index ceb051f0..cff6155c 100644
--- a/runtime/CSharp/Antlr4.Runtime/ProxyErrorListener`1.cs
+++ b/runtime/CSharp/Antlr4.Runtime/ProxyErrorListener`1.cs
@@ -2,12 +2,13 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
+using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime
@@ -41,10 +42,10 @@ protected internal virtual IEnumerable<IAntlrErrorListener<Symbol>> Delegates
             }
         }
 
-        public virtual void SyntaxError<T>(Recognizer<T, object> recognizer, T offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
+        public virtual void SyntaxError<T>([NotNull] Recognizer<T, object> recognizer, [Nullable] T offendingSymbol, int line, int charPositionInLine, [NotNull] string msg, [Nullable] RecognitionException e)
             where T : Symbol
         {
-            foreach (IAntlrErrorListener<Symbol> listener in delegates)
+            foreach (IAntlrErrorListener<T> listener in delegates)
             {
                 listener.SyntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
             }
diff --git a/runtime/CSharp/Antlr4.Runtime/ProxyParserErrorListener.cs b/runtime/CSharp/Antlr4.Runtime/ProxyParserErrorListener.cs
index d7e29d1d..41717592 100644
--- a/runtime/CSharp/Antlr4.Runtime/ProxyParserErrorListener.cs
+++ b/runtime/CSharp/Antlr4.Runtime/ProxyParserErrorListener.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using Antlr4.Runtime.Atn;
 using Antlr4.Runtime.Dfa;
diff --git a/runtime/CSharp/Antlr4.Runtime/RecognitionException.cs b/runtime/CSharp/Antlr4.Runtime/RecognitionException.cs
index 6202124e..f3e85bed 100644
--- a/runtime/CSharp/Antlr4.Runtime/RecognitionException.cs
+++ b/runtime/CSharp/Antlr4.Runtime/RecognitionException.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
@@ -50,14 +50,14 @@ public class RecognitionException : RuntimeException
 
         private int offendingState = -1;
 
-        public RecognitionException(Lexer lexer, ICharStream input)
+        public RecognitionException([Nullable] Lexer lexer, ICharStream input)
         {
             this.recognizer = lexer;
             this.input = input;
             this.ctx = null;
         }
 
-        public RecognitionException(Antlr4.Runtime.Recognizer<IToken, object> recognizer, IIntStream input, ParserRuleContext ctx)
+        public RecognitionException([Nullable] Antlr4.Runtime.Recognizer<IToken, object> recognizer, [Nullable] IIntStream input, [Nullable] ParserRuleContext ctx)
         {
             this.recognizer = recognizer;
             this.input = input;
@@ -68,7 +68,7 @@ public RecognitionException(Antlr4.Runtime.Recognizer<IToken, object> recognizer
             }
         }
 
-        public RecognitionException(string message, Antlr4.Runtime.Recognizer<IToken, object> recognizer, IIntStream input, ParserRuleContext ctx)
+        public RecognitionException(string message, [Nullable] Antlr4.Runtime.Recognizer<IToken, object> recognizer, [Nullable] IIntStream input, [Nullable] ParserRuleContext ctx)
             : base(message)
         {
             this.recognizer = recognizer;
diff --git a/runtime/CSharp/Antlr4.Runtime/Recognizer`2.cs b/runtime/CSharp/Antlr4.Runtime/Recognizer`2.cs
index 747783f1..66124940 100644
--- a/runtime/CSharp/Antlr4.Runtime/Recognizer`2.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Recognizer`2.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using Antlr4.Runtime.Atn;
@@ -231,7 +231,7 @@ public virtual Antlr4.Runtime.Atn.ParseInfo ParseInfo
 
         /// <summary>What is the error header, normally line/character position information?</summary>
         [NotNull]
-        public virtual string GetErrorHeader(RecognitionException e)
+        public virtual string GetErrorHeader([NotNull] RecognitionException e)
         {
             int line = e.OffendingToken.Line;
             int charPositionInLine = e.OffendingToken.Column;
@@ -319,17 +319,17 @@ public virtual IAntlrErrorListener<Symbol> ErrorListenerDispatch
 
         // subclass needs to override these if there are sempreds or actions
         // that the ATN interp needs to execute
-        public virtual bool Sempred(RuleContext _localctx, int ruleIndex, int actionIndex)
+        public virtual bool Sempred([Nullable] RuleContext _localctx, int ruleIndex, int actionIndex)
         {
             return true;
         }
 
-        public virtual bool Precpred(RuleContext localctx, int precedence)
+        public virtual bool Precpred([Nullable] RuleContext localctx, int precedence)
         {
             return true;
         }
 
-        public virtual void Action(RuleContext _localctx, int ruleIndex, int actionIndex)
+        public virtual void Action([Nullable] RuleContext _localctx, int ruleIndex, int actionIndex)
         {
         }
 
diff --git a/runtime/CSharp/Antlr4.Runtime/RuleContext.cs b/runtime/CSharp/Antlr4.Runtime/RuleContext.cs
index 3747fb22..577cf154 100644
--- a/runtime/CSharp/Antlr4.Runtime/RuleContext.cs
+++ b/runtime/CSharp/Antlr4.Runtime/RuleContext.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using System.Text;
 using Antlr4.Runtime.Atn;
@@ -235,7 +235,7 @@ public virtual T Accept<T, _T1>(IParseTreeVisitor<_T1> visitor)
         /// (root child1 .. childN). Print just a node if this is a leaf.
         /// We have to know the recognizer so we can get rule names.
         /// </remarks>
-        public virtual string ToStringTree(Parser recog)
+        public virtual string ToStringTree([Nullable] Parser recog)
         {
             return Trees.ToStringTree(this, recog);
         }
@@ -248,7 +248,7 @@ public virtual string ToStringTree(Parser recog)
         /// Print out a whole tree, not just a node, in LISP format
         /// (root child1 .. childN). Print just a node if this is a leaf.
         /// </remarks>
-        public virtual string ToStringTree(IList<string> ruleNames)
+        public virtual string ToStringTree([Nullable] IList<string> ruleNames)
         {
             return Trees.ToStringTree(this, ruleNames);
         }
@@ -268,20 +268,20 @@ public string ToString<_T0>(Recognizer<_T0> recog)
             return ToString(recog, ParserRuleContext.EmptyContext);
         }
 
-        public string ToString(IList<string> ruleNames)
+        public string ToString([Nullable] IList<string> ruleNames)
         {
             return ToString(ruleNames, null);
         }
 
         // recog null unless ParserRuleContext, in which case we use subclass toString(...)
-        public virtual string ToString<_T0>(Recognizer<_T0> recog, Antlr4.Runtime.RuleContext stop)
+        public virtual string ToString<_T0>(Recognizer<_T0> recog, [Nullable] Antlr4.Runtime.RuleContext stop)
         {
             string[] ruleNames = recog != null ? recog.RuleNames : null;
             IList<string> ruleNamesList = ruleNames != null ? Arrays.AsList(ruleNames) : null;
             return ToString(ruleNamesList, stop);
         }
 
-        public virtual string ToString(IList<string> ruleNames, Antlr4.Runtime.RuleContext stop)
+        public virtual string ToString([Nullable] IList<string> ruleNames, [Nullable] Antlr4.Runtime.RuleContext stop)
         {
             StringBuilder buf = new StringBuilder();
             Antlr4.Runtime.RuleContext p = this;
diff --git a/runtime/CSharp/Antlr4.Runtime/RuleContextWithAltNum.cs b/runtime/CSharp/Antlr4.Runtime/RuleContextWithAltNum.cs
index 53593ed9..61b4ff62 100644
--- a/runtime/CSharp/Antlr4.Runtime/RuleContextWithAltNum.cs
+++ b/runtime/CSharp/Antlr4.Runtime/RuleContextWithAltNum.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Atn;
 using Antlr4.Runtime.Sharpen;
 
diff --git a/runtime/CSharp/Antlr4.Runtime/TokenStreamRewriter.cs b/runtime/CSharp/Antlr4.Runtime/TokenStreamRewriter.cs
index 80bd6752..81780a0a 100644
--- a/runtime/CSharp/Antlr4.Runtime/TokenStreamRewriter.cs
+++ b/runtime/CSharp/Antlr4.Runtime/TokenStreamRewriter.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using System.Text;
@@ -354,7 +354,7 @@ public virtual void Replace(IToken from, IToken to, object text)
             Replace(DefaultProgramName, from, to, text);
         }
 
-        public virtual void Replace(string programName, int from, int to, object text)
+        public virtual void Replace(string programName, int from, int to, [Nullable] object text)
         {
             if (from > to || from < 0 || to < 0 || to >= tokens.Size)
             {
@@ -366,7 +366,7 @@ public virtual void Replace(string programName, int from, int to, object text)
             rewrites.Add(op);
         }
 
-        public virtual void Replace(string programName, IToken from, IToken to, object text)
+        public virtual void Replace(string programName, IToken from, IToken to, [Nullable] object text)
         {
             Replace(programName, from.TokenIndex, to.TokenIndex, text);
         }
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/AbstractParseTreeVisitor`1.cs b/runtime/CSharp/Antlr4.Runtime/Tree/AbstractParseTreeVisitor`1.cs
index a67d4c9e..4a0d285c 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/AbstractParseTreeVisitor`1.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/AbstractParseTreeVisitor`1.cs
@@ -2,10 +2,11 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Tree
@@ -19,7 +20,7 @@ public abstract class AbstractParseTreeVisitor<Result> : IParseTreeVisitor<Resul
         /// on the
         /// specified tree.</p>
         /// </summary>
-        public virtual Result Visit(IParseTree tree)
+        public virtual Result Visit([NotNull] IParseTree tree)
         {
             return tree.Accept(this);
         }
@@ -44,7 +45,7 @@ public virtual Result Visit(IParseTree tree)
         /// the tree structure. Visitors that modify the tree should override this
         /// method to behave properly in respect to the specific algorithm in use.</p>
         /// </summary>
-        public virtual Result VisitChildren(IRuleNode node)
+        public virtual Result VisitChildren([NotNull] IRuleNode node)
         {
             Result result = DefaultResult;
             int n = node.ChildCount;
@@ -67,7 +68,7 @@ public virtual Result VisitChildren(IRuleNode node)
         /// <see cref="AbstractParseTreeVisitor{Result}.DefaultResult()">defaultResult</see>
         /// .</p>
         /// </summary>
-        public virtual Result VisitTerminal(ITerminalNode node)
+        public virtual Result VisitTerminal([NotNull] ITerminalNode node)
         {
             return DefaultResult;
         }
@@ -78,7 +79,7 @@ public virtual Result VisitTerminal(ITerminalNode node)
         /// <see cref="AbstractParseTreeVisitor{Result}.DefaultResult()">defaultResult</see>
         /// .</p>
         /// </summary>
-        public virtual Result VisitErrorNode(IErrorNode node)
+        public virtual Result VisitErrorNode([NotNull] IErrorNode node)
         {
             return DefaultResult;
         }
@@ -185,7 +186,7 @@ protected internal virtual Result AggregateResult(Result aggregate, Result nextR
         /// <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
         /// .
         /// </returns>
-        protected internal virtual bool ShouldVisitNextChild(IRuleNode node, Result currentResult)
+        protected internal virtual bool ShouldVisitNextChild([NotNull] IRuleNode node, Result currentResult)
         {
             return true;
         }
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/ErrorNodeImpl.cs b/runtime/CSharp/Antlr4.Runtime/Tree/ErrorNodeImpl.cs
index fbdf9c1e..85b737ab 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/ErrorNodeImpl.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/ErrorNodeImpl.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
 using Antlr4.Runtime.Sharpen;
 
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/IErrorNode.cs b/runtime/CSharp/Antlr4.Runtime/Tree/IErrorNode.cs
index 8261dd41..db3f2328 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/IErrorNode.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/IErrorNode.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Tree
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/IParseTree.cs b/runtime/CSharp/Antlr4.Runtime/Tree/IParseTree.cs
index 3c0b06e1..b3e7b1b4 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/IParseTree.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/IParseTree.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
 using Antlr4.Runtime.Sharpen;
 
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/IParseTreeListener.cs b/runtime/CSharp/Antlr4.Runtime/Tree/IParseTreeListener.cs
index d9f15018..ba5ef82c 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/IParseTreeListener.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/IParseTreeListener.cs
@@ -2,11 +2,12 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
+using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Tree
@@ -24,12 +25,12 @@ namespace Antlr4.Runtime.Tree
     /// </summary>
     public interface IParseTreeListener
     {
-        void VisitTerminal(ITerminalNode node);
+        void VisitTerminal([NotNull] ITerminalNode node);
 
-        void VisitErrorNode(IErrorNode node);
+        void VisitErrorNode([NotNull] IErrorNode node);
 
-        void EnterEveryRule(ParserRuleContext ctx);
+        void EnterEveryRule([NotNull] ParserRuleContext ctx);
 
-        void ExitEveryRule(ParserRuleContext ctx);
+        void ExitEveryRule([NotNull] ParserRuleContext ctx);
     }
 }
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/IParseTreeVisitor`1.cs b/runtime/CSharp/Antlr4.Runtime/Tree/IParseTreeVisitor`1.cs
index c1215d22..22e33c96 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/IParseTreeVisitor`1.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/IParseTreeVisitor`1.cs
@@ -2,10 +2,11 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Tree
@@ -31,7 +32,7 @@ public interface IParseTreeVisitor<Result>
         /// to visit.
         /// </param>
         /// <returns>The result of visiting the parse tree.</returns>
-        Result Visit(IParseTree tree);
+        Result Visit([NotNull] IParseTree tree);
 
         /// <summary>
         /// Visit the children of a node, and return a user-defined result
@@ -43,7 +44,7 @@ public interface IParseTreeVisitor<Result>
         /// whose children should be visited.
         /// </param>
         /// <returns>The result of visiting the children of the node.</returns>
-        Result VisitChildren(IRuleNode node);
+        Result VisitChildren([NotNull] IRuleNode node);
 
         /// <summary>Visit a terminal node, and return a user-defined result of the operation.</summary>
         /// <param name="node">
@@ -52,7 +53,7 @@ public interface IParseTreeVisitor<Result>
         /// to visit.
         /// </param>
         /// <returns>The result of visiting the node.</returns>
-        Result VisitTerminal(ITerminalNode node);
+        Result VisitTerminal([NotNull] ITerminalNode node);
 
         /// <summary>Visit an error node, and return a user-defined result of the operation.</summary>
         /// <param name="node">
@@ -61,6 +62,6 @@ public interface IParseTreeVisitor<Result>
         /// to visit.
         /// </param>
         /// <returns>The result of visiting the node.</returns>
-        Result VisitErrorNode(IErrorNode node);
+        Result VisitErrorNode([NotNull] IErrorNode node);
     }
 }
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/IRuleNode.cs b/runtime/CSharp/Antlr4.Runtime/Tree/IRuleNode.cs
index e04336ea..e45238ff 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/IRuleNode.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/IRuleNode.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Tree
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/ISyntaxTree.cs b/runtime/CSharp/Antlr4.Runtime/Tree/ISyntaxTree.cs
index 851f7e63..5fa1fe48 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/ISyntaxTree.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/ISyntaxTree.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/ITerminalNode.cs b/runtime/CSharp/Antlr4.Runtime/Tree/ITerminalNode.cs
index 88ad66dc..e949beca 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/ITerminalNode.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/ITerminalNode.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
 using Antlr4.Runtime.Sharpen;
 
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/ITree.cs b/runtime/CSharp/Antlr4.Runtime/Tree/ITree.cs
index d7c743e1..f353ee34 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/ITree.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/ITree.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Tree
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/ParseTreeProperty`1.cs b/runtime/CSharp/Antlr4.Runtime/Tree/ParseTreeProperty`1.cs
index 11275098..cb10cc15 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/ParseTreeProperty`1.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/ParseTreeProperty`1.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using Antlr4.Runtime.Sharpen;
 
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/ParseTreeWalker.cs b/runtime/CSharp/Antlr4.Runtime/Tree/ParseTreeWalker.cs
index 8e118000..22a3b4ad 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/ParseTreeWalker.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/ParseTreeWalker.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using Antlr4.Runtime;
 using Antlr4.Runtime.Sharpen;
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/Chunk.cs b/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/Chunk.cs
index 5fc59522..19929f6c 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/Chunk.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/Chunk.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Tree.Pattern
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/ParseTreeMatch.cs b/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/ParseTreeMatch.cs
index 0458488d..6981614a 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/ParseTreeMatch.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/ParseTreeMatch.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using Antlr4.Runtime.Misc;
@@ -87,7 +87,7 @@ public class ParseTreeMatch
         /// is
         /// <see langword="null"/>
         /// </exception>
-        public ParseTreeMatch(IParseTree tree, ParseTreePattern pattern, MultiMap<string, IParseTree> labels, IParseTree mismatchedNode)
+        public ParseTreeMatch([NotNull] IParseTree tree, [NotNull] ParseTreePattern pattern, [NotNull] MultiMap<string, IParseTree> labels, [Nullable] IParseTree mismatchedNode)
         {
             if (tree == null)
             {
@@ -195,7 +195,7 @@ public virtual IParseTree Get(string label)
         /// is returned.
         /// </returns>
         [NotNull]
-        public virtual IList<IParseTree> GetAll(string label)
+        public virtual IList<IParseTree> GetAll([NotNull] string label)
         {
             IList<IParseTree> nodes = labels[label];
             if (nodes == null)
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/ParseTreePattern.cs b/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/ParseTreePattern.cs
index 64796829..d84dd254 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/ParseTreePattern.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/ParseTreePattern.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -77,7 +77,7 @@ public class ParseTreePattern
         /// <see cref="Antlr4.Runtime.Tree.IParseTree"/>
         /// form.
         /// </param>
-        public ParseTreePattern(ParseTreePatternMatcher matcher, string pattern, int patternRuleIndex, IParseTree patternTree)
+        public ParseTreePattern([NotNull] ParseTreePatternMatcher matcher, [NotNull] string pattern, int patternRuleIndex, [NotNull] IParseTree patternTree)
         {
             this.matcher = matcher;
             this.patternRuleIndex = patternRuleIndex;
@@ -97,7 +97,7 @@ public ParseTreePattern(ParseTreePatternMatcher matcher, string pattern, int pat
         /// used to determine whether or not the match was successful.
         /// </returns>
         [NotNull]
-        public virtual ParseTreeMatch Match(IParseTree tree)
+        public virtual ParseTreeMatch Match([NotNull] IParseTree tree)
         {
             return matcher.Match(tree, this);
         }
@@ -114,7 +114,7 @@ public virtual ParseTreeMatch Match(IParseTree tree)
         /// <see langword="false"/>
         /// .
         /// </returns>
-        public virtual bool Matches(IParseTree tree)
+        public virtual bool Matches([NotNull] IParseTree tree)
         {
             return matcher.Match(tree, this).Succeeded;
         }
@@ -137,7 +137,7 @@ public virtual bool Matches(IParseTree tree)
         /// regardless of the reason for the failure.
         /// </returns>
         [NotNull]
-        public virtual IList<ParseTreeMatch> FindAll(IParseTree tree, string xpath)
+        public virtual IList<ParseTreeMatch> FindAll([NotNull] IParseTree tree, [NotNull] string xpath)
         {
             ICollection<IParseTree> subtrees = XPath.FindAll(tree, xpath, matcher.Parser);
             IList<ParseTreeMatch> matches = new List<ParseTreeMatch>();
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/ParseTreePatternMatcher.cs b/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/ParseTreePatternMatcher.cs
index 98ad17fd..9a959e33 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/ParseTreePatternMatcher.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/ParseTreePatternMatcher.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using System.Text;
@@ -283,7 +283,7 @@ public virtual ParseTreeMatch Match(IParseTree tree, string pattern, int pattern
         /// string representation of a tree pattern.
         /// </summary>
         [NotNull]
-        public virtual ParseTreeMatch Match(IParseTree tree, ParseTreePattern pattern)
+        public virtual ParseTreeMatch Match([NotNull] IParseTree tree, [NotNull] ParseTreePattern pattern)
         {
             MultiMap<string, IParseTree> labels = new MultiMap<string, IParseTree>();
             IParseTree mismatchedNode = MatchImpl(tree, pattern.PatternTree, labels);
@@ -377,7 +377,7 @@ public virtual Parser Parser
         /// algorithm used by the implementation, and may be overridden.
         /// </returns>
         [Nullable]
-        protected internal virtual IParseTree MatchImpl(IParseTree tree, IParseTree patternTree, MultiMap<string, IParseTree> labels)
+        protected internal virtual IParseTree MatchImpl([NotNull] IParseTree tree, [NotNull] IParseTree patternTree, [NotNull] MultiMap<string, IParseTree> labels)
         {
             if (tree == null)
             {
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/RuleTagToken.cs b/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/RuleTagToken.cs
index b1898893..c504d08c 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/RuleTagToken.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/RuleTagToken.cs
@@ -2,12 +2,13 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using Antlr4.Runtime;
+using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
 
 namespace Antlr4.Runtime.Tree.Pattern
@@ -61,7 +62,7 @@ public class RuleTagToken : IToken
         /// <see langword="null"/>
         /// or empty.
         /// </exception>
-        public RuleTagToken(string ruleName, int bypassTokenType)
+        public RuleTagToken([NotNull] string ruleName, int bypassTokenType)
             : this(ruleName, bypassTokenType, null)
         {
         }
@@ -88,7 +89,7 @@ public RuleTagToken(string ruleName, int bypassTokenType)
         /// <see langword="null"/>
         /// or empty.
         /// </exception>
-        public RuleTagToken(string ruleName, int bypassTokenType, string label)
+        public RuleTagToken([NotNull] string ruleName, int bypassTokenType, [Nullable] string label)
         {
             if (ruleName == null || ruleName.IsEmpty())
             {
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/TagChunk.cs b/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/TagChunk.cs
index 34242d62..f013133c 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/TagChunk.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/TagChunk.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using Antlr4.Runtime.Sharpen;
 
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/TextChunk.cs b/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/TextChunk.cs
index 4c003bb4..2566b905 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/TextChunk.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/TextChunk.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -40,7 +40,7 @@ internal class TextChunk : Chunk
         /// <see langword="null"/>
         /// .
         /// </exception>
-        public TextChunk(string text)
+        public TextChunk([NotNull] string text)
         {
             if (text == null)
             {
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/TokenTagToken.cs b/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/TokenTagToken.cs
index 69cdb67e..1829377d 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/TokenTagToken.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/TokenTagToken.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -49,7 +49,7 @@ public class TokenTagToken : CommonToken
         /// </summary>
         /// <param name="tokenName">The token name.</param>
         /// <param name="type">The token type.</param>
-        public TokenTagToken(string tokenName, int type)
+        public TokenTagToken([NotNull] string tokenName, int type)
             : this(tokenName, type, null)
         {
         }
@@ -68,7 +68,7 @@ public TokenTagToken(string tokenName, int type)
         /// if
         /// the token tag is unlabeled.
         /// </param>
-        public TokenTagToken(string tokenName, int type, string label)
+        public TokenTagToken([NotNull] string tokenName, int type, [Nullable] string label)
             : base(type)
         {
             this.tokenName = tokenName;
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/TerminalNodeImpl.cs b/runtime/CSharp/Antlr4.Runtime/Tree/TerminalNodeImpl.cs
index 59400f84..fd40a5e6 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/TerminalNodeImpl.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/TerminalNodeImpl.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/Trees.cs b/runtime/CSharp/Antlr4.Runtime/Tree/Trees.cs
index 9a445dd3..eaf38259 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/Trees.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/Trees.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using System.Text;
@@ -27,7 +27,7 @@ public class Trees
         /// node payloads to get the text for the nodes.  Detect
         /// parse trees and extract data appropriately.
         /// </remarks>
-        public static string ToStringTree(ITree t)
+        public static string ToStringTree([NotNull] ITree t)
         {
             return ToStringTree(t, (IList<string>)null);
         }
@@ -40,7 +40,7 @@ public static string ToStringTree(ITree t)
         /// node payloads to get the text for the nodes.  Detect
         /// parse trees and extract data appropriately.
         /// </remarks>
-        public static string ToStringTree(ITree t, Parser recog)
+        public static string ToStringTree([NotNull] ITree t, [Nullable] Parser recog)
         {
             string[] ruleNames = recog != null ? recog.RuleNames : null;
             IList<string> ruleNamesList = ruleNames != null ? Arrays.AsList(ruleNames) : null;
@@ -54,7 +54,7 @@ public static string ToStringTree(ITree t, Parser recog)
         /// is used on the
         /// node payloads to get the text for the nodes.
         /// </remarks>
-        public static string ToStringTree(ITree t, IList<string> ruleNames)
+        public static string ToStringTree([NotNull] ITree t, [Nullable] IList<string> ruleNames)
         {
             string s = Utils.EscapeWhitespace(GetNodeText(t, ruleNames), false);
             if (t.ChildCount == 0)
@@ -78,14 +78,14 @@ public static string ToStringTree(ITree t, IList<string> ruleNames)
             return buf.ToString();
         }
 
-        public static string GetNodeText(ITree t, Parser recog)
+        public static string GetNodeText([NotNull] ITree t, [Nullable] Parser recog)
         {
             string[] ruleNames = recog != null ? recog.RuleNames : null;
             IList<string> ruleNamesList = ruleNames != null ? Arrays.AsList(ruleNames) : null;
             return GetNodeText(t, ruleNamesList);
         }
 
-        public static string GetNodeText(ITree t, IList<string> ruleNames)
+        public static string GetNodeText([NotNull] ITree t, [Nullable] IList<string> ruleNames)
         {
             if (ruleNames != null)
             {
@@ -148,7 +148,7 @@ public static IList<ITree> GetChildren(ITree t)
         /// </remarks>
         /// <since>4.5.1</since>
         [NotNull]
-        public static IList<ITree> GetAncestors(ITree t)
+        public static IList<ITree> GetAncestors([NotNull] ITree t)
         {
             if (t.Parent == null)
             {
@@ -265,7 +265,7 @@ public static IList<IParseTree> Descendants(IParseTree t)
         /// </remarks>
         /// <since>4.5</since>
         [Nullable]
-        public static ParserRuleContext GetRootOfSubtreeEnclosingRegion(IParseTree t, int startTokenIndex, int stopTokenIndex)
+        public static ParserRuleContext GetRootOfSubtreeEnclosingRegion([NotNull] IParseTree t, int startTokenIndex, int stopTokenIndex)
         {
             // inclusive
             // inclusive
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPath.cs b/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPath.cs
index d07fa93d..dd416e2c 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPath.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPath.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Collections.Generic;
 using System.IO;
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathElement.cs b/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathElement.cs
index 78c9af5c..3d889659 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathElement.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathElement.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using Antlr4.Runtime.Sharpen;
 using Antlr4.Runtime.Tree;
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathLexerErrorListener.cs b/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathLexerErrorListener.cs
index fe8f4038..be515607 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathLexerErrorListener.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathLexerErrorListener.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using Antlr4.Runtime;
 using Antlr4.Runtime.Sharpen;
 
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathRuleAnywhereElement.cs b/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathRuleAnywhereElement.cs
index 70dc2b4f..2e046076 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathRuleAnywhereElement.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathRuleAnywhereElement.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using Antlr4.Runtime.Sharpen;
 using Antlr4.Runtime.Tree;
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathRuleElement.cs b/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathRuleElement.cs
index 73f4ad70..2313a5b8 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathRuleElement.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathRuleElement.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using Antlr4.Runtime;
 using Antlr4.Runtime.Sharpen;
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathTokenAnywhereElement.cs b/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathTokenAnywhereElement.cs
index 3bd81452..f04f2606 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathTokenAnywhereElement.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathTokenAnywhereElement.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using Antlr4.Runtime.Sharpen;
 using Antlr4.Runtime.Tree;
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathTokenElement.cs b/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathTokenElement.cs
index 1c0ac9ea..711fcf33 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathTokenElement.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathTokenElement.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using Antlr4.Runtime.Sharpen;
 using Antlr4.Runtime.Tree;
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathWildcardAnywhereElement.cs b/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathWildcardAnywhereElement.cs
index 93e5a179..54f4f9eb 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathWildcardAnywhereElement.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathWildcardAnywhereElement.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using Antlr4.Runtime.Sharpen;
 using Antlr4.Runtime.Tree;
diff --git a/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathWildcardElement.cs b/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathWildcardElement.cs
index b4b7762e..8f092b93 100644
--- a/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathWildcardElement.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathWildcardElement.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System.Collections.Generic;
 using Antlr4.Runtime.Sharpen;
 using Antlr4.Runtime.Tree;
diff --git a/runtime/CSharp/Antlr4.Runtime/UnbufferedCharStream.cs b/runtime/CSharp/Antlr4.Runtime/UnbufferedCharStream.cs
index 818c62b4..ed7b845f 100644
--- a/runtime/CSharp/Antlr4.Runtime/UnbufferedCharStream.cs
+++ b/runtime/CSharp/Antlr4.Runtime/UnbufferedCharStream.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.IO;
 using Antlr4.Runtime.Misc;
diff --git a/runtime/CSharp/Antlr4.Runtime/UnbufferedTokenStream.cs b/runtime/CSharp/Antlr4.Runtime/UnbufferedTokenStream.cs
index 154d5128..1cb2b869 100644
--- a/runtime/CSharp/Antlr4.Runtime/UnbufferedTokenStream.cs
+++ b/runtime/CSharp/Antlr4.Runtime/UnbufferedTokenStream.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using System.Text;
 using Antlr4.Runtime.Misc;
@@ -255,7 +255,7 @@ protected internal virtual int Fill(int n)
             return n;
         }
 
-        protected internal virtual void Add(IToken t)
+        protected internal virtual void Add([NotNull] IToken t)
         {
             if (n >= tokens.Length)
             {
diff --git a/runtime/CSharp/Antlr4.Runtime/Vocabulary.cs b/runtime/CSharp/Antlr4.Runtime/Vocabulary.cs
index aa33591e..5c2083f5 100644
--- a/runtime/CSharp/Antlr4.Runtime/Vocabulary.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Vocabulary.cs
@@ -2,10 +2,10 @@
 // Licensed under the BSD License. See LICENSE.txt in the project root for license information.
 
 /*
-* Copyright (c) 2012 The ANTLR Project. All rights reserved.
-* Use of this file is governed by the BSD-3-Clause license that
-* can be found in the LICENSE.txt file in the project root.
-*/
+ * Copyright (c) 2012 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD-3-Clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
 using System;
 using Antlr4.Runtime.Misc;
 using Antlr4.Runtime.Sharpen;
@@ -66,7 +66,7 @@ public class Vocabulary : IVocabulary
         /// </param>
         /// <seealso cref="GetLiteralName(int)"/>
         /// <seealso cref="GetSymbolicName(int)"/>
-        public Vocabulary(string[] literalNames, string[] symbolicNames)
+        public Vocabulary([Nullable] string[] literalNames, [Nullable] string[] symbolicNames)
             : this(literalNames, symbolicNames, null)
         {
         }
@@ -102,7 +102,7 @@ public Vocabulary(string[] literalNames, string[] symbolicNames)
         /// <seealso cref="GetLiteralName(int)"/>
         /// <seealso cref="GetSymbolicName(int)"/>
         /// <seealso cref="GetDisplayName(int)"/>
-        public Vocabulary(string[] literalNames, string[] symbolicNames, string[] displayNames)
+        public Vocabulary([Nullable] string[] literalNames, [Nullable] string[] symbolicNames, [Nullable] string[] displayNames)
         {
             this.literalNames = literalNames != null ? literalNames : EmptyNames;
             this.symbolicNames = symbolicNames != null ? symbolicNames : EmptyNames;
@@ -143,7 +143,7 @@ public Vocabulary(string[] literalNames, string[] symbolicNames, string[] displa
         /// for
         /// the display names of tokens.
         /// </returns>
-        public static IVocabulary FromTokenNames(string[] tokenNames)
+        public static IVocabulary FromTokenNames([Nullable] string[] tokenNames)
         {
             if (tokenNames == null || tokenNames.Length == 0)
             {

From 94857db3a732190665b89b0a3bb3598a05ada797 Mon Sep 17 00:00:00 2001
From: Sam Harwell <sam@tunnelvisionlabs.com>
Date: Tue, 8 Aug 2017 23:31:06 -0500
Subject: [PATCH 3/3] Revert incorrect changes to generics in generated code

---
 runtime/CSharp/Antlr4.Runtime/Atn/SemanticContext.cs   | 2 +-
 runtime/CSharp/Antlr4.Runtime/Dfa/AbstractEdgeMap`1.cs | 2 +-
 runtime/CSharp/Antlr4.Runtime/Dfa/ArrayEdgeMap`1.cs    | 8 ++++----
 runtime/CSharp/Antlr4.Runtime/ProxyErrorListener`1.cs  | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/runtime/CSharp/Antlr4.Runtime/Atn/SemanticContext.cs b/runtime/CSharp/Antlr4.Runtime/Atn/SemanticContext.cs
index 7b82a10a..56058035 100644
--- a/runtime/CSharp/Antlr4.Runtime/Atn/SemanticContext.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Atn/SemanticContext.cs
@@ -548,7 +548,7 @@ public static SemanticContext Or(SemanticContext a, SemanticContext b)
             where _T0 : SemanticContext
         {
             List<SemanticContext.PrecedencePredicate> result = null;
-            for (IEnumerator<_T0> iterator = collection.GetEnumerator(); iterator.HasNext(); )
+            for (IEnumerator<SemanticContext> iterator = collection.GetEnumerator(); iterator.HasNext(); )
             {
                 SemanticContext context = iterator.Next();
                 if (context is SemanticContext.PrecedencePredicate)
diff --git a/runtime/CSharp/Antlr4.Runtime/Dfa/AbstractEdgeMap`1.cs b/runtime/CSharp/Antlr4.Runtime/Dfa/AbstractEdgeMap`1.cs
index 57bbe3c2..1135306b 100644
--- a/runtime/CSharp/Antlr4.Runtime/Dfa/AbstractEdgeMap`1.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Dfa/AbstractEdgeMap`1.cs
@@ -32,7 +32,7 @@ public virtual Antlr4.Runtime.Dfa.AbstractEdgeMap<T> PutAll<_T0>(IEdgeMap<_T0> m
             where _T0 : T
         {
             Antlr4.Runtime.Dfa.AbstractEdgeMap<T> result = this;
-            foreach (KeyValuePair<int, _T0> entry in m.EntrySet())
+            foreach (KeyValuePair<int, T> entry in m.EntrySet())
             {
                 result = result.Put(entry.Key, entry.Value);
             }
diff --git a/runtime/CSharp/Antlr4.Runtime/Dfa/ArrayEdgeMap`1.cs b/runtime/CSharp/Antlr4.Runtime/Dfa/ArrayEdgeMap`1.cs
index 04f92221..391b4d6c 100644
--- a/runtime/CSharp/Antlr4.Runtime/Dfa/ArrayEdgeMap`1.cs
+++ b/runtime/CSharp/Antlr4.Runtime/Dfa/ArrayEdgeMap`1.cs
@@ -92,7 +92,7 @@ public override AbstractEdgeMap<T> PutAll<_T0>(IEdgeMap<_T0> m)
             }
             if (m is Antlr4.Runtime.Dfa.ArrayEdgeMap<object>)
             {
-                Antlr4.Runtime.Dfa.ArrayEdgeMap<_T0> other = (Antlr4.Runtime.Dfa.ArrayEdgeMap<_T0>)m;
+                Antlr4.Runtime.Dfa.ArrayEdgeMap<T> other = (Antlr4.Runtime.Dfa.ArrayEdgeMap<T>)m;
                 int minOverlap = Math.Max(minIndex, other.minIndex);
                 int maxOverlap = Math.Min(maxIndex, other.maxIndex);
                 Antlr4.Runtime.Dfa.ArrayEdgeMap<T> result = this;
@@ -106,7 +106,7 @@ public override AbstractEdgeMap<T> PutAll<_T0>(IEdgeMap<_T0> m)
             {
                 if (m is SingletonEdgeMap<object>)
                 {
-                    SingletonEdgeMap<_T0> other = (SingletonEdgeMap<_T0>)m;
+                    SingletonEdgeMap<T> other = (SingletonEdgeMap<T>)m;
                     System.Diagnostics.Debug.Assert(!other.IsEmpty);
                     return ((Antlr4.Runtime.Dfa.ArrayEdgeMap<T>)Put(other.Key, other.Value));
                 }
@@ -114,11 +114,11 @@ public override AbstractEdgeMap<T> PutAll<_T0>(IEdgeMap<_T0> m)
                 {
                     if (m is SparseEdgeMap<object>)
                     {
-                        SparseEdgeMap<_T0> other = (SparseEdgeMap<_T0>)m;
+                        SparseEdgeMap<T> other = (SparseEdgeMap<T>)m;
                         lock (other)
                         {
                             int[] keys = other.Keys;
-                            IList<_T0> values = other.Values;
+                            IList<T> values = other.Values;
                             Antlr4.Runtime.Dfa.ArrayEdgeMap<T> result = this;
                             for (int i = 0; i < values.Count; i++)
                             {
diff --git a/runtime/CSharp/Antlr4.Runtime/ProxyErrorListener`1.cs b/runtime/CSharp/Antlr4.Runtime/ProxyErrorListener`1.cs
index cff6155c..faa81a95 100644
--- a/runtime/CSharp/Antlr4.Runtime/ProxyErrorListener`1.cs
+++ b/runtime/CSharp/Antlr4.Runtime/ProxyErrorListener`1.cs
@@ -45,7 +45,7 @@ protected internal virtual IEnumerable<IAntlrErrorListener<Symbol>> Delegates
         public virtual void SyntaxError<T>([NotNull] Recognizer<T, object> recognizer, [Nullable] T offendingSymbol, int line, int charPositionInLine, [NotNull] string msg, [Nullable] RecognitionException e)
             where T : Symbol
         {
-            foreach (IAntlrErrorListener<T> listener in delegates)
+            foreach (IAntlrErrorListener<Symbol> listener in delegates)
             {
                 listener.SyntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
             }