diff --git a/CodeCoverage.runsettings b/CodeCoverage.runsettings
index 12529d305..6575840af 100644
--- a/CodeCoverage.runsettings
+++ b/CodeCoverage.runsettings
@@ -77,6 +77,8 @@
+
+
diff --git a/libraries/AdaptiveExpressions/parser/ExpressionAntlrLexer.g4 b/libraries/AdaptiveExpressions/parser/ExpressionAntlrLexer.g4
index 3758d022a..bd1e0f27f 100644
--- a/libraries/AdaptiveExpressions/parser/ExpressionAntlrLexer.g4
+++ b/libraries/AdaptiveExpressions/parser/ExpressionAntlrLexer.g4
@@ -1,5 +1,8 @@
lexer grammar ExpressionAntlrLexer;
+@parser::header {#pragma warning disable 3021} // Disable StyleCop warning CS3021 re CLSCompliant attribute in generated files.
+@lexer::header {#pragma warning disable 3021} // Disable StyleCop warning CS3021 re CLSCompliant attribute in generated files.
+
@lexer::members {
bool ignoreWS = true; // usually we ignore whitespace, but inside stringInterpolation, whitespace is significant
}
diff --git a/libraries/AdaptiveExpressions/parser/ExpressionAntlrParser.g4 b/libraries/AdaptiveExpressions/parser/ExpressionAntlrParser.g4
index fe67ef460..7c5c3ef04 100644
--- a/libraries/AdaptiveExpressions/parser/ExpressionAntlrParser.g4
+++ b/libraries/AdaptiveExpressions/parser/ExpressionAntlrParser.g4
@@ -1,5 +1,8 @@
parser grammar ExpressionAntlrParser;
+@parser::header {#pragma warning disable 3021} // Disable StyleCop warning CS3021 re CLSCompliant attribute in generated files.
+@lexer::header {#pragma warning disable 3021} // Disable StyleCop warning CS3021 re CLSCompliant attribute in generated files.
+
options { tokenVocab=ExpressionAntlrLexer; }
file: expression EOF;
diff --git a/libraries/AdaptiveExpressions/parser/ExpressionParser.cs b/libraries/AdaptiveExpressions/parser/ExpressionParser.cs
index 4addf0b15..97639f9ee 100644
--- a/libraries/AdaptiveExpressions/parser/ExpressionParser.cs
+++ b/libraries/AdaptiveExpressions/parser/ExpressionParser.cs
@@ -13,8 +13,6 @@ using Antlr4.Runtime.Misc;
using Antlr4.Runtime.Tree;
using Newtonsoft.Json.Linq;
-[assembly: CLSCompliant(false)]
-
namespace AdaptiveExpressions
{
///
diff --git a/libraries/Microsoft.Bot.Builder.LanguageGeneration/Analyzer.cs b/libraries/Microsoft.Bot.Builder.LanguageGeneration/Analyzer.cs
index 0e2bddd2a..1afe3b3e0 100644
--- a/libraries/Microsoft.Bot.Builder.LanguageGeneration/Analyzer.cs
+++ b/libraries/Microsoft.Bot.Builder.LanguageGeneration/Analyzer.cs
@@ -12,7 +12,7 @@ namespace Microsoft.Bot.Builder.LanguageGeneration
///
/// LG template analyzer.
///
- public class Analyzer : LGFileParserBaseVisitor
+ public class Analyzer : LGTemplateParserBaseVisitor
{
private readonly Dictionary templateMap;
@@ -23,8 +23,8 @@ namespace Microsoft.Bot.Builder.LanguageGeneration
///
/// Initializes a new instance of the class.
///
- /// template list.
- /// expression parser.
+ /// Template list.
+ /// Expression parser.
public Analyzer(List templates, ExpressionParser expressionParser)
{
Templates = templates;
@@ -47,7 +47,7 @@ namespace Microsoft.Bot.Builder.LanguageGeneration
/// Analyzer a template to get the static analyzer results.
///
/// Template name.
- /// analyze result including variables and template references.
+ /// Analyze result including variables and template references.
public AnalyzerResult AnalyzeTemplate(string templateName)
{
if (!templateMap.ContainsKey(templateName))
@@ -67,29 +67,15 @@ namespace Microsoft.Bot.Builder.LanguageGeneration
// because given we don't track down for templates have parameters
// the only scenario that we are still analyzing an parameterized template is
// this template is root template to analyze, in this we also don't have exclude parameters
- var dependencies = Visit(templateMap[templateName].ParseTree);
+ var dependencies = Visit(templateMap[templateName].TemplateBodyParseTree);
evaluationTargetStack.Pop();
return dependencies;
}
- public override AnalyzerResult VisitTemplateDefinition([NotNull] LGFileParser.TemplateDefinitionContext context)
- {
- var templateNameContext = context.templateNameLine();
- if (templateNameContext.templateName().GetText().Equals(CurrentTarget().TemplateName))
- {
- if (context.templateBody() != null)
- {
- return Visit(context.templateBody());
- }
- }
+ public override AnalyzerResult VisitNormalBody([NotNull] LGTemplateParser.NormalBodyContext context) => Visit(context.normalTemplateBody());
- return new AnalyzerResult();
- }
-
- public override AnalyzerResult VisitNormalBody([NotNull] LGFileParser.NormalBodyContext context) => Visit(context.normalTemplateBody());
-
- public override AnalyzerResult VisitNormalTemplateBody([NotNull] LGFileParser.NormalTemplateBodyContext context)
+ public override AnalyzerResult VisitNormalTemplateBody([NotNull] LGTemplateParser.NormalTemplateBodyContext context)
{
var result = new AnalyzerResult();
@@ -102,7 +88,7 @@ namespace Microsoft.Bot.Builder.LanguageGeneration
return result;
}
- public override AnalyzerResult VisitStructuredTemplateBody([NotNull] LGFileParser.StructuredTemplateBodyContext context)
+ public override AnalyzerResult VisitStructuredTemplateBody([NotNull] LGTemplateParser.StructuredTemplateBodyContext context)
{
var result = new AnalyzerResult();
@@ -123,7 +109,7 @@ namespace Microsoft.Bot.Builder.LanguageGeneration
return result;
}
- public override AnalyzerResult VisitIfElseBody([NotNull] LGFileParser.IfElseBodyContext context)
+ public override AnalyzerResult VisitIfElseBody([NotNull] LGTemplateParser.IfElseBodyContext context)
{
var result = new AnalyzerResult();
@@ -145,7 +131,7 @@ namespace Microsoft.Bot.Builder.LanguageGeneration
return result;
}
- public override AnalyzerResult VisitSwitchCaseBody([NotNull] LGFileParser.SwitchCaseBodyContext context)
+ public override AnalyzerResult VisitSwitchCaseBody([NotNull] LGTemplateParser.SwitchCaseBodyContext context)
{
var result = new AnalyzerResult();
var switchCaseNodes = context.switchCaseTemplateBody().switchCaseRule();
@@ -166,7 +152,7 @@ namespace Microsoft.Bot.Builder.LanguageGeneration
return result;
}
- public override AnalyzerResult VisitNormalTemplateString([NotNull] LGFileParser.NormalTemplateStringContext context)
+ public override AnalyzerResult VisitNormalTemplateString([NotNull] LGTemplateParser.NormalTemplateStringContext context)
{
var result = new AnalyzerResult();
foreach (var expression in context.EXPRESSION())
@@ -177,7 +163,7 @@ namespace Microsoft.Bot.Builder.LanguageGeneration
return result;
}
- private AnalyzerResult VisitStructureValue(LGFileParser.KeyValueStructureLineContext context)
+ private AnalyzerResult VisitStructureValue(LGTemplateParser.KeyValueStructureLineContext context)
{
var values = context.keyValueStructureValue();
@@ -211,7 +197,7 @@ namespace Microsoft.Bot.Builder.LanguageGeneration
/// return only those without parameters.
///
/// Expression.
- /// template refs.
+ /// Template refs.
private AnalyzerResult AnalyzeExpressionDirectly(Expression exp)
{
var result = new AnalyzerResult();
diff --git a/libraries/Microsoft.Bot.Builder.LanguageGeneration/AnalyzerResult.cs b/libraries/Microsoft.Bot.Builder.LanguageGeneration/AnalyzerResult.cs
index 925fb981a..9af881c5d 100644
--- a/libraries/Microsoft.Bot.Builder.LanguageGeneration/AnalyzerResult.cs
+++ b/libraries/Microsoft.Bot.Builder.LanguageGeneration/AnalyzerResult.cs
@@ -35,7 +35,7 @@ namespace Microsoft.Bot.Builder.LanguageGeneration
/// Gets or sets template references that this template contains.
///
///
- /// template references that this template contains.
+ /// Template references that this template contains.
///
public List TemplateReferences { get; set; }
diff --git a/libraries/Microsoft.Bot.Builder.LanguageGeneration/CustomizedMemory.cs b/libraries/Microsoft.Bot.Builder.LanguageGeneration/CustomizedMemory.cs
index 5a2204b76..2db4201af 100644
--- a/libraries/Microsoft.Bot.Builder.LanguageGeneration/CustomizedMemory.cs
+++ b/libraries/Microsoft.Bot.Builder.LanguageGeneration/CustomizedMemory.cs
@@ -17,7 +17,7 @@ namespace Microsoft.Bot.Builder.LanguageGeneration
///
/// Initializes a new instance of the class.
///
- /// scope.
+ /// Scope.
public CustomizedMemory(object scope)
{
this.GlobalMemory = scope == null ? null : MemoryFactory.Create(scope);
@@ -27,8 +27,8 @@ namespace Microsoft.Bot.Builder.LanguageGeneration
///
/// Initializes a new instance of the class.
///
- /// global memory.
- /// local memory.
+ /// Global memory.
+ /// Local memory.
public CustomizedMemory(IMemory globalMemory, IMemory localMemory = null)
{
this.GlobalMemory = globalMemory;
@@ -60,9 +60,9 @@ namespace Microsoft.Bot.Builder.LanguageGeneration
/// Try to get the value from a given path. Firstly, get result from global memory,
/// if global memory does not contain, get from local memory.
///
- /// memory path.
- /// resolved value.
- /// true if the memory contains an element with the specified key; otherwise, false.
+ /// Memory path.
+ /// Resolved value.
+ /// True if the memory contains an element with the specified key; otherwise, false.
public bool TryGetValue(string path, out object value)
{
value = null;
diff --git a/libraries/Microsoft.Bot.Builder.LanguageGeneration/ErrorListener.cs b/libraries/Microsoft.Bot.Builder.LanguageGeneration/ErrorListener.cs
index 00405696e..139971aa7 100644
--- a/libraries/Microsoft.Bot.Builder.LanguageGeneration/ErrorListener.cs
+++ b/libraries/Microsoft.Bot.Builder.LanguageGeneration/ErrorListener.cs
@@ -14,16 +14,18 @@ namespace Microsoft.Bot.Builder.LanguageGeneration
public class ErrorListener : BaseErrorListener
{
private readonly string source;
+ private readonly int lineOffset;
- public ErrorListener(string errorSource)
+ public ErrorListener(string errorSource, int lineOffset = 0)
{
source = errorSource;
+ this.lineOffset = lineOffset;
}
public override void SyntaxError([NotNull] IRecognizer recognizer, [Nullable] IToken offendingSymbol, int line, int charPositionInLine, [NotNull] string msg, [Nullable] RecognitionException e)
{
- var startPosition = new Position(line, charPositionInLine);
- var stopPosition = new Position(line, charPositionInLine + offendingSymbol.StopIndex - offendingSymbol.StartIndex + 1);
+ var startPosition = new Position(lineOffset + line, charPositionInLine);
+ var stopPosition = new Position(lineOffset + line, charPositionInLine + offendingSymbol.StopIndex - offendingSymbol.StartIndex + 1);
var range = new Range(startPosition, stopPosition);
var diagnostic = new Diagnostic(range, TemplateErrors.SyntaxError, DiagnosticSeverity.Error, source);
throw new TemplateException(diagnostic.ToString(), new List() { diagnostic });
diff --git a/libraries/Microsoft.Bot.Builder.LanguageGeneration/EvaluationTarget.cs b/libraries/Microsoft.Bot.Builder.LanguageGeneration/EvaluationTarget.cs
index 2e9058523..4848c2e39 100644
--- a/libraries/Microsoft.Bot.Builder.LanguageGeneration/EvaluationTarget.cs
+++ b/libraries/Microsoft.Bot.Builder.LanguageGeneration/EvaluationTarget.cs
@@ -13,8 +13,8 @@ namespace Microsoft.Bot.Builder.LanguageGeneration
///
/// Initializes a new instance of the class.
///
- /// template name.
- /// template scope.
+ /// Template name.
+ /// Template scope.
public EvaluationTarget(string templateName, object scope)
{
TemplateName = templateName;
@@ -33,7 +33,7 @@ namespace Microsoft.Bot.Builder.LanguageGeneration
/// Gets or sets template name.
///
///
- /// template name.
+ /// Template name.
///
public string TemplateName { get; set; }
@@ -49,7 +49,7 @@ namespace Microsoft.Bot.Builder.LanguageGeneration
/// Get current instance id. If two target has the same Id,
/// we can say they have the same template evaluation.
///
- /// id.
+ /// Id.
public string GetId()
{
var memory = (CustomizedMemory)Scope;
diff --git a/libraries/Microsoft.Bot.Builder.LanguageGeneration/Evaluator.cs b/libraries/Microsoft.Bot.Builder.LanguageGeneration/Evaluator.cs
index 275e78a2d..42d78e9a3 100644
--- a/libraries/Microsoft.Bot.Builder.LanguageGeneration/Evaluator.cs
+++ b/libraries/Microsoft.Bot.Builder.LanguageGeneration/Evaluator.cs
@@ -19,7 +19,7 @@ namespace Microsoft.Bot.Builder.LanguageGeneration
///
/// LG template Evaluator.
///
- public class Evaluator : LGFileParserBaseVisitor