diff --git a/src/Microsoft.AspNet.Razor/Chunks/Generators/RazorChunkGenerator.cs b/src/Microsoft.AspNet.Razor/Chunks/Generators/RazorChunkGenerator.cs
index c9b7a8c25b..a6d057f3b1 100644
--- a/src/Microsoft.AspNet.Razor/Chunks/Generators/RazorChunkGenerator.cs
+++ b/src/Microsoft.AspNet.Razor/Chunks/Generators/RazorChunkGenerator.cs
@@ -4,7 +4,6 @@
using System;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.Chunks.Generators
{
@@ -14,10 +13,20 @@ namespace Microsoft.AspNet.Razor.Chunks.Generators
public RazorChunkGenerator(
string className,
- [NotNull] string rootNamespaceName,
+ string rootNamespaceName,
string sourceFileName,
- [NotNull] RazorEngineHost host)
+ RazorEngineHost host)
{
+ if (rootNamespaceName == null)
+ {
+ throw new ArgumentNullException(nameof(rootNamespaceName));
+ }
+
+ if (host == null)
+ {
+ throw new ArgumentNullException(nameof(host));
+ }
+
if (string.IsNullOrEmpty(className))
{
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, nameof(className));
diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/CSharpCodeGenerator.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/CSharpCodeGenerator.cs
index 531965a754..f95f1cdab6 100644
--- a/src/Microsoft.AspNet.Razor/CodeGenerators/CSharpCodeGenerator.cs
+++ b/src/Microsoft.AspNet.Razor/CodeGenerators/CSharpCodeGenerator.cs
@@ -1,12 +1,12 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Razor.Chunks;
using Microsoft.AspNet.Razor.CodeGenerators.Visitors;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.CodeGenerators
{
@@ -87,9 +87,19 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
return new CodeGeneratorResult(writer.GenerateCode(), writer.LineMappingManager.Mappings);
}
- protected virtual CSharpCodeVisitor CreateCSharpCodeVisitor([NotNull] CSharpCodeWriter writer,
- [NotNull] CodeGeneratorContext context)
+ protected virtual CSharpCodeVisitor CreateCSharpCodeVisitor(CSharpCodeWriter writer,
+ CodeGeneratorContext context)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
return new CSharpCodeVisitor(writer, context);
}
diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/CSharpCodeWriter.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/CSharpCodeWriter.cs
index 44cd85e2f2..51c3882bb1 100644
--- a/src/Microsoft.AspNet.Razor/CodeGenerators/CSharpCodeWriter.cs
+++ b/src/Microsoft.AspNet.Razor/CodeGenerators/CSharpCodeWriter.cs
@@ -8,7 +8,6 @@ using System.Linq;
using Microsoft.AspNet.Razor.Chunks.Generators;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Text;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.CodeGenerators
{
@@ -240,28 +239,58 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
}
// Writes a method invocation for the given instance name.
- public CSharpCodeWriter WriteInstanceMethodInvocation([NotNull] string instanceName,
- [NotNull] string methodName,
+ public CSharpCodeWriter WriteInstanceMethodInvocation(string instanceName,
+ string methodName,
params string[] parameters)
{
+ if (instanceName == null)
+ {
+ throw new ArgumentNullException(nameof(instanceName));
+ }
+
+ if (methodName == null)
+ {
+ throw new ArgumentNullException(nameof(methodName));
+ }
+
return WriteInstanceMethodInvocation(instanceName, methodName, endLine: true, parameters: parameters);
}
// Writes a method invocation for the given instance name.
- public CSharpCodeWriter WriteInstanceMethodInvocation([NotNull] string instanceName,
- [NotNull] string methodName,
+ public CSharpCodeWriter WriteInstanceMethodInvocation(string instanceName,
+ string methodName,
bool endLine,
params string[] parameters)
{
+ if (instanceName == null)
+ {
+ throw new ArgumentNullException(nameof(instanceName));
+ }
+
+ if (methodName == null)
+ {
+ throw new ArgumentNullException(nameof(methodName));
+ }
+
return WriteMethodInvocation(
string.Format(CultureInfo.InvariantCulture, InstanceMethodFormat, instanceName, methodName),
endLine,
parameters);
}
- public CSharpCodeWriter WriteStartInstanceMethodInvocation([NotNull] string instanceName,
- [NotNull] string methodName)
+ public CSharpCodeWriter WriteStartInstanceMethodInvocation(string instanceName,
+ string methodName)
{
+ if (instanceName == null)
+ {
+ throw new ArgumentNullException(nameof(instanceName));
+ }
+
+ if (methodName == null)
+ {
+ throw new ArgumentNullException(nameof(methodName));
+ }
+
return WriteStartMethodInvocation(
string.Format(CultureInfo.InvariantCulture, InstanceMethodFormat, instanceName, methodName));
}
diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/CSharpLineMappingWriter.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/CSharpLineMappingWriter.cs
index 20e948114d..5fa2f5157b 100644
--- a/src/Microsoft.AspNet.Razor/CodeGenerators/CSharpLineMappingWriter.cs
+++ b/src/Microsoft.AspNet.Razor/CodeGenerators/CSharpLineMappingWriter.cs
@@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.CodeGenerators
{
@@ -17,8 +16,13 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
private SourceLocation _generatedLocation;
private int _generatedContentLength;
- private CSharpLineMappingWriter([NotNull] CSharpCodeWriter writer, bool addLineMappings)
+ private CSharpLineMappingWriter(CSharpCodeWriter writer, bool addLineMappings)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
_writer = writer;
_addLineMapping = addLineMappings;
_startIndent = _writer.CurrentIndent;
@@ -54,11 +58,16 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
/// The of the Razor content being mapping.
/// The input file path.
public CSharpLineMappingWriter(
- [NotNull] CSharpCodeWriter writer,
- [NotNull] SourceLocation documentLocation,
- [NotNull] string sourceFileName)
+ CSharpCodeWriter writer,
+ SourceLocation documentLocation,
+ string sourceFileName)
: this(writer, addLineMappings: false)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
_writePragmas = true;
_writer.WriteLineNumberDirective(documentLocation, sourceFileName);
}
diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/CSharpPaddingBuilder.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/CSharpPaddingBuilder.cs
index 91f00285df..43fbcb2d48 100644
--- a/src/Microsoft.AspNet.Razor/CodeGenerators/CSharpPaddingBuilder.cs
+++ b/src/Microsoft.AspNet.Razor/CodeGenerators/CSharpPaddingBuilder.cs
@@ -4,7 +4,6 @@
using System;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.CodeGenerators
{
@@ -20,8 +19,13 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
}
// Special case for statement padding to account for brace positioning in the editor.
- public string BuildStatementPadding([NotNull] Span target)
+ public string BuildStatementPadding(Span target)
{
+ if (target == null)
+ {
+ throw new ArgumentNullException(nameof(target));
+ }
+
var padding = CalculatePadding(target, generatedStart: 0);
// We treat statement padding specially so for brace positioning, so that in the following example:
@@ -48,15 +52,25 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
return BuildExpressionPadding(target, generatedStart: 0);
}
- public string BuildExpressionPadding([NotNull] Span target, int generatedStart)
+ public string BuildExpressionPadding(Span target, int generatedStart)
{
+ if (target == null)
+ {
+ throw new ArgumentNullException(nameof(target));
+ }
+
var padding = CalculatePadding(target, generatedStart);
return BuildPaddingInternal(padding);
}
- internal int CalculatePadding([NotNull] Span target, int generatedStart)
+ internal int CalculatePadding(Span target, int generatedStart)
{
+ if (target == null)
+ {
+ throw new ArgumentNullException(nameof(target));
+ }
+
int padding;
padding = CollectSpacesAndTabs(target, _host.TabSize) - generatedStart;
diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/CSharpTagHelperCodeRenderer.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/CSharpTagHelperCodeRenderer.cs
index 62e0f60767..14710986d7 100644
--- a/src/Microsoft.AspNet.Razor/CodeGenerators/CSharpTagHelperCodeRenderer.cs
+++ b/src/Microsoft.AspNet.Razor/CodeGenerators/CSharpTagHelperCodeRenderer.cs
@@ -9,7 +9,6 @@ using Microsoft.AspNet.Razor.Chunks;
using Microsoft.AspNet.Razor.CodeGenerators.Visitors;
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
using Microsoft.AspNet.Razor.TagHelpers;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.CodeGenerators
{
@@ -38,10 +37,25 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
/// A instance that contains information about
/// the current code generation process.
public CSharpTagHelperCodeRenderer(
- [NotNull] IChunkVisitor bodyVisitor,
- [NotNull] CSharpCodeWriter writer,
- [NotNull] CodeGeneratorContext context)
+ IChunkVisitor bodyVisitor,
+ CSharpCodeWriter writer,
+ CodeGeneratorContext context)
{
+ if (bodyVisitor == null)
+ {
+ throw new ArgumentNullException(nameof(bodyVisitor));
+ }
+
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
_bodyVisitor = bodyVisitor;
_writer = writer;
_context = context;
diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/GeneratedClassContext.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/GeneratedClassContext.cs
index a6726e39fc..bbd4418786 100644
--- a/src/Microsoft.AspNet.Razor/CodeGenerators/GeneratedClassContext.cs
+++ b/src/Microsoft.AspNet.Razor/CodeGenerators/GeneratedClassContext.cs
@@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
-using System.Diagnostics.CodeAnalysis;
using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.CodeGenerators
@@ -24,9 +23,14 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
public GeneratedClassContext(string executeMethodName,
string writeMethodName,
string writeLiteralMethodName,
- [NotNull] GeneratedTagHelperContext generatedTagHelperContext)
+ GeneratedTagHelperContext generatedTagHelperContext)
: this()
{
+ if (generatedTagHelperContext == null)
+ {
+ throw new ArgumentNullException(nameof(generatedTagHelperContext));
+ }
+
if (string.IsNullOrEmpty(executeMethodName))
{
throw new ArgumentException(
diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/GeneratorResults.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/GeneratorResults.cs
index 1dad924ea8..050c8e3e49 100644
--- a/src/Microsoft.AspNet.Razor/CodeGenerators/GeneratorResults.cs
+++ b/src/Microsoft.AspNet.Razor/CodeGenerators/GeneratorResults.cs
@@ -1,11 +1,11 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using System.Collections.Generic;
using Microsoft.AspNet.Razor.Chunks;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.TagHelpers;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.CodeGenerators
{
@@ -20,15 +20,27 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
/// The results of parsing a document.
/// The results of generating code for the document.
/// A for the document.
- public GeneratorResults([NotNull] ParserResults parserResults,
- [NotNull] CodeGeneratorResult codeGeneratorResult,
- [NotNull] ChunkTree chunkTree)
+ public GeneratorResults(ParserResults parserResults,
+ CodeGeneratorResult codeGeneratorResult,
+ ChunkTree chunkTree)
: this(parserResults.Document,
parserResults.TagHelperDescriptors,
parserResults.ErrorSink,
codeGeneratorResult,
chunkTree)
{
+ if (parserResults == null)
+ {
+ throw new ArgumentNullException(nameof(parserResults));
+ }
+ if (codeGeneratorResult == null)
+ {
+ throw new ArgumentNullException(nameof(codeGeneratorResult));
+ }
+ if (chunkTree == null)
+ {
+ throw new ArgumentNullException(nameof(chunkTree));
+ }
}
///
@@ -44,13 +56,38 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
///
/// The results of generating code for the document.
/// A for the document.
- public GeneratorResults([NotNull] Block document,
- [NotNull] IEnumerable tagHelperDescriptors,
- [NotNull] ErrorSink errorSink,
- [NotNull] CodeGeneratorResult codeGeneratorResult,
- [NotNull] ChunkTree chunkTree)
+ public GeneratorResults(Block document,
+ IEnumerable tagHelperDescriptors,
+ ErrorSink errorSink,
+ CodeGeneratorResult codeGeneratorResult,
+ ChunkTree chunkTree)
: base(document, tagHelperDescriptors, errorSink)
{
+ if (document == null)
+ {
+ throw new ArgumentNullException(nameof(document));
+ }
+
+ if (tagHelperDescriptors == null)
+ {
+ throw new ArgumentNullException(nameof(tagHelperDescriptors));
+ }
+
+ if (errorSink == null)
+ {
+ throw new ArgumentNullException(nameof(errorSink));
+ }
+
+ if (codeGeneratorResult == null)
+ {
+ throw new ArgumentNullException(nameof(codeGeneratorResult));
+ }
+
+ if (chunkTree == null)
+ {
+ throw new ArgumentNullException(nameof(chunkTree));
+ }
+
GeneratedCode = codeGeneratorResult.Code;
DesignTimeLineMappings = codeGeneratorResult.DesignTimeLineMappings;
ChunkTree = chunkTree;
diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/TagHelperAttributeValueCodeRenderer.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/TagHelperAttributeValueCodeRenderer.cs
index 3a17d9d4cd..4ea6ffd3d0 100644
--- a/src/Microsoft.AspNet.Razor/CodeGenerators/TagHelperAttributeValueCodeRenderer.cs
+++ b/src/Microsoft.AspNet.Razor/CodeGenerators/TagHelperAttributeValueCodeRenderer.cs
@@ -3,7 +3,6 @@
using System;
using Microsoft.AspNet.Razor.TagHelpers;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.CodeGenerators
{
@@ -31,12 +30,32 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
/// Razor construct e.g. "@(@readonly)".
///
public virtual void RenderAttributeValue(
- [NotNull] TagHelperAttributeDescriptor attributeDescriptor,
- [NotNull] CSharpCodeWriter writer,
- [NotNull] CodeGeneratorContext context,
- [NotNull] Action renderAttributeValue,
+ TagHelperAttributeDescriptor attributeDescriptor,
+ CSharpCodeWriter writer,
+ CodeGeneratorContext context,
+ Action renderAttributeValue,
bool complexValue)
{
+ if (attributeDescriptor == null)
+ {
+ throw new ArgumentNullException(nameof(attributeDescriptor));
+ }
+
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (renderAttributeValue == null)
+ {
+ throw new ArgumentNullException(nameof(renderAttributeValue));
+ }
+
renderAttributeValue(writer);
}
}
diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpBaseTypeVisitor.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpBaseTypeVisitor.cs
index b1859db9f4..9bd5178000 100644
--- a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpBaseTypeVisitor.cs
+++ b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpBaseTypeVisitor.cs
@@ -1,16 +1,25 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using Microsoft.AspNet.Razor.Chunks;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors
{
public class CSharpBaseTypeVisitor : CodeVisitor
{
- public CSharpBaseTypeVisitor([NotNull] CSharpCodeWriter writer, [NotNull] CodeGeneratorContext context)
+ public CSharpBaseTypeVisitor(CSharpCodeWriter writer, CodeGeneratorContext context)
: base(writer, context)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
}
public string CurrentBaseType { get; set; }
diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpCodeVisitor.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpCodeVisitor.cs
index 4fa0765e6d..0c84e6bb92 100644
--- a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpCodeVisitor.cs
+++ b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpCodeVisitor.cs
@@ -1,11 +1,11 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using System.Globalization;
using System.Linq;
using Microsoft.AspNet.Razor.Chunks;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors
{
@@ -18,9 +18,19 @@ namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors
private CSharpPaddingBuilder _paddingBuilder;
private CSharpTagHelperCodeRenderer _tagHelperCodeRenderer;
- public CSharpCodeVisitor([NotNull] CSharpCodeWriter writer, [NotNull] CodeGeneratorContext context)
+ public CSharpCodeVisitor(CSharpCodeWriter writer, CodeGeneratorContext context)
: base(writer, context)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
_paddingBuilder = new CSharpPaddingBuilder(context.Host);
}
@@ -35,9 +45,13 @@ namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors
return _tagHelperCodeRenderer;
}
- [param: NotNull]
set
{
+ if (value == null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
+
_tagHelperCodeRenderer = value;
}
}
diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpDesignTimeHelpersVisitor.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpDesignTimeHelpersVisitor.cs
index feb4ececef..c6f2fd0834 100644
--- a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpDesignTimeHelpersVisitor.cs
+++ b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpDesignTimeHelpersVisitor.cs
@@ -1,10 +1,10 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using System.Diagnostics;
using System.Globalization;
using Microsoft.AspNet.Razor.Chunks;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors
{
@@ -20,12 +20,27 @@ namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors
private bool _initializedTagHelperDirectiveSyntaxHelper;
- public CSharpDesignTimeHelpersVisitor([NotNull] CSharpCodeVisitor csharpCodeVisitor,
- [NotNull] CSharpCodeWriter writer,
- [NotNull] CodeGeneratorContext context)
+ public CSharpDesignTimeHelpersVisitor(CSharpCodeVisitor csharpCodeVisitor,
+ CSharpCodeWriter writer,
+ CodeGeneratorContext context)
: base(writer, context)
{
+ if (csharpCodeVisitor == null)
+ {
+ throw new ArgumentNullException(nameof(csharpCodeVisitor));
+ }
+
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
_csharpCodeVisitor = csharpCodeVisitor;
}
diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpTagHelperAttributeValueVisitor.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpTagHelperAttributeValueVisitor.cs
index 6b7fa9f5ec..cc2f1eee48 100644
--- a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpTagHelperAttributeValueVisitor.cs
+++ b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpTagHelperAttributeValueVisitor.cs
@@ -1,10 +1,10 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using Microsoft.AspNet.Razor.Chunks;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors
{
@@ -34,11 +34,21 @@ namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors
/// is writing the value.
///
public CSharpTagHelperAttributeValueVisitor(
- [NotNull] CSharpCodeWriter writer,
- [NotNull] CodeGeneratorContext context,
+ CSharpCodeWriter writer,
+ CodeGeneratorContext context,
string attributeTypeName)
: base(writer, context)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
_attributeTypeName = attributeTypeName;
}
diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpTagHelperFieldDeclarationVisitor.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpTagHelperFieldDeclarationVisitor.cs
index 18d87c2a62..0d9436ea4b 100644
--- a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpTagHelperFieldDeclarationVisitor.cs
+++ b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpTagHelperFieldDeclarationVisitor.cs
@@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNet.Razor.Chunks;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors
{
@@ -14,10 +13,20 @@ namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors
private readonly GeneratedTagHelperContext _tagHelperContext;
private bool _foundTagHelpers;
- public CSharpTagHelperFieldDeclarationVisitor([NotNull] CSharpCodeWriter writer,
- [NotNull] CodeGeneratorContext context)
+ public CSharpTagHelperFieldDeclarationVisitor(CSharpCodeWriter writer,
+ CodeGeneratorContext context)
: base(writer, context)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
_declaredTagHelpers = new HashSet(StringComparer.Ordinal);
_tagHelperContext = Context.Host.GeneratedClassContext.GeneratedTagHelperContext;
}
@@ -81,6 +90,11 @@ namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors
public override void Accept(Chunk chunk)
{
+ if (chunk == null)
+ {
+ throw new ArgumentNullException(nameof(chunk));
+ }
+
var parentChunk = chunk as ParentChunk;
// If we're any ParentChunk other than TagHelperChunk then we want to dive into its Children
diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpTagHelperRunnerInitializationVisitor.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpTagHelperRunnerInitializationVisitor.cs
index e4e2d23beb..ec885464fb 100644
--- a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpTagHelperRunnerInitializationVisitor.cs
+++ b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpTagHelperRunnerInitializationVisitor.cs
@@ -1,8 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using Microsoft.AspNet.Razor.Chunks;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors
{
@@ -19,16 +19,31 @@ namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors
///
/// The used to generate code.
/// The .
- public CSharpTagHelperRunnerInitializationVisitor([NotNull] CSharpCodeWriter writer,
- [NotNull] CodeGeneratorContext context)
+ public CSharpTagHelperRunnerInitializationVisitor(CSharpCodeWriter writer,
+ CodeGeneratorContext context)
: base(writer, context)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
_tagHelperContext = Context.Host.GeneratedClassContext.GeneratedTagHelperContext;
}
///
public override void Accept(Chunk chunk)
{
+ if (chunk == null)
+ {
+ throw new ArgumentNullException(nameof(chunk));
+ }
+
// If at any ParentChunk other than a TagHelperChunk, then dive into its Children to search for more
// TagHelperChunk nodes. This method avoids overriding each of the ParentChunk-specific Visit() methods to
// dive into Children.
diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpTypeMemberVisitor.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpTypeMemberVisitor.cs
index 1410730251..77656f9aa5 100644
--- a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpTypeMemberVisitor.cs
+++ b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpTypeMemberVisitor.cs
@@ -1,8 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using Microsoft.AspNet.Razor.Chunks;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors
{
@@ -10,11 +10,26 @@ namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors
{
private CSharpCodeVisitor _csharpCodeVisitor;
- public CSharpTypeMemberVisitor([NotNull] CSharpCodeVisitor csharpCodeVisitor,
- [NotNull] CSharpCodeWriter writer,
- [NotNull] CodeGeneratorContext context)
+ public CSharpTypeMemberVisitor(CSharpCodeVisitor csharpCodeVisitor,
+ CSharpCodeWriter writer,
+ CodeGeneratorContext context)
: base(writer, context)
{
+ if (csharpCodeVisitor == null)
+ {
+ throw new ArgumentNullException(nameof(csharpCodeVisitor));
+ }
+
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
_csharpCodeVisitor = csharpCodeVisitor;
}
diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpUsingVisitor.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpUsingVisitor.cs
index 3f56129c57..8a957be73f 100644
--- a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpUsingVisitor.cs
+++ b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CSharpUsingVisitor.cs
@@ -1,11 +1,11 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNet.Razor.Chunks;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors
{
@@ -15,9 +15,19 @@ namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors
private bool _foundTagHelpers;
- public CSharpUsingVisitor([NotNull] CSharpCodeWriter writer, [NotNull] CodeGeneratorContext context)
+ public CSharpUsingVisitor(CSharpCodeWriter writer, CodeGeneratorContext context)
: base(writer, context)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
ImportedUsings = new List();
}
@@ -26,6 +36,11 @@ namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors
///
public override void Accept(Chunk chunk)
{
+ if (chunk == null)
+ {
+ throw new ArgumentNullException(nameof(chunk));
+ }
+
// If at any ParentChunk other than a TagHelperChunk, then dive into its Children to search for more
// TagHelperChunk or UsingChunk nodes. This method avoids overriding each of the ParentChunk-specific
// Visit() methods to dive into Children.
diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/ChunkVisitor.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/ChunkVisitor.cs
index cbb5fef7a6..1f79be0b17 100644
--- a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/ChunkVisitor.cs
+++ b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/ChunkVisitor.cs
@@ -1,17 +1,27 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using System.Collections.Generic;
using Microsoft.AspNet.Razor.Chunks;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors
{
public abstract class ChunkVisitor : IChunkVisitor
where TWriter : CodeWriter
{
- public ChunkVisitor([NotNull] TWriter writer, [NotNull] CodeGeneratorContext context)
+ public ChunkVisitor(TWriter writer, CodeGeneratorContext context)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
Writer = writer;
Context = context;
}
@@ -19,16 +29,26 @@ namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors
protected TWriter Writer { get; private set; }
protected CodeGeneratorContext Context { get; private set; }
- public void Accept([NotNull] IList chunks)
+ public void Accept(IList chunks)
{
+ if (chunks == null)
+ {
+ throw new ArgumentNullException(nameof(chunks));
+ }
+
foreach (Chunk chunk in chunks)
{
Accept(chunk);
}
}
- public virtual void Accept([NotNull] Chunk chunk)
+ public virtual void Accept(Chunk chunk)
{
+ if (chunk == null)
+ {
+ throw new ArgumentNullException(nameof(chunk));
+ }
+
if (chunk is LiteralChunk)
{
Visit((LiteralChunk)chunk);
diff --git a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CodeVisitor.cs b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CodeVisitor.cs
index dab34ba9fa..c55ada4e65 100644
--- a/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CodeVisitor.cs
+++ b/src/Microsoft.AspNet.Razor/CodeGenerators/Visitors/CodeVisitor.cs
@@ -1,17 +1,26 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using Microsoft.AspNet.Razor.Chunks;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors
{
public class CodeVisitor : ChunkVisitor
where TWriter : CodeWriter
{
- public CodeVisitor([NotNull] TWriter writer, [NotNull] CodeGeneratorContext context)
+ public CodeVisitor(TWriter writer, CodeGeneratorContext context)
: base(writer, context)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
}
protected override void Visit(LiteralChunk chunk)
diff --git a/src/Microsoft.AspNet.Razor/Parser/MarkupRewriter.cs b/src/Microsoft.AspNet.Razor/Parser/MarkupRewriter.cs
index 1bd514a41c..bff770d22c 100644
--- a/src/Microsoft.AspNet.Razor/Parser/MarkupRewriter.cs
+++ b/src/Microsoft.AspNet.Razor/Parser/MarkupRewriter.cs
@@ -5,7 +5,6 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.Parser
{
@@ -14,8 +13,13 @@ namespace Microsoft.AspNet.Razor.Parser
private Stack _blocks = new Stack();
private Action _markupSpanFactory;
- protected MarkupRewriter([NotNull] Action markupSpanFactory)
+ protected MarkupRewriter(Action markupSpanFactory)
{
+ if (markupSpanFactory == null)
+ {
+ throw new ArgumentNullException(nameof(markupSpanFactory));
+ }
+
_markupSpanFactory = markupSpanFactory;
}
diff --git a/src/Microsoft.AspNet.Razor/Parser/ParserContext.cs b/src/Microsoft.AspNet.Razor/Parser/ParserContext.cs
index 912818a8ce..5dff26c23c 100644
--- a/src/Microsoft.AspNet.Razor/Parser/ParserContext.cs
+++ b/src/Microsoft.AspNet.Razor/Parser/ParserContext.cs
@@ -12,7 +12,6 @@ using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.TagHelpers;
using Microsoft.AspNet.Razor.Text;
using Microsoft.AspNet.Razor.Utils;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.Parser
{
@@ -25,12 +24,37 @@ namespace Microsoft.AspNet.Razor.Parser
private Stack _blockStack = new Stack();
private readonly ErrorSink _errorSink;
- public ParserContext([NotNull] ITextDocument source,
- [NotNull] ParserBase codeParser,
- [NotNull] ParserBase markupParser,
- [NotNull] ParserBase activeParser,
- [NotNull] ErrorSink errorSink)
+ public ParserContext(ITextDocument source,
+ ParserBase codeParser,
+ ParserBase markupParser,
+ ParserBase activeParser,
+ ErrorSink errorSink)
{
+ if (source == null)
+ {
+ throw new ArgumentNullException(nameof(source));
+ }
+
+ if (codeParser == null)
+ {
+ throw new ArgumentNullException(nameof(codeParser));
+ }
+
+ if (markupParser == null)
+ {
+ throw new ArgumentNullException(nameof(markupParser));
+ }
+
+ if (activeParser == null)
+ {
+ throw new ArgumentNullException(nameof(activeParser));
+ }
+
+ if (errorSink == null)
+ {
+ throw new ArgumentNullException(nameof(errorSink));
+ }
+
if (activeParser != codeParser && activeParser != markupParser)
{
throw new ArgumentException(RazorResources.ActiveParser_Must_Be_Code_Or_Markup_Parser, nameof(activeParser));
diff --git a/src/Microsoft.AspNet.Razor/Parser/ParserVisitorExtensions.cs b/src/Microsoft.AspNet.Razor/Parser/ParserVisitorExtensions.cs
index 0fa7689ba4..1a35aa2900 100644
--- a/src/Microsoft.AspNet.Razor/Parser/ParserVisitorExtensions.cs
+++ b/src/Microsoft.AspNet.Razor/Parser/ParserVisitorExtensions.cs
@@ -1,14 +1,24 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-using Microsoft.Framework.Internal;
+using System;
namespace Microsoft.AspNet.Razor.Parser
{
public static class ParserVisitorExtensions
{
- public static void Visit([NotNull] this ParserVisitor self, [NotNull] ParserResults result)
+ public static void Visit(this ParserVisitor self, ParserResults result)
{
+ if (self == null)
+ {
+ throw new ArgumentNullException(nameof(self));
+ }
+
+ if (result == null)
+ {
+ throw new ArgumentNullException(nameof(result));
+ }
+
result.Document.Accept(self);
foreach (RazorError error in result.ParserErrors)
{
diff --git a/src/Microsoft.AspNet.Razor/Parser/RazorParser.cs b/src/Microsoft.AspNet.Razor/Parser/RazorParser.cs
index c374b47b19..95a3ee89fe 100644
--- a/src/Microsoft.AspNet.Razor/Parser/RazorParser.cs
+++ b/src/Microsoft.AspNet.Razor/Parser/RazorParser.cs
@@ -13,7 +13,6 @@ using Microsoft.AspNet.Razor.Parser.TagHelpers;
using Microsoft.AspNet.Razor.Parser.TagHelpers.Internal;
using Microsoft.AspNet.Razor.TagHelpers;
using Microsoft.AspNet.Razor.Text;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.Parser
{
@@ -26,23 +25,37 @@ namespace Microsoft.AspNet.Razor.Parser
/// The used for parsing markup content.
/// The used to resolve
/// s.
- public RazorParser([NotNull] ParserBase codeParser,
- [NotNull] ParserBase markupParser,
+ public RazorParser(ParserBase codeParser,
+ ParserBase markupParser,
ITagHelperDescriptorResolver tagHelperDescriptorResolver)
: this(codeParser,
markupParser,
tagHelperDescriptorResolver,
GetDefaultRewriters(markupParser))
{
+ if (codeParser == null)
+ {
+ throw new ArgumentNullException(nameof(codeParser));
+ }
+
+ if (markupParser == null)
+ {
+ throw new ArgumentNullException(nameof(markupParser));
+ }
}
///
/// Initializes a new instance of from the specified .
///
/// The to copy values from.
- public RazorParser([NotNull] RazorParser parser)
+ public RazorParser(RazorParser parser)
: this(parser.CodeParser, parser.MarkupParser, parser.TagHelperDescriptorResolver, parser.Optimizers)
{
+ if (parser == null)
+ {
+ throw new ArgumentNullException(nameof(parser));
+ }
+
DesignTimeMode = parser.DesignTimeMode;
}
@@ -210,9 +223,19 @@ namespace Microsoft.AspNet.Razor.Parser
/// phase.
/// s that are applicable to the
///
- protected virtual IEnumerable GetTagHelperDescriptors([NotNull] Block documentRoot,
- [NotNull] ErrorSink errorSink)
+ protected virtual IEnumerable GetTagHelperDescriptors(Block documentRoot,
+ ErrorSink errorSink)
{
+ if (documentRoot == null)
+ {
+ throw new ArgumentNullException(nameof(documentRoot));
+ }
+
+ if (errorSink == null)
+ {
+ throw new ArgumentNullException(nameof(errorSink));
+ }
+
var addOrRemoveTagHelperSpanVisitor =
new TagHelperDirectiveSpanVisitor(TagHelperDescriptorResolver, errorSink);
return addOrRemoveTagHelperSpanVisitor.GetDescriptors(documentRoot);
diff --git a/src/Microsoft.AspNet.Razor/Parser/SyntaxTree/EquivalenceComparer.cs b/src/Microsoft.AspNet.Razor/Parser/SyntaxTree/EquivalenceComparer.cs
index e12ee9901a..2a861963b8 100644
--- a/src/Microsoft.AspNet.Razor/Parser/SyntaxTree/EquivalenceComparer.cs
+++ b/src/Microsoft.AspNet.Razor/Parser/SyntaxTree/EquivalenceComparer.cs
@@ -1,8 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using System.Collections.Generic;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.Parser.SyntaxTree
{
@@ -18,8 +18,13 @@ namespace Microsoft.AspNet.Razor.Parser.SyntaxTree
return nodeX != null && nodeX.EquivalentTo(nodeY);
}
- public int GetHashCode([NotNull] SyntaxTreeNode node)
+ public int GetHashCode(SyntaxTreeNode node)
{
+ if (node == null)
+ {
+ throw new ArgumentNullException(nameof(node));
+ }
+
return node.GetEquivalenceHash();
}
}
diff --git a/src/Microsoft.AspNet.Razor/Parser/TagHelpers/TagHelperDirectiveSpanVisitor.cs b/src/Microsoft.AspNet.Razor/Parser/TagHelpers/TagHelperDirectiveSpanVisitor.cs
index 34b4be0b55..5f1c415699 100644
--- a/src/Microsoft.AspNet.Razor/Parser/TagHelpers/TagHelperDirectiveSpanVisitor.cs
+++ b/src/Microsoft.AspNet.Razor/Parser/TagHelpers/TagHelperDirectiveSpanVisitor.cs
@@ -1,11 +1,11 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using System.Collections.Generic;
using Microsoft.AspNet.Razor.Chunks.Generators;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.TagHelpers;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.Parser.TagHelpers
{
@@ -27,15 +27,30 @@ namespace Microsoft.AspNet.Razor.Parser.TagHelpers
}
public TagHelperDirectiveSpanVisitor(
- [NotNull] ITagHelperDescriptorResolver descriptorResolver,
- [NotNull] ErrorSink errorSink)
+ ITagHelperDescriptorResolver descriptorResolver,
+ ErrorSink errorSink)
{
+ if (descriptorResolver == null)
+ {
+ throw new ArgumentNullException(nameof(descriptorResolver));
+ }
+
+ if (errorSink == null)
+ {
+ throw new ArgumentNullException(nameof(errorSink));
+ }
+
_descriptorResolver = descriptorResolver;
_errorSink = errorSink;
}
- public IEnumerable GetDescriptors([NotNull] Block root)
+ public IEnumerable GetDescriptors(Block root)
{
+ if (root == null)
+ {
+ throw new ArgumentNullException(nameof(root));
+ }
+
_directiveDescriptors = new List();
// This will recurse through the syntax tree.
@@ -49,9 +64,19 @@ namespace Microsoft.AspNet.Razor.Parser.TagHelpers
// Allows MVC a chance to override the TagHelperDescriptorResolutionContext
protected virtual TagHelperDescriptorResolutionContext GetTagHelperDescriptorResolutionContext(
- [NotNull] IEnumerable descriptors,
- [NotNull] ErrorSink errorSink)
+ IEnumerable descriptors,
+ ErrorSink errorSink)
{
+ if (descriptors == null)
+ {
+ throw new ArgumentNullException(nameof(descriptors));
+ }
+
+ if (errorSink == null)
+ {
+ throw new ArgumentNullException(nameof(errorSink));
+ }
+
return new TagHelperDescriptorResolutionContext(descriptors, errorSink);
}
diff --git a/src/Microsoft.AspNet.Razor/Parser/TextReaderExtensions.cs b/src/Microsoft.AspNet.Razor/Parser/TextReaderExtensions.cs
index c0cfd20db2..492b41bc9c 100644
--- a/src/Microsoft.AspNet.Razor/Parser/TextReaderExtensions.cs
+++ b/src/Microsoft.AspNet.Razor/Parser/TextReaderExtensions.cs
@@ -5,47 +5,96 @@ using System;
using System.IO;
using System.Linq;
using System.Text;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.Parser
{
internal static class TextReaderExtensions
{
- public static string ReadUntil([NotNull] this TextReader reader, char terminator)
+ public static string ReadUntil(this TextReader reader, char terminator)
{
+ if (reader == null)
+ {
+ throw new ArgumentNullException(nameof(reader));
+ }
+
return ReadUntil(reader, terminator, inclusive: false);
}
- public static string ReadUntil([NotNull] this TextReader reader, char terminator, bool inclusive)
+ public static string ReadUntil(this TextReader reader, char terminator, bool inclusive)
{
+ if (reader == null)
+ {
+ throw new ArgumentNullException(nameof(reader));
+ }
+
// Rather not allocate an array to use ReadUntil(TextReader, params char[]) so we'll just call the predicate version directly
return ReadUntil(reader, c => c == terminator, inclusive);
}
- public static string ReadUntil([NotNull] this TextReader reader, [NotNull] params char[] terminators)
+ public static string ReadUntil(this TextReader reader, params char[] terminators)
{
+ if (reader == null)
+ {
+ throw new ArgumentNullException(nameof(reader));
+ }
+
+ if (terminators == null)
+ {
+ throw new ArgumentNullException(nameof(terminators));
+ }
+
// NOTE: Using named parameters would be difficult here, hence the inline comment
return ReadUntil(reader, inclusive: false, terminators: terminators);
}
public static string ReadUntil(
- [NotNull] this TextReader reader,
+ this TextReader reader,
bool inclusive,
- [NotNull] params char[] terminators)
+ params char[] terminators)
{
+ if (reader == null)
+ {
+ throw new ArgumentNullException(nameof(reader));
+ }
+
+ if (terminators == null)
+ {
+ throw new ArgumentNullException(nameof(terminators));
+ }
+
return ReadUntil(reader, c => terminators.Any(tc => tc == c), inclusive: inclusive);
}
- public static string ReadUntil([NotNull] this TextReader reader, [NotNull] Predicate condition)
+ public static string ReadUntil(this TextReader reader, Predicate condition)
{
+ if (reader == null)
+ {
+ throw new ArgumentNullException(nameof(reader));
+ }
+
+ if (condition == null)
+ {
+ throw new ArgumentNullException(nameof(condition));
+ }
+
return ReadUntil(reader, condition, inclusive: false);
}
public static string ReadUntil(
- [NotNull] this TextReader reader,
- [NotNull] Predicate condition,
+ this TextReader reader,
+ Predicate condition,
bool inclusive)
{
+ if (reader == null)
+ {
+ throw new ArgumentNullException(nameof(reader));
+ }
+
+ if (condition == null)
+ {
+ throw new ArgumentNullException(nameof(condition));
+ }
+
var builder = new StringBuilder();
var ch = -1;
while ((ch = reader.Peek()) != -1 && !condition((char)ch))
@@ -62,26 +111,56 @@ namespace Microsoft.AspNet.Razor.Parser
return builder.ToString();
}
- public static string ReadWhile([NotNull] this TextReader reader, [NotNull] Predicate condition)
+ public static string ReadWhile(this TextReader reader, Predicate condition)
{
+ if (reader == null)
+ {
+ throw new ArgumentNullException(nameof(reader));
+ }
+
+ if (condition == null)
+ {
+ throw new ArgumentNullException(nameof(condition));
+ }
+
return ReadWhile(reader, condition, inclusive: false);
}
public static string ReadWhile(
- [NotNull] this TextReader reader,
- [NotNull] Predicate condition,
+ this TextReader reader,
+ Predicate condition,
bool inclusive)
{
+ if (reader == null)
+ {
+ throw new ArgumentNullException(nameof(reader));
+ }
+
+ if (condition == null)
+ {
+ throw new ArgumentNullException(nameof(condition));
+ }
+
return ReadUntil(reader, ch => !condition(ch), inclusive);
}
- public static string ReadWhiteSpace([NotNull] this TextReader reader)
+ public static string ReadWhiteSpace(this TextReader reader)
{
+ if (reader == null)
+ {
+ throw new ArgumentNullException(nameof(reader));
+ }
+
return ReadWhile(reader, c => Char.IsWhiteSpace(c));
}
- public static string ReadUntilWhiteSpace([NotNull] this TextReader reader)
+ public static string ReadUntilWhiteSpace(this TextReader reader)
{
+ if (reader == null)
+ {
+ throw new ArgumentNullException(nameof(reader));
+ }
+
return ReadUntil(reader, c => Char.IsWhiteSpace(c));
}
}
diff --git a/src/Microsoft.AspNet.Razor/Parser/WhitespaceRewriter.cs b/src/Microsoft.AspNet.Razor/Parser/WhitespaceRewriter.cs
index 99855d20b1..c94a15d43e 100644
--- a/src/Microsoft.AspNet.Razor/Parser/WhitespaceRewriter.cs
+++ b/src/Microsoft.AspNet.Razor/Parser/WhitespaceRewriter.cs
@@ -5,15 +5,18 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.Parser
{
internal class WhiteSpaceRewriter : MarkupRewriter
{
- public WhiteSpaceRewriter([NotNull] Action markupSpanFactory)
+ public WhiteSpaceRewriter(Action markupSpanFactory)
: base(markupSpanFactory)
{
+ if (markupSpanFactory == null)
+ {
+ throw new ArgumentNullException(nameof(markupSpanFactory));
+ }
}
protected override bool CanRewrite(Block block)
diff --git a/src/Microsoft.AspNet.Razor/ParserResults.cs b/src/Microsoft.AspNet.Razor/ParserResults.cs
index 847d654a6c..799e210795 100644
--- a/src/Microsoft.AspNet.Razor/ParserResults.cs
+++ b/src/Microsoft.AspNet.Razor/ParserResults.cs
@@ -1,11 +1,11 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.TagHelpers;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor
{
@@ -25,11 +25,25 @@ namespace Microsoft.AspNet.Razor
/// The used to collect s encountered when parsing the
/// current Razor document.
///
- public ParserResults([NotNull] Block document,
- [NotNull] IEnumerable tagHelperDescriptors,
- [NotNull] ErrorSink errorSink)
+ public ParserResults(Block document,
+ IEnumerable tagHelperDescriptors,
+ ErrorSink errorSink)
: this(!errorSink.Errors.Any(), document, tagHelperDescriptors, errorSink)
{
+ if (document == null)
+ {
+ throw new ArgumentNullException(nameof(document));
+ }
+
+ if (tagHelperDescriptors == null)
+ {
+ throw new ArgumentNullException(nameof(tagHelperDescriptors));
+ }
+
+ if (errorSink == null)
+ {
+ throw new ArgumentNullException(nameof(errorSink));
+ }
}
///
@@ -45,10 +59,25 @@ namespace Microsoft.AspNet.Razor
/// current Razor document.
///
protected ParserResults(bool success,
- [NotNull] Block document,
- [NotNull] IEnumerable tagHelperDescriptors,
- [NotNull] ErrorSink errorSink)
+ Block document,
+ IEnumerable tagHelperDescriptors,
+ ErrorSink errorSink)
{
+ if (document == null)
+ {
+ throw new ArgumentNullException(nameof(document));
+ }
+
+ if (tagHelperDescriptors == null)
+ {
+ throw new ArgumentNullException(nameof(tagHelperDescriptors));
+ }
+
+ if (errorSink == null)
+ {
+ throw new ArgumentNullException(nameof(errorSink));
+ }
+
Success = success;
Document = document;
TagHelperDescriptors = tagHelperDescriptors;
diff --git a/src/Microsoft.AspNet.Razor/RazorEditorParser.cs b/src/Microsoft.AspNet.Razor/RazorEditorParser.cs
index 6e76ac4f26..cb83079f23 100644
--- a/src/Microsoft.AspNet.Razor/RazorEditorParser.cs
+++ b/src/Microsoft.AspNet.Razor/RazorEditorParser.cs
@@ -9,7 +9,6 @@ using System.IO;
using Microsoft.AspNet.Razor.Editor;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Text;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor
{
@@ -68,8 +67,13 @@ namespace Microsoft.AspNet.Razor
///
/// The which defines the environment in which the generated code will live. should be set if design-time code mappings are desired
/// The physical path to use in line pragmas
- public RazorEditorParser([NotNull] RazorEngineHost host, string sourceFileName)
+ public RazorEditorParser(RazorEngineHost host, string sourceFileName)
{
+ if (host == null)
+ {
+ throw new ArgumentNullException(nameof(host));
+ }
+
if (string.IsNullOrEmpty(sourceFileName))
{
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, nameof(sourceFileName));
diff --git a/src/Microsoft.AspNet.Razor/RazorEngineHost.cs b/src/Microsoft.AspNet.Razor/RazorEngineHost.cs
index ba705e3c18..93783b6ba5 100644
--- a/src/Microsoft.AspNet.Razor/RazorEngineHost.cs
+++ b/src/Microsoft.AspNet.Razor/RazorEngineHost.cs
@@ -8,7 +8,6 @@ using Microsoft.AspNet.Razor.Chunks.Generators;
using Microsoft.AspNet.Razor.CodeGenerators;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.TagHelpers;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor
{
@@ -54,17 +53,31 @@ namespace Microsoft.AspNet.Razor
/// Creates a host which uses the specified code language and the HTML markup language
///
/// The code language to use
- public RazorEngineHost([NotNull] RazorCodeLanguage codeLanguage)
+ public RazorEngineHost(RazorCodeLanguage codeLanguage)
: this(codeLanguage, () => new HtmlMarkupParser())
{
+ if (codeLanguage == null)
+ {
+ throw new ArgumentNullException(nameof(codeLanguage));
+ }
}
[SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Justification = "The code path is safe, it is a property setter and not dependent on other state")]
public RazorEngineHost(
- [NotNull] RazorCodeLanguage codeLanguage,
- [NotNull] Func markupParserFactory)
+ RazorCodeLanguage codeLanguage,
+ Func markupParserFactory)
: this()
{
+ if (codeLanguage == null)
+ {
+ throw new ArgumentNullException(nameof(codeLanguage));
+ }
+
+ if (markupParserFactory == null)
+ {
+ throw new ArgumentNullException(nameof(markupParserFactory));
+ }
+
CodeLanguage = codeLanguage;
_markupParserFactory = markupParserFactory;
}
@@ -170,9 +183,14 @@ namespace Microsoft.AspNet.Razor
/// The file name of the Razor file being parsed.
/// Either the same code parser, after modifications, or a different code parser.
public virtual RazorParser DecorateRazorParser(
- [NotNull] RazorParser incomingRazorParser,
+ RazorParser incomingRazorParser,
string sourceFileName)
{
+ if (incomingRazorParser == null)
+ {
+ throw new ArgumentNullException(nameof(incomingRazorParser));
+ }
+
return incomingRazorParser;
}
@@ -181,8 +199,13 @@ namespace Microsoft.AspNet.Razor
///
/// The code parser
/// Either the same code parser, after modifications, or a different code parser
- public virtual ParserBase DecorateCodeParser([NotNull] ParserBase incomingCodeParser)
+ public virtual ParserBase DecorateCodeParser(ParserBase incomingCodeParser)
{
+ if (incomingCodeParser == null)
+ {
+ throw new ArgumentNullException(nameof(incomingCodeParser));
+ }
+
return incomingCodeParser;
}
@@ -191,8 +214,13 @@ namespace Microsoft.AspNet.Razor
///
/// The markup parser
/// Either the same markup parser, after modifications, or a different markup parser
- public virtual ParserBase DecorateMarkupParser([NotNull] ParserBase incomingMarkupParser)
+ public virtual ParserBase DecorateMarkupParser(ParserBase incomingMarkupParser)
{
+ if (incomingMarkupParser == null)
+ {
+ throw new ArgumentNullException(nameof(incomingMarkupParser));
+ }
+
return incomingMarkupParser;
}
@@ -201,8 +229,13 @@ namespace Microsoft.AspNet.Razor
///
/// The chunk generator
/// Either the same chunk generator, after modifications, or a different chunk generator
- public virtual RazorChunkGenerator DecorateChunkGenerator([NotNull] RazorChunkGenerator incomingChunkGenerator)
+ public virtual RazorChunkGenerator DecorateChunkGenerator(RazorChunkGenerator incomingChunkGenerator)
{
+ if (incomingChunkGenerator == null)
+ {
+ throw new ArgumentNullException(nameof(incomingChunkGenerator));
+ }
+
return incomingChunkGenerator;
}
@@ -212,9 +245,14 @@ namespace Microsoft.AspNet.Razor
/// The code generator
/// Either the same code generator, after modifications, or a different code generator.
public virtual CodeGenerator DecorateCodeGenerator(
- [NotNull] CodeGenerator incomingBuilder,
+ CodeGenerator incomingBuilder,
CodeGeneratorContext context)
{
+ if (incomingBuilder == null)
+ {
+ throw new ArgumentNullException(nameof(incomingBuilder));
+ }
+
return incomingBuilder;
}
diff --git a/src/Microsoft.AspNet.Razor/RazorTemplateEngine.cs b/src/Microsoft.AspNet.Razor/RazorTemplateEngine.cs
index b7dbb87ae5..b89ae9c0f4 100644
--- a/src/Microsoft.AspNet.Razor/RazorTemplateEngine.cs
+++ b/src/Microsoft.AspNet.Razor/RazorTemplateEngine.cs
@@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
@@ -11,7 +12,6 @@ using Microsoft.AspNet.Razor.Chunks.Generators;
using Microsoft.AspNet.Razor.CodeGenerators;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Text;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor
{
@@ -30,8 +30,13 @@ namespace Microsoft.AspNet.Razor
///
/// The host which defines the environment in which the generated template code will live.
///
- public RazorTemplateEngine([NotNull] RazorEngineHost host)
+ public RazorTemplateEngine(RazorEngineHost host)
{
+ if (host == null)
+ {
+ throw new ArgumentNullException(nameof(host));
+ }
+
Host = host;
}
@@ -40,8 +45,13 @@ namespace Microsoft.AspNet.Razor
///
public RazorEngineHost Host { get; }
- public ParserResults ParseTemplate([NotNull] ITextBuffer input)
+ public ParserResults ParseTemplate(ITextBuffer input)
{
+ if (input == null)
+ {
+ throw new ArgumentNullException(nameof(input));
+ }
+
return ParseTemplate(input, cancelToken: null);
}
@@ -67,15 +77,25 @@ namespace Microsoft.AspNet.Razor
"Microsoft.Reliability", "CA2000:Dispose objects before losing scope",
Justification = "Input object would be disposed if we dispose the wrapper. We don't own the input so " +
"we don't want to dispose it")]
- public ParserResults ParseTemplate([NotNull] ITextBuffer input, CancellationToken? cancelToken)
+ public ParserResults ParseTemplate(ITextBuffer input, CancellationToken? cancelToken)
{
+ if (input == null)
+ {
+ throw new ArgumentNullException(nameof(input));
+ }
+
return ParseTemplateCore(input.ToDocument(), sourceFileName: null, cancelToken: cancelToken);
}
// See ParseTemplate(ITextBuffer, CancellationToken?),
// this overload simply wraps a TextReader in a TextBuffer (see ITextBuffer and BufferingTextReader)
- public ParserResults ParseTemplate([NotNull] TextReader input, string sourceFileName)
+ public ParserResults ParseTemplate(TextReader input, string sourceFileName)
{
+ if (input == null)
+ {
+ throw new ArgumentNullException(nameof(input));
+ }
+
return ParseTemplateCore(new SeekableTextReader(input), sourceFileName, cancelToken: null);
}
@@ -84,29 +104,49 @@ namespace Microsoft.AspNet.Razor
"CA2000:Dispose objects before losing scope",
Justification = "Input object would be disposed if we dispose the wrapper. We don't own the input so " +
"we don't want to dispose it")]
- public ParserResults ParseTemplate([NotNull] TextReader input, CancellationToken? cancelToken)
+ public ParserResults ParseTemplate(TextReader input, CancellationToken? cancelToken)
{
+ if (input == null)
+ {
+ throw new ArgumentNullException(nameof(input));
+ }
+
return ParseTemplateCore(new SeekableTextReader(input), sourceFileName: null, cancelToken: cancelToken);
}
protected internal virtual ParserResults ParseTemplateCore(
- [NotNull] ITextDocument input,
+ ITextDocument input,
string sourceFileName,
CancellationToken? cancelToken)
{
+ if (input == null)
+ {
+ throw new ArgumentNullException(nameof(input));
+ }
+
// Construct the parser
var parser = CreateParser(sourceFileName);
Debug.Assert(parser != null);
return parser.Parse(input);
}
- public GeneratorResults GenerateCode([NotNull] ITextBuffer input)
+ public GeneratorResults GenerateCode(ITextBuffer input)
{
+ if (input == null)
+ {
+ throw new ArgumentNullException(nameof(input));
+ }
+
return GenerateCode(input, className: null, rootNamespace: null, sourceFileName: null, cancelToken: null);
}
- public GeneratorResults GenerateCode([NotNull] ITextBuffer input, CancellationToken? cancelToken)
+ public GeneratorResults GenerateCode(ITextBuffer input, CancellationToken? cancelToken)
{
+ if (input == null)
+ {
+ throw new ArgumentNullException(nameof(input));
+ }
+
return GenerateCode(
input,
className: null,
@@ -116,11 +156,16 @@ namespace Microsoft.AspNet.Razor
}
public GeneratorResults GenerateCode(
- [NotNull] ITextBuffer input,
+ ITextBuffer input,
string className,
string rootNamespace,
string sourceFileName)
{
+ if (input == null)
+ {
+ throw new ArgumentNullException(nameof(input));
+ }
+
return GenerateCode(input, className, rootNamespace, sourceFileName, cancelToken: null);
}
@@ -163,12 +208,17 @@ namespace Microsoft.AspNet.Razor
Justification = "Input object would be disposed if we dispose the wrapper. We don't own the input so " +
"we don't want to dispose it")]
public GeneratorResults GenerateCode(
- [NotNull] ITextBuffer input,
+ ITextBuffer input,
string className,
string rootNamespace,
string sourceFileName,
CancellationToken? cancelToken)
{
+ if (input == null)
+ {
+ throw new ArgumentNullException(nameof(input));
+ }
+
return GenerateCodeCore(
input.ToDocument(),
className,
@@ -179,13 +229,23 @@ namespace Microsoft.AspNet.Razor
}
// See GenerateCode override which takes ITextBuffer, and BufferingTextReader for details.
- public GeneratorResults GenerateCode([NotNull] TextReader input)
+ public GeneratorResults GenerateCode(TextReader input)
{
+ if (input == null)
+ {
+ throw new ArgumentNullException(nameof(input));
+ }
+
return GenerateCode(input, className: null, rootNamespace: null, sourceFileName: null, cancelToken: null);
}
- public GeneratorResults GenerateCode([NotNull] TextReader input, CancellationToken? cancelToken)
+ public GeneratorResults GenerateCode(TextReader input, CancellationToken? cancelToken)
{
+ if (input == null)
+ {
+ throw new ArgumentNullException(nameof(input));
+ }
+
return GenerateCode(
input,
className: null,
@@ -195,11 +255,16 @@ namespace Microsoft.AspNet.Razor
}
public GeneratorResults GenerateCode(
- [NotNull] TextReader input,
+ TextReader input,
string className,
string rootNamespace, string sourceFileName)
{
+ if (input == null)
+ {
+ throw new ArgumentNullException(nameof(input));
+ }
+
return GenerateCode(input, className, rootNamespace, sourceFileName, cancelToken: null);
}
@@ -221,11 +286,16 @@ namespace Microsoft.AspNet.Razor
/// debugging.
///
public GeneratorResults GenerateCode(
- [NotNull] Stream inputStream,
+ Stream inputStream,
string className,
string rootNamespace,
string sourceFileName)
{
+ if (inputStream == null)
+ {
+ throw new ArgumentNullException(nameof(inputStream));
+ }
+
MemoryStream memoryStream = null;
string checksum = null;
try
@@ -280,12 +350,17 @@ namespace Microsoft.AspNet.Razor
Justification = "Input object would be disposed if we dispose the wrapper. We don't own the input so " +
"we don't want to dispose it")]
public GeneratorResults GenerateCode(
- [NotNull] TextReader input,
+ TextReader input,
string className,
string rootNamespace,
string sourceFileName,
CancellationToken? cancelToken)
{
+ if (input == null)
+ {
+ throw new ArgumentNullException(nameof(input));
+ }
+
return GenerateCodeCore(
new SeekableTextReader(input),
className,
@@ -296,13 +371,18 @@ namespace Microsoft.AspNet.Razor
}
protected internal virtual GeneratorResults GenerateCodeCore(
- [NotNull] ITextDocument input,
+ ITextDocument input,
string className,
string rootNamespace,
string sourceFileName,
string checksum,
CancellationToken? cancelToken)
{
+ if (input == null)
+ {
+ throw new ArgumentNullException(nameof(input));
+ }
+
className = (className ?? Host.DefaultClassName) ?? DefaultClassName;
rootNamespace = (rootNamespace ?? Host.DefaultNamespace) ?? DefaultNamespace;
diff --git a/src/Microsoft.AspNet.Razor/SourceLocation.cs b/src/Microsoft.AspNet.Razor/SourceLocation.cs
index d779dfc3c7..14b775d500 100644
--- a/src/Microsoft.AspNet.Razor/SourceLocation.cs
+++ b/src/Microsoft.AspNet.Razor/SourceLocation.cs
@@ -127,8 +127,13 @@ namespace Microsoft.AspNet.Razor
/// The to advance.
/// The to advance by.
/// The advanced .
- public static SourceLocation Advance(SourceLocation left, [NotNull] string text)
+ public static SourceLocation Advance(SourceLocation left, string text)
{
+ if (text == null)
+ {
+ throw new ArgumentNullException(nameof(text));
+ }
+
var tracker = new SourceLocationTracker(left);
tracker.UpdateLocation(text);
return tracker.CurrentLocation;
diff --git a/src/Microsoft.AspNet.Razor/TagHelpers/TagHelperAttributeDescriptor.cs b/src/Microsoft.AspNet.Razor/TagHelpers/TagHelperAttributeDescriptor.cs
index b0342a8c81..8fc2983c1d 100644
--- a/src/Microsoft.AspNet.Razor/TagHelpers/TagHelperAttributeDescriptor.cs
+++ b/src/Microsoft.AspNet.Razor/TagHelpers/TagHelperAttributeDescriptor.cs
@@ -3,7 +3,6 @@
using System;
using System.Reflection;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.TagHelpers
{
@@ -13,6 +12,8 @@ namespace Microsoft.AspNet.Razor.TagHelpers
public class TagHelperAttributeDescriptor
{
private string _typeName;
+ private string _name;
+ private string _propertyName;
///
/// Instantiates a new instance of the class.
@@ -59,12 +60,43 @@ namespace Microsoft.AspNet.Razor.TagHelpers
/// The HTML attribute name or, if is true, the prefix for matching attribute
/// names.
///
- public string Name { get; [param: NotNull] set; }
+ public string Name
+ {
+ get
+ {
+ return _name;
+ }
+ set
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
+
+ _name = value;
+ }
+ }
+
///
/// The name of the CLR property that corresponds to the HTML attribute.
///
- public string PropertyName { get; [param: NotNull] set; }
+ public string PropertyName
+ {
+ get
+ {
+ return _propertyName;
+ }
+ set
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
+
+ _propertyName = value;
+ }
+ }
///
/// The full name of the named (see ) property's or, if
@@ -76,8 +108,13 @@ namespace Microsoft.AspNet.Razor.TagHelpers
{
return _typeName;
}
- [param: NotNull] set
+ set
{
+ if (value == null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
+
_typeName = value;
IsStringProperty = string.Equals(_typeName, typeof(string).FullName, StringComparison.Ordinal);
}
diff --git a/src/Microsoft.AspNet.Razor/TagHelpers/TagHelperDescriptor.cs b/src/Microsoft.AspNet.Razor/TagHelpers/TagHelperDescriptor.cs
index 92f1b59396..68646e9211 100644
--- a/src/Microsoft.AspNet.Razor/TagHelpers/TagHelperDescriptor.cs
+++ b/src/Microsoft.AspNet.Razor/TagHelpers/TagHelperDescriptor.cs
@@ -1,10 +1,10 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.TagHelpers
{
@@ -13,16 +13,54 @@ namespace Microsoft.AspNet.Razor.TagHelpers
///
public class TagHelperDescriptor
{
+ private string _prefix = string.Empty;
+ private string _tagName;
+ private string _typeName;
+ private string _assemblyName;
+ private IEnumerable _attributes =
+ Enumerable.Empty();
+ private IEnumerable _requiredAttributes = Enumerable.Empty();
+
///
/// Text used as a required prefix when matching HTML start and end tags in the Razor source to available
/// tag helpers.
///
- public string Prefix { get; [param: NotNull] set; } = string.Empty;
+ public string Prefix
+ {
+ get
+ {
+ return _prefix;
+ }
+ set
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
+
+ _prefix = value;
+ }
+ }
///
/// The tag name that the tag helper should target.
///
- public string TagName { get; [param: NotNull] set; }
+ public string TagName
+ {
+ get
+ {
+ return _tagName;
+ }
+ set
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
+
+ _tagName = value;
+ }
+ }
///
/// The full tag name that is required for the tag helper to target an HTML element.
@@ -39,18 +77,62 @@ namespace Microsoft.AspNet.Razor.TagHelpers
///
/// The full name of the tag helper class.
///
- public string TypeName { get; [param: NotNull] set; }
+ public string TypeName
+ {
+ get
+ {
+ return _typeName;
+ }
+ set
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
+
+ _typeName = value;
+ }
+ }
///
/// The name of the assembly containing the tag helper class.
///
- public string AssemblyName { get; [param: NotNull] set; }
+ public string AssemblyName
+ {
+ get
+ {
+ return _assemblyName;
+ }
+ set
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
+
+ _assemblyName = value;
+ }
+ }
///
/// The list of attributes the tag helper expects.
///
- public IEnumerable Attributes { get; [param: NotNull] set; }
- = Enumerable.Empty();
+ public IEnumerable Attributes
+ {
+ get
+ {
+ return _attributes;
+ }
+ set
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
+
+ _attributes = value;
+ }
+ }
///
/// The list of required attribute names the tag helper expects to target an element.
@@ -58,7 +140,22 @@ namespace Microsoft.AspNet.Razor.TagHelpers
///
/// * at the end of an attribute name acts as a prefix match.
///
- public IEnumerable RequiredAttributes { get; [param: NotNull] set; } = Enumerable.Empty();
+ public IEnumerable RequiredAttributes
+ {
+ get
+ {
+ return _requiredAttributes;
+ }
+ set
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
+
+ _requiredAttributes = value;
+ }
+ }
///
/// Get the names of elements allowed as children. Tag helpers must target all such elements.
diff --git a/src/Microsoft.AspNet.Razor/TagHelpers/TagHelperDescriptorComparer.cs b/src/Microsoft.AspNet.Razor/TagHelpers/TagHelperDescriptorComparer.cs
index 1fff142a56..e7c4fb4599 100644
--- a/src/Microsoft.AspNet.Razor/TagHelpers/TagHelperDescriptorComparer.cs
+++ b/src/Microsoft.AspNet.Razor/TagHelpers/TagHelperDescriptorComparer.cs
@@ -61,8 +61,13 @@ namespace Microsoft.AspNet.Razor.TagHelpers
}
///
- public virtual int GetHashCode([NotNull] TagHelperDescriptor descriptor)
+ public virtual int GetHashCode(TagHelperDescriptor descriptor)
{
+ if (descriptor == null)
+ {
+ throw new ArgumentNullException(nameof(descriptor));
+ }
+
var hashCodeCombiner = HashCodeCombiner.Start()
.Add(descriptor.TypeName, StringComparer.Ordinal)
.Add(descriptor.TagName, StringComparer.OrdinalIgnoreCase)
diff --git a/src/Microsoft.AspNet.Razor/TagHelpers/TagHelperDescriptorResolutionContext.cs b/src/Microsoft.AspNet.Razor/TagHelpers/TagHelperDescriptorResolutionContext.cs
index fc560351e3..67ec4d99a7 100644
--- a/src/Microsoft.AspNet.Razor/TagHelpers/TagHelperDescriptorResolutionContext.cs
+++ b/src/Microsoft.AspNet.Razor/TagHelpers/TagHelperDescriptorResolutionContext.cs
@@ -1,8 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using System.Collections.Generic;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.TagHelpers
{
@@ -24,9 +24,19 @@ namespace Microsoft.AspNet.Razor.TagHelpers
/// s.
/// Used to aggregate s.
public TagHelperDescriptorResolutionContext(
- [NotNull] IEnumerable directiveDescriptors,
- [NotNull] ErrorSink errorSink)
+ IEnumerable directiveDescriptors,
+ ErrorSink errorSink)
{
+ if (directiveDescriptors == null)
+ {
+ throw new ArgumentNullException(nameof(directiveDescriptors));
+ }
+
+ if (errorSink == null)
+ {
+ throw new ArgumentNullException(nameof(errorSink));
+ }
+
DirectiveDescriptors = new List(directiveDescriptors);
ErrorSink = errorSink;
}
diff --git a/src/Microsoft.AspNet.Razor/TagHelpers/TagHelperDirectiveDescriptor.cs b/src/Microsoft.AspNet.Razor/TagHelpers/TagHelperDirectiveDescriptor.cs
index 07900ca0f7..140f39d23c 100644
--- a/src/Microsoft.AspNet.Razor/TagHelpers/TagHelperDirectiveDescriptor.cs
+++ b/src/Microsoft.AspNet.Razor/TagHelpers/TagHelperDirectiveDescriptor.cs
@@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-using Microsoft.Framework.Internal;
+using System;
namespace Microsoft.AspNet.Razor.TagHelpers
{
@@ -10,10 +10,27 @@ namespace Microsoft.AspNet.Razor.TagHelpers
///
public class TagHelperDirectiveDescriptor
{
+ private string _directiveText;
+
///
/// A used to find tag helper s.
///
- public string DirectiveText { get; [param: NotNull] set; }
+ public string DirectiveText
+ {
+ get
+ {
+ return _directiveText;
+ }
+ set
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
+
+ _directiveText = value;
+ }
+ }
///
/// The of the directive.
diff --git a/src/Microsoft.AspNet.Razor/TagHelpers/TypeBasedTagHelperDescriptorComparer.cs b/src/Microsoft.AspNet.Razor/TagHelpers/TypeBasedTagHelperDescriptorComparer.cs
index 6de545ac14..d3251f3fe4 100644
--- a/src/Microsoft.AspNet.Razor/TagHelpers/TypeBasedTagHelperDescriptorComparer.cs
+++ b/src/Microsoft.AspNet.Razor/TagHelpers/TypeBasedTagHelperDescriptorComparer.cs
@@ -1,4 +1,4 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@@ -47,8 +47,13 @@ namespace Microsoft.AspNet.Razor.TagHelpers
}
///
- public int GetHashCode([NotNull] TagHelperDescriptor descriptor)
+ public int GetHashCode(TagHelperDescriptor descriptor)
{
+ if (descriptor == null)
+ {
+ throw new ArgumentNullException(nameof(descriptor));
+ }
+
return HashCodeCombiner.Start()
.Add(descriptor.AssemblyName, StringComparer.Ordinal)
.Add(descriptor.TypeName, StringComparer.Ordinal)
diff --git a/src/Microsoft.AspNet.Razor/Text/BufferingTextReader.cs b/src/Microsoft.AspNet.Razor/Text/BufferingTextReader.cs
index 8e05ebaa6c..b247b416e4 100644
--- a/src/Microsoft.AspNet.Razor/Text/BufferingTextReader.cs
+++ b/src/Microsoft.AspNet.Razor/Text/BufferingTextReader.cs
@@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.IO;
using System.Text;
using Microsoft.AspNet.Razor.Utils;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.Text
{
@@ -18,8 +17,13 @@ namespace Microsoft.AspNet.Razor.Text
private int _currentCharacter;
private SourceLocationTracker _locationTracker;
- public BufferingTextReader([NotNull] TextReader source)
+ public BufferingTextReader(TextReader source)
{
+ if (source == null)
+ {
+ throw new ArgumentNullException(nameof(source));
+ }
+
InnerReader = source;
_locationTracker = new SourceLocationTracker();
diff --git a/src/Microsoft.AspNet.Razor/Text/LocationTagged.cs b/src/Microsoft.AspNet.Razor/Text/LocationTagged.cs
index 4bb3d3ee4d..efc811a042 100644
--- a/src/Microsoft.AspNet.Razor/Text/LocationTagged.cs
+++ b/src/Microsoft.AspNet.Razor/Text/LocationTagged.cs
@@ -17,13 +17,22 @@ namespace Microsoft.AspNet.Razor.Text
Value = default(TValue);
}
- public LocationTagged([NotNull] TValue value, int offset, int line, int col)
+ public LocationTagged(TValue value, int offset, int line, int col)
: this(value, new SourceLocation(offset, line, col))
{
+ if (value == null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
}
- public LocationTagged([NotNull] TValue value, SourceLocation location)
+ public LocationTagged(TValue value, SourceLocation location)
{
+ if (value == null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
+
Location = location;
Value = value;
}
diff --git a/src/Microsoft.AspNet.Razor/Text/SeekableTextReader.cs b/src/Microsoft.AspNet.Razor/Text/SeekableTextReader.cs
index db2582a37b..d055eded9e 100644
--- a/src/Microsoft.AspNet.Razor/Text/SeekableTextReader.cs
+++ b/src/Microsoft.AspNet.Razor/Text/SeekableTextReader.cs
@@ -1,8 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using System.IO;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.Text
{
@@ -19,14 +19,22 @@ namespace Microsoft.AspNet.Razor.Text
UpdateState();
}
- public SeekableTextReader([NotNull] TextReader source)
+ public SeekableTextReader(TextReader source)
: this(source.ReadToEnd())
{
+ if (source == null)
+ {
+ throw new ArgumentNullException(nameof(source));
+ }
}
- public SeekableTextReader([NotNull] ITextBuffer buffer)
+ public SeekableTextReader(ITextBuffer buffer)
: this(buffer.ReadToEnd())
{
+ if (buffer == null)
+ {
+ throw new ArgumentNullException(nameof(buffer));
+ }
}
public SourceLocation Location
diff --git a/src/Microsoft.AspNet.Razor/Text/TextBufferReader.cs b/src/Microsoft.AspNet.Razor/Text/TextBufferReader.cs
index adb961159b..3aa56ffbb4 100644
--- a/src/Microsoft.AspNet.Razor/Text/TextBufferReader.cs
+++ b/src/Microsoft.AspNet.Razor/Text/TextBufferReader.cs
@@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNet.Razor.Utils;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.Text
{
@@ -13,8 +12,13 @@ namespace Microsoft.AspNet.Razor.Text
private Stack _bookmarks = new Stack();
private SourceLocationTracker _tracker = new SourceLocationTracker();
- public TextBufferReader([NotNull] ITextBuffer buffer)
+ public TextBufferReader(ITextBuffer buffer)
{
+ if (buffer == null)
+ {
+ throw new ArgumentNullException(nameof(buffer));
+ }
+
InnerBuffer = buffer;
}
diff --git a/src/Microsoft.AspNet.Razor/Text/TextChange.cs b/src/Microsoft.AspNet.Razor/Text/TextChange.cs
index 59444192e5..39229a175b 100644
--- a/src/Microsoft.AspNet.Razor/Text/TextChange.cs
+++ b/src/Microsoft.AspNet.Razor/Text/TextChange.cs
@@ -26,12 +26,22 @@ namespace Microsoft.AspNet.Razor.Text
public TextChange(
int oldPosition,
int oldLength,
- [NotNull] ITextBuffer oldBuffer,
+ ITextBuffer oldBuffer,
int newPosition,
int newLength,
- [NotNull] ITextBuffer newBuffer)
+ ITextBuffer newBuffer)
: this()
{
+ if (oldBuffer == null)
+ {
+ throw new ArgumentNullException(nameof(oldBuffer));
+ }
+
+ if (newBuffer == null)
+ {
+ throw new ArgumentNullException(nameof(newBuffer));
+ }
+
if (oldPosition < 0)
{
throw new ArgumentOutOfRangeException(nameof(oldPosition), CommonResources.FormatArgument_Must_Be_GreaterThanOrEqualTo(0));
diff --git a/src/Microsoft.AspNet.Razor/Tokenizer/CSharpTokenizer.cs b/src/Microsoft.AspNet.Razor/Tokenizer/CSharpTokenizer.cs
index db67d6113d..bfc191b5de 100644
--- a/src/Microsoft.AspNet.Razor/Tokenizer/CSharpTokenizer.cs
+++ b/src/Microsoft.AspNet.Razor/Tokenizer/CSharpTokenizer.cs
@@ -7,7 +7,6 @@ using System.Diagnostics;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Text;
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.Tokenizer
{
@@ -15,9 +14,14 @@ namespace Microsoft.AspNet.Razor.Tokenizer
{
private Dictionary> _operatorHandlers;
- public CSharpTokenizer([NotNull] ITextDocument source)
+ public CSharpTokenizer(ITextDocument source)
: base(source)
{
+ if (source == null)
+ {
+ throw new ArgumentNullException(nameof(source));
+ }
+
CurrentState = Data;
_operatorHandlers = new Dictionary>()
diff --git a/src/Microsoft.AspNet.Razor/Tokenizer/HtmlTokenizer.cs b/src/Microsoft.AspNet.Razor/Tokenizer/HtmlTokenizer.cs
index c43ca4d773..79d865aed8 100644
--- a/src/Microsoft.AspNet.Razor/Tokenizer/HtmlTokenizer.cs
+++ b/src/Microsoft.AspNet.Razor/Tokenizer/HtmlTokenizer.cs
@@ -1,12 +1,12 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Text;
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.Tokenizer
{
@@ -15,9 +15,14 @@ namespace Microsoft.AspNet.Razor.Tokenizer
{
private const char TransitionChar = '@';
- public HtmlTokenizer([NotNull] ITextDocument source)
+ public HtmlTokenizer(ITextDocument source)
: base(source)
{
+ if (source == null)
+ {
+ throw new ArgumentNullException(nameof(source));
+ }
+
CurrentState = Data;
}
@@ -158,7 +163,7 @@ namespace Microsoft.AspNet.Razor.Tokenizer
Debug.Fail("Unexpected symbol!");
#else
- Debug.Assert(false, "Unexpected symbol");
+ Debug.Assert(false, "Unexpected symbol");
#endif
return EndSymbol(HtmlSymbolType.Unknown);
}
diff --git a/src/Microsoft.AspNet.Razor/Tokenizer/Symbols/CSharpSymbol.cs b/src/Microsoft.AspNet.Razor/Tokenizer/Symbols/CSharpSymbol.cs
index 5f114cd310..4cc9acd2c6 100644
--- a/src/Microsoft.AspNet.Razor/Tokenizer/Symbols/CSharpSymbol.cs
+++ b/src/Microsoft.AspNet.Razor/Tokenizer/Symbols/CSharpSymbol.cs
@@ -1,43 +1,59 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using System.Collections.Generic;
using System.Linq;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.Tokenizer.Symbols
{
public class CSharpSymbol : SymbolBase
{
// Helper constructor
- public CSharpSymbol(int offset, int line, int column, [NotNull] string content, CSharpSymbolType type)
+ public CSharpSymbol(int offset, int line, int column, string content, CSharpSymbolType type)
: this(new SourceLocation(offset, line, column), content, type, Enumerable.Empty())
{
+ if (content == null)
+ {
+ throw new ArgumentNullException(nameof(content));
+ }
}
- public CSharpSymbol(SourceLocation start, [NotNull] string content, CSharpSymbolType type)
+ public CSharpSymbol(SourceLocation start, string content, CSharpSymbolType type)
: this(start, content, type, Enumerable.Empty())
{
+ if (content == null)
+ {
+ throw new ArgumentNullException(nameof(content));
+ }
}
public CSharpSymbol(
int offset,
int line,
int column,
- [NotNull] string content,
+ string content,
CSharpSymbolType type,
IEnumerable errors)
: base(new SourceLocation(offset, line, column), content, type, errors)
{
+ if (content == null)
+ {
+ throw new ArgumentNullException(nameof(content));
+ }
}
public CSharpSymbol(
SourceLocation start,
- [NotNull] string content,
+ string content,
CSharpSymbolType type,
IEnumerable errors)
: base(start, content, type, errors)
{
+ if (content == null)
+ {
+ throw new ArgumentNullException(nameof(content));
+ }
}
public bool? EscapedIdentifier { get; set; }
diff --git a/src/Microsoft.AspNet.Razor/Tokenizer/Symbols/HtmlSymbol.cs b/src/Microsoft.AspNet.Razor/Tokenizer/Symbols/HtmlSymbol.cs
index 639974e40f..e7b4c7e881 100644
--- a/src/Microsoft.AspNet.Razor/Tokenizer/Symbols/HtmlSymbol.cs
+++ b/src/Microsoft.AspNet.Razor/Tokenizer/Symbols/HtmlSymbol.cs
@@ -1,43 +1,59 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using System.Collections.Generic;
using System.Linq;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.Tokenizer.Symbols
{
public class HtmlSymbol : SymbolBase
{
// Helper constructor
- public HtmlSymbol(int offset, int line, int column, [NotNull] string content, HtmlSymbolType type)
+ public HtmlSymbol(int offset, int line, int column, string content, HtmlSymbolType type)
: this(new SourceLocation(offset, line, column), content, type, Enumerable.Empty())
{
+ if (content == null)
+ {
+ throw new ArgumentNullException(nameof(content));
+ }
}
- public HtmlSymbol(SourceLocation start, [NotNull] string content, HtmlSymbolType type)
+ public HtmlSymbol(SourceLocation start, string content, HtmlSymbolType type)
: base(start, content, type, Enumerable.Empty())
{
+ if (content == null)
+ {
+ throw new ArgumentNullException(nameof(content));
+ }
}
public HtmlSymbol(
int offset,
int line,
int column,
- [NotNull] string content,
+ string content,
HtmlSymbolType type,
IEnumerable errors)
: base(new SourceLocation(offset, line, column), content, type, errors)
{
+ if (content == null)
+ {
+ throw new ArgumentNullException(nameof(content));
+ }
}
public HtmlSymbol(
SourceLocation start,
- [NotNull] string content,
+ string content,
HtmlSymbolType type,
IEnumerable errors)
: base(start, content, type, errors)
{
+ if (content == null)
+ {
+ throw new ArgumentNullException(nameof(content));
+ }
}
}
}
diff --git a/src/Microsoft.AspNet.Razor/Tokenizer/Symbols/SymbolBase.cs b/src/Microsoft.AspNet.Razor/Tokenizer/Symbols/SymbolBase.cs
index 6d24a81f2a..8490804d52 100644
--- a/src/Microsoft.AspNet.Razor/Tokenizer/Symbols/SymbolBase.cs
+++ b/src/Microsoft.AspNet.Razor/Tokenizer/Symbols/SymbolBase.cs
@@ -10,14 +10,19 @@ using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.Tokenizer.Symbols
{
public abstract class SymbolBase : ISymbol
- where TType: struct
+ where TType : struct
{
protected SymbolBase(
SourceLocation start,
- [NotNull] string content,
+ string content,
TType type,
IEnumerable errors)
{
+ if (content == null)
+ {
+ throw new ArgumentNullException(nameof(content));
+ }
+
Start = start;
Content = content;
Type = type;
diff --git a/src/Microsoft.AspNet.Razor/Tokenizer/Tokenizer.cs b/src/Microsoft.AspNet.Razor/Tokenizer/Tokenizer.cs
index ca6ae0d43f..07f74c2587 100644
--- a/src/Microsoft.AspNet.Razor/Tokenizer/Tokenizer.cs
+++ b/src/Microsoft.AspNet.Razor/Tokenizer/Tokenizer.cs
@@ -13,7 +13,6 @@ using System.Text;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Text;
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.Tokenizer
{
@@ -22,8 +21,13 @@ namespace Microsoft.AspNet.Razor.Tokenizer
where TSymbol : SymbolBase
{
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "TextDocumentReader does not require disposal")]
- protected Tokenizer([NotNull] ITextDocument source)
+ protected Tokenizer(ITextDocument source)
{
+ if (source == null)
+ {
+ throw new ArgumentNullException(nameof(source));
+ }
+
Source = new TextDocumentReader(source);
Buffer = new StringBuilder();
CurrentErrors = new List();
diff --git a/src/Microsoft.AspNet.Razor/Utils/DisposableAction.cs b/src/Microsoft.AspNet.Razor/Utils/DisposableAction.cs
index 3d01811ebb..8ff2f09179 100644
--- a/src/Microsoft.AspNet.Razor/Utils/DisposableAction.cs
+++ b/src/Microsoft.AspNet.Razor/Utils/DisposableAction.cs
@@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.Utils
{
@@ -11,8 +10,13 @@ namespace Microsoft.AspNet.Razor.Utils
private Action _action;
private bool _invoked;
- public DisposableAction([NotNull] Action action)
+ public DisposableAction(Action action)
{
+ if (action == null)
+ {
+ throw new ArgumentNullException(nameof(action));
+ }
+
_action = action;
}
diff --git a/src/Microsoft.AspNet.Razor/project.json b/src/Microsoft.AspNet.Razor/project.json
index 6f92c23571..cd0a52b3c5 100644
--- a/src/Microsoft.AspNet.Razor/project.json
+++ b/src/Microsoft.AspNet.Razor/project.json
@@ -9,10 +9,6 @@
"Microsoft.Framework.HashCodeCombiner.Sources": {
"type": "build",
"version": "1.0.0-*"
- },
- "Microsoft.Framework.NotNullAttribute.Sources": {
- "type": "build",
- "version": "1.0.0-*"
}
},
"frameworks": {
diff --git a/test/Microsoft.AspNet.Razor.Runtime.Test/TagHelpers/TagHelperDescriptorResolverTest.cs b/test/Microsoft.AspNet.Razor.Runtime.Test/TagHelpers/TagHelperDescriptorResolverTest.cs
index 8973f5a39a..378c8956cd 100644
--- a/test/Microsoft.AspNet.Razor.Runtime.Test/TagHelpers/TagHelperDescriptorResolverTest.cs
+++ b/test/Microsoft.AspNet.Razor.Runtime.Test/TagHelpers/TagHelperDescriptorResolverTest.cs
@@ -1381,7 +1381,6 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
[Theory]
[InlineData("", 1)]
- [InlineData(null, 1)]
[InlineData("*,", 2)]
[InlineData("?,", 2)]
[InlineData(",", 1)]