diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/ChunkHelper.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/ChunkHelper.cs
index dc19136445..5053193f02 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/ChunkHelper.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/ChunkHelper.cs
@@ -5,7 +5,6 @@ using System;
using System.Linq;
using Microsoft.AspNet.Mvc.Razor.Host;
using Microsoft.AspNet.Razor.Chunks;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor.Directives
{
@@ -25,9 +24,14 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
/// The cast to .
/// is not an instance of
/// .
- public static TChunk EnsureChunk([NotNull] Chunk chunk)
+ public static TChunk EnsureChunk(Chunk chunk)
where TChunk : Chunk
{
+ if (chunk == null)
+ {
+ throw new ArgumentNullException(nameof(chunk));
+ }
+
var chunkOfT = chunk as TChunk;
if (chunkOfT == null)
{
@@ -45,8 +49,13 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
/// The to scan for s in.
/// The last in the if found, null otherwise.
///
- public static ModelChunk GetModelChunk([NotNull] ChunkTree chunkTree)
+ public static ModelChunk GetModelChunk(ChunkTree chunkTree)
{
+ if (chunkTree == null)
+ {
+ throw new ArgumentNullException(nameof(chunkTree));
+ }
+
// If there's more than 1 model chunk there will be a Razor error BUT we want intellisense to show up on
// the current model chunk that the user is typing.
return chunkTree
@@ -63,9 +72,19 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
/// The name of the default model.
/// The model type name for the generated page.
public static string GetModelTypeName(
- [NotNull] ChunkTree chunkTree,
- [NotNull] string defaultModelName)
+ ChunkTree chunkTree,
+ string defaultModelName)
{
+ if (chunkTree == null)
+ {
+ throw new ArgumentNullException(nameof(chunkTree));
+ }
+
+ if (defaultModelName == null)
+ {
+ throw new ArgumentNullException(nameof(defaultModelName));
+ }
+
var modelChunk = GetModelChunk(chunkTree);
return modelChunk != null ? modelChunk.ModelType : defaultModelName;
}
@@ -77,9 +96,20 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
/// The string to replace the token in.
/// The model name to replace with.
/// A string with the token replaced.
- public static string ReplaceTModel([NotNull] string value,
- [NotNull] string modelName)
+ public static string ReplaceTModel(
+ string value,
+ string modelName)
{
+ if (value == null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
+
+ if (modelName == null)
+ {
+ throw new ArgumentNullException(nameof(modelName));
+ }
+
return value.Replace(TModelToken, modelName);
}
}
diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/ChunkInheritanceUtility.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/ChunkInheritanceUtility.cs
index 53f3aba753..3ec945d00e 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/ChunkInheritanceUtility.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/ChunkInheritanceUtility.cs
@@ -9,7 +9,6 @@ using Microsoft.AspNet.FileProviders;
using Microsoft.AspNet.Razor;
using Microsoft.AspNet.Razor.Chunks;
using Microsoft.AspNet.Razor.Parser;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor.Directives
{
@@ -30,10 +29,25 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
///
/// Sequence of s inherited by default.
public ChunkInheritanceUtility(
- [NotNull] MvcRazorHost razorHost,
- [NotNull] IChunkTreeCache chunkTreeCache,
- [NotNull] IReadOnlyList defaultInheritedChunks)
+ MvcRazorHost razorHost,
+ IChunkTreeCache chunkTreeCache,
+ IReadOnlyList defaultInheritedChunks)
{
+ if (razorHost == null)
+ {
+ throw new ArgumentNullException(nameof(razorHost));
+ }
+
+ if (chunkTreeCache == null)
+ {
+ throw new ArgumentNullException(nameof(chunkTreeCache));
+ }
+
+ if (defaultInheritedChunks == null)
+ {
+ throw new ArgumentNullException(nameof(defaultInheritedChunks));
+ }
+
_razorHost = razorHost;
_defaultInheritedChunks = defaultInheritedChunks;
_chunkTreeCache = chunkTreeCache;
@@ -49,8 +63,13 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
/// The path of the page to locate inherited chunks for.
/// A of parsed _ViewImports
/// s and their file paths.
- public virtual IReadOnlyList GetInheritedChunkTreeResults([NotNull] string pagePath)
+ public virtual IReadOnlyList GetInheritedChunkTreeResults(string pagePath)
{
+ if (pagePath == null)
+ {
+ throw new ArgumentNullException(nameof(pagePath));
+ }
+
var inheritedChunkTreeResults = new List();
var templateEngine = new RazorTemplateEngine(_razorHost);
foreach (var viewImportsPath in ViewHierarchyUtility.GetViewImportsLocations(pagePath))
@@ -85,10 +104,20 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
/// files.
/// The list of chunks to merge.
public void MergeInheritedChunkTrees(
- [NotNull] ChunkTree chunkTree,
- [NotNull] IReadOnlyList inheritedChunkTrees,
+ ChunkTree chunkTree,
+ IReadOnlyList inheritedChunkTrees,
string defaultModel)
{
+ if (chunkTree == null)
+ {
+ throw new ArgumentNullException(nameof(chunkTree));
+ }
+
+ if (inheritedChunkTrees == null)
+ {
+ throw new ArgumentNullException(nameof(inheritedChunkTrees));
+ }
+
var mergerMappings = GetMergerMappings(chunkTree, defaultModel);
IChunkMerger merger;
diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/ChunkTreeResult.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/ChunkTreeResult.cs
index f139d06947..1f96a130c5 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/ChunkTreeResult.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/ChunkTreeResult.cs
@@ -1,8 +1,8 @@
-// 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;
using Microsoft.AspNet.Razor.Chunks;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor.Directives
{
@@ -17,8 +17,18 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
/// The generated from the file at the
/// given .
/// The path to the file that generated the given .
- public ChunkTreeResult([NotNull] ChunkTree chunkTree, [NotNull] string filePath)
+ public ChunkTreeResult(ChunkTree chunkTree, string filePath)
{
+ if (chunkTree == null)
+ {
+ throw new ArgumentNullException(nameof(chunkTree));
+ }
+
+ if (filePath == null)
+ {
+ throw new ArgumentNullException(nameof(filePath));
+ }
+
ChunkTree = chunkTree;
FilePath = filePath;
}
diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/DefaultChunkTreeCache.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/DefaultChunkTreeCache.cs
index 681031c01b..f6ccecc94a 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/DefaultChunkTreeCache.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/DefaultChunkTreeCache.cs
@@ -5,7 +5,6 @@ using System;
using Microsoft.AspNet.FileProviders;
using Microsoft.AspNet.Razor.Chunks;
using Microsoft.Framework.Caching.Memory;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor.Directives
{
@@ -41,9 +40,19 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
///
public ChunkTree GetOrAdd(
- [NotNull] string pagePath,
- [NotNull] Func getChunkTree)
+ string pagePath,
+ Func getChunkTree)
{
+ if (pagePath == null)
+ {
+ throw new ArgumentNullException(nameof(pagePath));
+ }
+
+ if (getChunkTree == null)
+ {
+ throw new ArgumentNullException(nameof(getChunkTree));
+ }
+
ChunkTree chunkTree;
if (!_chunkTreeCache.TryGetValue(pagePath, out chunkTree))
{
diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/InjectChunkMerger.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/InjectChunkMerger.cs
index bb7ea85ee5..60e305657e 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/InjectChunkMerger.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/InjectChunkMerger.cs
@@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNet.Razor.Chunks;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor.Directives
{
@@ -20,22 +19,42 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
/// Initializes a new instance of .
///
/// The model type to be used to replace <TModel> tokens.
- public InjectChunkMerger([NotNull] string modelType)
+ public InjectChunkMerger(string modelType)
{
+ if (modelType == null)
+ {
+ throw new ArgumentNullException(nameof(modelType));
+ }
+
_modelType = "<" + modelType + ">";
}
///
- public void VisitChunk([NotNull] Chunk chunk)
+ public void VisitChunk(Chunk chunk)
{
+ if (chunk == null)
+ {
+ throw new ArgumentNullException(nameof(chunk));
+ }
+
var injectChunk = ChunkHelper.EnsureChunk(chunk);
injectChunk.TypeName = ChunkHelper.ReplaceTModel(injectChunk.TypeName, _modelType);
_addedMemberNames.Add(injectChunk.MemberName);
}
///
- public void Merge([NotNull] ChunkTree chunkTree, [NotNull] Chunk chunk)
+ public void Merge(ChunkTree chunkTree, Chunk chunk)
{
+ if (chunkTree == null)
+ {
+ throw new ArgumentNullException(nameof(chunkTree));
+ }
+
+ if (chunk == null)
+ {
+ throw new ArgumentNullException(nameof(chunk));
+ }
+
var injectChunk = ChunkHelper.EnsureChunk(chunk);
if (!_addedMemberNames.Contains(injectChunk.MemberName))
{
diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/SetBaseTypeChunkMerger.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/SetBaseTypeChunkMerger.cs
index c226f3b6c0..6235c6466d 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/SetBaseTypeChunkMerger.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/SetBaseTypeChunkMerger.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.Mvc.Razor.Directives
{
@@ -24,16 +24,31 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
}
///
- public void VisitChunk([NotNull] Chunk chunk)
+ public void VisitChunk(Chunk chunk)
{
+ if (chunk == null)
+ {
+ throw new ArgumentNullException(nameof(chunk));
+ }
+
var setBaseTypeChunk = ChunkHelper.EnsureChunk(chunk);
setBaseTypeChunk.TypeName = ChunkHelper.ReplaceTModel(setBaseTypeChunk.TypeName, _modelType);
_isBaseTypeSet = true;
}
///
- public void Merge([NotNull] ChunkTree chunkTree, [NotNull] Chunk chunk)
+ public void Merge(ChunkTree chunkTree, Chunk chunk)
{
+ if (chunkTree == null)
+ {
+ throw new ArgumentNullException(nameof(chunkTree));
+ }
+
+ if (chunk == null)
+ {
+ throw new ArgumentNullException(nameof(chunk));
+ }
+
if (!_isBaseTypeSet)
{
var baseTypeChunk = ChunkHelper.EnsureChunk(chunk);
diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/UsingChunkMerger.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/UsingChunkMerger.cs
index 7c570c8007..a8b8cc1bd0 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/UsingChunkMerger.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/Directives/UsingChunkMerger.cs
@@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNet.Razor.Chunks;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor.Directives
{
@@ -16,15 +15,30 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
private readonly HashSet _currentUsings = new HashSet(StringComparer.Ordinal);
///
- public void VisitChunk([NotNull] Chunk chunk)
+ public void VisitChunk(Chunk chunk)
{
+ if (chunk == null)
+ {
+ throw new ArgumentNullException(nameof(chunk));
+ }
+
var namespaceChunk = ChunkHelper.EnsureChunk(chunk);
_currentUsings.Add(namespaceChunk.Namespace);
}
///
- public void Merge([NotNull] ChunkTree chunkTree, [NotNull] Chunk chunk)
+ public void Merge(ChunkTree chunkTree, Chunk chunk)
{
+ if (chunkTree == null)
+ {
+ throw new ArgumentNullException(nameof(chunkTree));
+ }
+
+ if (chunk == null)
+ {
+ throw new ArgumentNullException(nameof(chunk));
+ }
+
var namespaceChunk = ChunkHelper.EnsureChunk(chunk);
if (!_currentUsings.Contains(namespaceChunk.Namespace))
diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/InjectChunkVisitor.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/InjectChunkVisitor.cs
index 16e9f22c25..501c81b55f 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/InjectChunkVisitor.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/InjectChunkVisitor.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 Microsoft.AspNet.Razor.CodeGenerators;
using Microsoft.AspNet.Razor.CodeGenerators.Visitors;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor
{
@@ -12,18 +12,38 @@ namespace Microsoft.AspNet.Mvc.Razor
{
private readonly string _injectAttribute;
- public InjectChunkVisitor([NotNull] CSharpCodeWriter writer,
- [NotNull] CodeGeneratorContext context,
- [NotNull] string injectAttributeName)
+ public InjectChunkVisitor(CSharpCodeWriter writer,
+ CodeGeneratorContext context,
+ string injectAttributeName)
: base(writer, context)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (injectAttributeName == null)
+ {
+ throw new ArgumentNullException(nameof(injectAttributeName));
+ }
+
_injectAttribute = "[" + injectAttributeName + "]";
}
public IList InjectChunks { get; } = new List();
- protected override void Visit([NotNull] InjectChunk chunk)
+ protected override void Visit(InjectChunk chunk)
{
+ if (chunk == null)
+ {
+ throw new ArgumentNullException(nameof(chunk));
+ }
+
Writer.WriteLine(_injectAttribute);
// Some of the chunks that we visit are either InjectDescriptors that are added by default or
diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/Internal/DesignTimeRazorPathNormalizer.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/Internal/DesignTimeRazorPathNormalizer.cs
index 0737df7a89..8841859d59 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/Internal/DesignTimeRazorPathNormalizer.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/Internal/DesignTimeRazorPathNormalizer.cs
@@ -3,7 +3,6 @@
using System;
using System.IO;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor.Internal
{
@@ -11,13 +10,23 @@ namespace Microsoft.AspNet.Mvc.Razor.Internal
{
private readonly string _applicationRoot;
- public DesignTimeRazorPathNormalizer([NotNull] string applicationRoot)
+ public DesignTimeRazorPathNormalizer(string applicationRoot)
{
+ if (applicationRoot == null)
+ {
+ throw new ArgumentNullException(nameof(applicationRoot));
+ }
+
_applicationRoot = applicationRoot;
}
- public override string NormalizePath([NotNull] string path)
+ public override string NormalizePath(string path)
{
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
// Need to convert path to application relative (rooted paths are passed in during design time).
if (Path.IsPathRooted(path) && path.StartsWith(_applicationRoot, StringComparison.Ordinal))
{
diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/Internal/RazorPathNormalizer.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/Internal/RazorPathNormalizer.cs
index 8b614e2be9..21cfc2b3cf 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/Internal/RazorPathNormalizer.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/Internal/RazorPathNormalizer.cs
@@ -1,14 +1,19 @@
// 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.Mvc.Razor.Internal
{
public class RazorPathNormalizer
{
- public virtual string NormalizePath([NotNull] string path)
+ public virtual string NormalizePath(string path)
{
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
return path;
}
}
diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/ModelChunkVisitor.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/ModelChunkVisitor.cs
index 81997ffe01..ce9f5d333c 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/ModelChunkVisitor.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/ModelChunkVisitor.cs
@@ -1,19 +1,28 @@
// 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.CodeGenerators;
using Microsoft.AspNet.Razor.CodeGenerators.Visitors;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor
{
public class ModelChunkVisitor : MvcCSharpCodeVisitor
{
public ModelChunkVisitor(
- [NotNull] CSharpCodeWriter writer,
- [NotNull] CodeGeneratorContext context)
+ CSharpCodeWriter 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(ModelChunk chunk)
diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpChunkVisitor.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpChunkVisitor.cs
index 036afe02f8..d1401ac016 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpChunkVisitor.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpChunkVisitor.cs
@@ -1,19 +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 Microsoft.AspNet.Razor.Chunks;
using Microsoft.AspNet.Razor.CodeGenerators;
using Microsoft.AspNet.Razor.CodeGenerators.Visitors;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor
{
public abstract class MvcCSharpChunkVisitor : CodeVisitor
{
- public MvcCSharpChunkVisitor([NotNull] CSharpCodeWriter writer,
- [NotNull] CodeGeneratorContext context)
+ public MvcCSharpChunkVisitor(CSharpCodeWriter writer,
+ CodeGeneratorContext context)
: base(writer, context)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
}
public override void Accept(Chunk chunk)
diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpCodeGenerator.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpCodeGenerator.cs
index a37b01732a..b5a5091ff8 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpCodeGenerator.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpCodeGenerator.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 Microsoft.AspNet.Mvc.Razor.Directives;
using Microsoft.AspNet.Razor.CodeGenerators;
using Microsoft.AspNet.Razor.CodeGenerators.Visitors;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor
{
@@ -16,12 +16,32 @@ namespace Microsoft.AspNet.Mvc.Razor
private readonly string _injectAttribute;
public MvcCSharpCodeGenerator(
- [NotNull] CodeGeneratorContext context,
- [NotNull] string defaultModel,
- [NotNull] string injectAttribute,
- [NotNull] GeneratedTagHelperAttributeContext tagHelperAttributeContext)
+ CodeGeneratorContext context,
+ string defaultModel,
+ string injectAttribute,
+ GeneratedTagHelperAttributeContext tagHelperAttributeContext)
: base(context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (defaultModel == null)
+ {
+ throw new ArgumentNullException(nameof(defaultModel));
+ }
+
+ if (injectAttribute == null)
+ {
+ throw new ArgumentNullException(nameof(injectAttribute));
+ }
+
+ if (tagHelperAttributeContext == null)
+ {
+ throw new ArgumentNullException(nameof(tagHelperAttributeContext));
+ }
+
_tagHelperAttributeContext = tagHelperAttributeContext;
_defaultModel = defaultModel;
_injectAttribute = injectAttribute;
@@ -30,9 +50,19 @@ namespace Microsoft.AspNet.Mvc.Razor
private string Model { get; set; }
protected override CSharpCodeVisitor CreateCSharpCodeVisitor(
- [NotNull] CSharpCodeWriter writer,
- [NotNull] CodeGeneratorContext context)
+ CSharpCodeWriter writer,
+ CodeGeneratorContext context)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var csharpCodeVisitor = base.CreateCSharpCodeVisitor(writer, context);
csharpCodeVisitor.TagHelperRenderer.AttributeValueCodeRenderer =
@@ -67,8 +97,13 @@ namespace Microsoft.AspNet.Mvc.Razor
}
}
- protected override void BuildConstructor([NotNull] CSharpCodeWriter writer)
+ protected override void BuildConstructor(CSharpCodeWriter writer)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
base.BuildConstructor(writer);
writer.WriteLineHiddenDirective();
diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpCodeVistor.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpCodeVistor.cs
index 6a7c42b765..fe6e4bda4f 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpCodeVistor.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcCSharpCodeVistor.cs
@@ -1,23 +1,33 @@
// 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.CodeGenerators;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor
{
public abstract class MvcCSharpCodeVisitor : MvcCSharpChunkVisitor
{
public MvcCSharpCodeVisitor(
- [NotNull] CSharpCodeWriter writer,
- [NotNull] CodeGeneratorContext context)
+ CSharpCodeWriter 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(InjectChunk chunk)
{
}
+
protected override void Visit(ModelChunk chunk)
{
}
diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorHost.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorHost.cs
index f60d151046..fd8b80bb00 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorHost.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorHost.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.Collections.Generic;
using System.IO;
using System.Linq;
@@ -15,7 +16,6 @@ using Microsoft.AspNet.Razor.CodeGenerators;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
using Microsoft.AspNet.Razor.TagHelpers;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor
{
@@ -151,9 +151,13 @@ namespace Microsoft.AspNet.Mvc.Razor
return _tagHelperDescriptorResolver;
}
- [param: NotNull]
set
{
+ if (value == null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
+
_tagHelperDescriptorResolver = value;
}
}
@@ -231,8 +235,13 @@ namespace Microsoft.AspNet.Mvc.Razor
///
/// The path to a Razor file to locate _ViewImports.cshtml for.
/// Inherited s.
- public IReadOnlyList GetInheritedChunkTreeResults([NotNull] string sourceFileName)
+ public IReadOnlyList GetInheritedChunkTreeResults(string sourceFileName)
{
+ if (sourceFileName == null)
+ {
+ throw new ArgumentNullException(nameof(sourceFileName));
+ }
+
// Need the normalized path to resolve inherited chunks only. Full paths are needed for generated Razor
// files checksum and line pragmas to enable DesignTime debugging.
var normalizedPath = _pathNormalizer.NormalizePath(sourceFileName);
@@ -250,24 +259,44 @@ namespace Microsoft.AspNet.Mvc.Razor
}
///
- public override RazorParser DecorateRazorParser([NotNull] RazorParser razorParser, string sourceFileName)
+ public override RazorParser DecorateRazorParser(RazorParser razorParser, string sourceFileName)
{
+ if (razorParser == null)
+ {
+ throw new ArgumentNullException(nameof(razorParser));
+ }
+
var inheritedChunkTrees = GetInheritedChunkTrees(sourceFileName);
return new MvcRazorParser(razorParser, inheritedChunkTrees, DefaultInheritedChunks, ModelExpressionType);
}
///
- public override ParserBase DecorateCodeParser([NotNull] ParserBase incomingCodeParser)
+ public override ParserBase DecorateCodeParser(ParserBase incomingCodeParser)
{
+ if (incomingCodeParser == null)
+ {
+ throw new ArgumentNullException(nameof(incomingCodeParser));
+ }
+
return new MvcRazorCodeParser(_baseType);
}
///
public override CodeGenerator DecorateCodeGenerator(
- [NotNull] CodeGenerator incomingGenerator,
- [NotNull] CodeGeneratorContext context)
+ CodeGenerator incomingGenerator,
+ CodeGeneratorContext context)
{
+ if (incomingGenerator == null)
+ {
+ throw new ArgumentNullException(nameof(incomingGenerator));
+ }
+
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var inheritedChunkTrees = GetInheritedChunkTrees(context.SourceFile);
ChunkInheritanceUtility.MergeInheritedChunkTrees(
diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorParser.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorParser.cs
index 78f5e408ab..4e39469c35 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorParser.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorParser.cs
@@ -11,7 +11,6 @@ using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Parser.TagHelpers;
using Microsoft.AspNet.Razor.TagHelpers;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor
{
@@ -33,12 +32,32 @@ namespace Microsoft.AspNet.Mvc.Razor
/// The inherited by
/// default by all Razor pages in the application.
public MvcRazorParser(
- [NotNull] RazorParser parser,
- [NotNull] IReadOnlyList inheritedChunkTrees,
- [NotNull] IReadOnlyList defaultInheritedChunks,
- [NotNull] string modelExpressionTypeName)
+ RazorParser parser,
+ IReadOnlyList inheritedChunkTrees,
+ IReadOnlyList defaultInheritedChunks,
+ string modelExpressionTypeName)
: base(parser)
{
+ if (parser == null)
+ {
+ throw new ArgumentNullException(nameof(parser));
+ }
+
+ if (inheritedChunkTrees == null)
+ {
+ throw new ArgumentNullException(nameof(inheritedChunkTrees));
+ }
+
+ if (defaultInheritedChunks == null)
+ {
+ throw new ArgumentNullException(nameof(defaultInheritedChunks));
+ }
+
+ if (modelExpressionTypeName == null)
+ {
+ throw new ArgumentNullException(nameof(modelExpressionTypeName));
+ }
+
// Construct tag helper descriptors from @addTagHelper, @removeTagHelper and @tagHelperPrefix chunks
_viewImportsDirectiveDescriptors = GetTagHelperDirectiveDescriptors(
inheritedChunkTrees,
@@ -49,9 +68,19 @@ namespace Microsoft.AspNet.Mvc.Razor
///
protected override IEnumerable GetTagHelperDescriptors(
- [NotNull] Block documentRoot,
- [NotNull] ErrorSink errorSink)
+ Block documentRoot,
+ ErrorSink errorSink)
{
+ if (documentRoot == null)
+ {
+ throw new ArgumentNullException(nameof(documentRoot));
+ }
+
+ if (errorSink == null)
+ {
+ throw new ArgumentNullException(nameof(errorSink));
+ }
+
var visitor = new ViewImportsTagHelperDirectiveSpanVisitor(
TagHelperDescriptorResolver,
_viewImportsDirectiveDescriptors,
diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcTagHelperAttributeValueCodeRenderer.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcTagHelperAttributeValueCodeRenderer.cs
index 6f11f57c07..06d0dcb1f2 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcTagHelperAttributeValueCodeRenderer.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcTagHelperAttributeValueCodeRenderer.cs
@@ -4,7 +4,6 @@
using System;
using Microsoft.AspNet.Razor.CodeGenerators;
using Microsoft.AspNet.Razor.TagHelpers;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor
{
@@ -19,8 +18,13 @@ namespace Microsoft.AspNet.Mvc.Razor
/// Instantiates a new instance of .
///
/// Contains code generation information for rendering attribute values.
- public MvcTagHelperAttributeValueCodeRenderer([NotNull] GeneratedTagHelperAttributeContext context)
+ public MvcTagHelperAttributeValueCodeRenderer(GeneratedTagHelperAttributeContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
_context = context;
}
@@ -30,12 +34,32 @@ namespace Microsoft.AspNet.Mvc.Razor
/// created by calling into .
///
public override void RenderAttributeValue(
- [NotNull] TagHelperAttributeDescriptor attributeDescriptor,
- [NotNull] CSharpCodeWriter writer,
- [NotNull] CodeGeneratorContext codeGeneratorContext,
- [NotNull] Action renderAttributeValue,
+ TagHelperAttributeDescriptor attributeDescriptor,
+ CSharpCodeWriter writer,
+ CodeGeneratorContext codeGeneratorContext,
+ Action renderAttributeValue,
bool complexValue)
{
+ if (attributeDescriptor == null)
+ {
+ throw new ArgumentNullException(nameof(attributeDescriptor));
+ }
+
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
+ if (codeGeneratorContext == null)
+ {
+ throw new ArgumentNullException(nameof(codeGeneratorContext));
+ }
+
+ if (renderAttributeValue == null)
+ {
+ throw new ArgumentNullException(nameof(renderAttributeValue));
+ }
+
if (attributeDescriptor.TypeName.Equals(_context.ModelExpressionTypeName, StringComparison.Ordinal))
{
writer
diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/project.json b/src/Microsoft.AspNet.Mvc.Razor.Host/project.json
index a75eb91a53..137b61e567 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/project.json
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/project.json
@@ -12,8 +12,7 @@
"Microsoft.AspNet.FileProviders.Physical": "1.0.0-*",
"Microsoft.AspNet.Razor.Runtime": "4.0.0-*",
"Microsoft.Framework.Caching.Memory": "1.0.0-*",
- "Microsoft.Framework.PropertyHelper.Sources": { "version": "1.0.0-*", "type": "build" },
- "Microsoft.Framework.NotNullAttribute.Sources": { "version": "1.0.0-*", "type": "build" }
+ "Microsoft.Framework.PropertyHelper.Sources": { "version": "1.0.0-*", "type": "build" }
},
"frameworks": {
"net45": { },
diff --git a/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationFailedException.cs b/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationFailedException.cs
index a730c2027c..1eda4be94f 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationFailedException.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationFailedException.cs
@@ -5,7 +5,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Dnx.Compilation;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor.Compilation
{
@@ -20,9 +19,14 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
/// s containing
/// details of the compilation failure.
public CompilationFailedException(
- [NotNull] IEnumerable compilationFailures)
+ IEnumerable compilationFailures)
: base(FormatMessage(compilationFailures))
{
+ if (compilationFailures == null)
+ {
+ throw new ArgumentNullException(nameof(compilationFailures));
+ }
+
CompilationFailures = compilationFailures;
}
diff --git a/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationOptionsProviderExtension.cs b/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationOptionsProviderExtension.cs
index e91e12c2cf..4ac5d08bba 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationOptionsProviderExtension.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationOptionsProviderExtension.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.Dnx.Compilation;
using Microsoft.Dnx.Compilation.CSharp;
using Microsoft.Dnx.Runtime;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor.Compilation
{
@@ -25,9 +25,19 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
///
/// The for the current application.
public static CompilationSettings GetCompilationSettings(
- [NotNull] this ICompilerOptionsProvider compilerOptionsProvider,
- [NotNull] IApplicationEnvironment applicationEnvironment)
+ this ICompilerOptionsProvider compilerOptionsProvider,
+ IApplicationEnvironment applicationEnvironment)
{
+ if (compilerOptionsProvider == null)
+ {
+ throw new ArgumentNullException(nameof(compilerOptionsProvider));
+ }
+
+ if (applicationEnvironment == null)
+ {
+ throw new ArgumentNullException(nameof(applicationEnvironment));
+ }
+
return compilerOptionsProvider.GetCompilerOptions(applicationEnvironment.ApplicationName,
applicationEnvironment.RuntimeFramework,
applicationEnvironment.Configuration)
diff --git a/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationResult.cs b/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationResult.cs
index 5b2fd1326e..da598143c3 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationResult.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationResult.cs
@@ -3,9 +3,6 @@
using System;
using System.Collections.Generic;
-using System.IO;
-using Microsoft.Framework.Internal;
-using Microsoft.Dnx.Runtime;
using Microsoft.Dnx.Compilation;
namespace Microsoft.AspNet.Mvc.Razor.Compilation
@@ -61,8 +58,13 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
/// s produced from parsing or
/// compiling the Razor file.
/// A instance for a failed compilation.
- public static CompilationResult Failed([NotNull] IEnumerable compilationFailures)
+ public static CompilationResult Failed(IEnumerable compilationFailures)
{
+ if (compilationFailures == null)
+ {
+ throw new ArgumentNullException(nameof(compilationFailures));
+ }
+
return new CompilationResult
{
CompilationFailures = compilationFailures
@@ -74,8 +76,13 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
///
/// The compiled type.
/// A instance for a successful compilation.
- public static CompilationResult Successful([NotNull] Type type)
+ public static CompilationResult Successful(Type type)
{
+ if (type == null)
+ {
+ throw new ArgumentNullException(nameof(type));
+ }
+
return new CompilationResult
{
CompiledType = type
diff --git a/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilerCache.cs b/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilerCache.cs
index 240d1ed1c0..09f4d9db93 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilerCache.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilerCache.cs
@@ -8,7 +8,6 @@ using System.Diagnostics;
using System.Text;
using Microsoft.AspNet.FileProviders;
using Microsoft.Framework.Caching.Memory;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor.Compilation
{
@@ -27,8 +26,13 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
/// Initializes a new instance of .
///
/// used to locate Razor views.
- public CompilerCache([NotNull] IFileProvider fileProvider)
+ public CompilerCache(IFileProvider fileProvider)
{
+ if (fileProvider == null)
+ {
+ throw new ArgumentNullException(nameof(fileProvider));
+ }
+
_fileProvider = fileProvider;
_cache = new MemoryCache(new MemoryCacheOptions { CompactOnMemoryPressure = false });
}
@@ -41,10 +45,20 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
/// A mapping of application relative paths of view to the precompiled view
/// s.
public CompilerCache(
- [NotNull] IFileProvider fileProvider,
- [NotNull] IDictionary precompiledViews)
+ IFileProvider fileProvider,
+ IDictionary precompiledViews)
: this(fileProvider)
{
+ if (fileProvider == null)
+ {
+ throw new ArgumentNullException(nameof(fileProvider));
+ }
+
+ if (precompiledViews == null)
+ {
+ throw new ArgumentNullException(nameof(precompiledViews));
+ }
+
foreach (var item in precompiledViews)
{
var cacheEntry = new CompilerCacheResult(CompilationResult.Successful(item.Value));
@@ -54,9 +68,19 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
///
public CompilerCacheResult GetOrAdd(
- [NotNull] string relativePath,
- [NotNull] Func compile)
+ string relativePath,
+ Func compile)
{
+ if (relativePath == null)
+ {
+ throw new ArgumentNullException(nameof(relativePath));
+ }
+
+ if (compile == null)
+ {
+ throw new ArgumentNullException(nameof(compile));
+ }
+
CompilerCacheResult cacheResult;
// Attempt to lookup the cache entry using the passed in path. This will succeed if the path is already
// normalized and a cache entry exists.
diff --git a/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilerCacheResult.cs b/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilerCacheResult.cs
index e32963cd0a..130ab74c15 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilerCacheResult.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilerCacheResult.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.Mvc.Razor.Compilation
{
@@ -21,8 +21,13 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
/// .
///
/// The
- public CompilerCacheResult([NotNull] CompilationResult compilationResult)
+ public CompilerCacheResult(CompilationResult compilationResult)
{
+ if (compilationResult == null)
+ {
+ throw new ArgumentNullException(nameof(compilationResult));
+ }
+
CompilationResult = compilationResult;
}
diff --git a/src/Microsoft.AspNet.Mvc.Razor/Compilation/ICompilerCache.cs b/src/Microsoft.AspNet.Mvc.Razor/Compilation/ICompilerCache.cs
index 24838b8eea..173f5df4c5 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/Compilation/ICompilerCache.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/Compilation/ICompilerCache.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.Mvc.Razor.Compilation
{
@@ -18,7 +17,8 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
/// Application relative path to the file.
/// An delegate that will generate a compilation result.
/// A cached .
- CompilerCacheResult GetOrAdd([NotNull] string relativePath,
- [NotNull] Func compile);
+ CompilerCacheResult GetOrAdd(
+ string relativePath,
+ Func compile);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Mvc.Razor/Compilation/RazorCompilationService.cs b/src/Microsoft.AspNet.Mvc.Razor/Compilation/RazorCompilationService.cs
index 4dcfa256b0..f4430a5bd3 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/Compilation/RazorCompilationService.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/Compilation/RazorCompilationService.cs
@@ -10,7 +10,6 @@ using Microsoft.AspNet.Razor;
using Microsoft.AspNet.Razor.CodeGenerators;
using Microsoft.Dnx.Compilation;
using Microsoft.Dnx.Runtime;
-using Microsoft.Framework.Internal;
using Microsoft.Framework.OptionsModel;
namespace Microsoft.AspNet.Mvc.Razor.Compilation
@@ -43,8 +42,13 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
}
///
- public CompilationResult Compile([NotNull] RelativeFileInfo file)
+ public CompilationResult Compile(RelativeFileInfo file)
{
+ if (file == null)
+ {
+ throw new ArgumentNullException(nameof(file));
+ }
+
GeneratorResults results;
using (var inputStream = file.FileInfo.CreateReadStream())
{
diff --git a/src/Microsoft.AspNet.Mvc.Razor/Compilation/RelativeFileInfo.cs b/src/Microsoft.AspNet.Mvc.Razor/Compilation/RelativeFileInfo.cs
index 1f28ad8e61..2a49daf9ba 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/Compilation/RelativeFileInfo.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/Compilation/RelativeFileInfo.cs
@@ -3,7 +3,6 @@
using System;
using Microsoft.AspNet.FileProviders;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor.Compilation
{
@@ -18,8 +17,13 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
///
/// for the file.
/// Path of the file relative to the application base.
- public RelativeFileInfo([NotNull] IFileInfo fileInfo, string relativePath)
+ public RelativeFileInfo(IFileInfo fileInfo, string relativePath)
{
+ if (fileInfo == null)
+ {
+ throw new ArgumentNullException(nameof(fileInfo));
+ }
+
if (string.IsNullOrEmpty(relativePath))
{
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(relativePath));
diff --git a/src/Microsoft.AspNet.Mvc.Razor/Compilation/RoslynCompilationService.cs b/src/Microsoft.AspNet.Mvc.Razor/Compilation/RoslynCompilationService.cs
index 5d510e621f..0516ae90a8 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/Compilation/RoslynCompilationService.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/Compilation/RoslynCompilationService.cs
@@ -17,7 +17,6 @@ using Microsoft.CodeAnalysis.Emit;
using Microsoft.Dnx.Compilation;
using Microsoft.Dnx.Compilation.CSharp;
using Microsoft.Dnx.Runtime;
-using Microsoft.Framework.Internal;
using Microsoft.Framework.OptionsModel;
namespace Microsoft.AspNet.Mvc.Razor.Compilation
@@ -69,8 +68,18 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
}
///
- public CompilationResult Compile([NotNull] RelativeFileInfo fileInfo, [NotNull] string compilationContent)
+ public CompilationResult Compile(RelativeFileInfo fileInfo, string compilationContent)
{
+ if (fileInfo == null)
+ {
+ throw new ArgumentNullException(nameof(fileInfo));
+ }
+
+ if (compilationContent == null)
+ {
+ throw new ArgumentNullException(nameof(compilationContent));
+ }
+
var assemblyName = Path.GetRandomFileName();
var compilationSettings = _compilerOptionsProvider.GetCompilationSettings(_environment);
var syntaxTree = SyntaxTreeGenerator.Generate(compilationContent,
diff --git a/src/Microsoft.AspNet.Mvc.Razor/Compilation/SyntaxTreeGenerator.cs b/src/Microsoft.AspNet.Mvc.Razor/Compilation/SyntaxTreeGenerator.cs
index 9c87d9a9b9..6859ec86f3 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/Compilation/SyntaxTreeGenerator.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/Compilation/SyntaxTreeGenerator.cs
@@ -1,21 +1,37 @@
// 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.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Text;
using Microsoft.Dnx.Compilation.CSharp;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor.Compilation
{
public static class SyntaxTreeGenerator
{
- public static SyntaxTree Generate([NotNull] string text,
- [NotNull] string path,
- [NotNull] CompilationSettings compilationSettings)
+ public static SyntaxTree Generate(
+ string text,
+ string path,
+ CompilationSettings compilationSettings)
{
+ if (text == null)
+ {
+ throw new ArgumentNullException(nameof(text));
+ }
+
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
+ if (compilationSettings == null)
+ {
+ throw new ArgumentNullException(nameof(compilationSettings));
+ }
+
var sourceText = SourceText.From(text, Encoding.UTF8);
var syntaxTree = CSharpSyntaxTree.ParseText(sourceText,
path: path,
diff --git a/src/Microsoft.AspNet.Mvc.Razor/Compilation/UncachedCompilationResult.cs b/src/Microsoft.AspNet.Mvc.Razor/Compilation/UncachedCompilationResult.cs
index 44bb43790c..0e96345135 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/Compilation/UncachedCompilationResult.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/Compilation/UncachedCompilationResult.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.Mvc.Razor.Compilation
{
@@ -24,9 +23,20 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
/// The generated C# content that was compiled.
/// An instance that indicates a successful
/// compilation.
- public static UncachedCompilationResult Successful([NotNull] Type type,
- [NotNull] string compiledContent)
+ public static UncachedCompilationResult Successful(
+ Type type,
+ string compiledContent)
{
+ if (type == null)
+ {
+ throw new ArgumentNullException(nameof(type));
+ }
+
+ if (compiledContent == null)
+ {
+ throw new ArgumentNullException(nameof(compiledContent));
+ }
+
return new UncachedCompilationResult
{
CompiledType = type,
diff --git a/src/Microsoft.AspNet.Mvc.Razor/DefaultTagHelperActivator.cs b/src/Microsoft.AspNet.Mvc.Razor/DefaultTagHelperActivator.cs
index 0438c85126..efcf495395 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/DefaultTagHelperActivator.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/DefaultTagHelperActivator.cs
@@ -28,14 +28,24 @@ namespace Microsoft.AspNet.Mvc.Razor
_getPropertiesToActivate = type =>
PropertyActivator.GetPropertiesToActivate(
type,
- typeof(ViewContextAttribute),
+ typeof(ViewContextAttribute),
CreateActivateInfo);
}
///
- public void Activate([NotNull] TTagHelper tagHelper, [NotNull] ViewContext context)
+ public void Activate(TTagHelper tagHelper, ViewContext context)
where TTagHelper : ITagHelper
{
+ if (tagHelper == null)
+ {
+ throw new ArgumentNullException(nameof(tagHelper));
+ }
+
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var propertiesToActivate = _injectActions.GetOrAdd(
tagHelper.GetType(),
_getPropertiesToActivate);
diff --git a/src/Microsoft.AspNet.Mvc.Razor/DefaultViewLocationCache.cs b/src/Microsoft.AspNet.Mvc.Razor/DefaultViewLocationCache.cs
index 05179bff3f..f33dec9c69 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/DefaultViewLocationCache.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/DefaultViewLocationCache.cs
@@ -26,8 +26,13 @@ namespace Microsoft.AspNet.Mvc.Razor
}
///
- public ViewLocationCacheResult Get([NotNull] ViewLocationExpanderContext context)
+ public ViewLocationCacheResult Get(ViewLocationExpanderContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var cacheKey = GenerateKey(context, copyViewExpanderValues: false);
ViewLocationCacheResult result;
if (_cache.TryGetValue(cacheKey, out result))
@@ -40,9 +45,14 @@ namespace Microsoft.AspNet.Mvc.Razor
///
public void Set(
- [NotNull] ViewLocationExpanderContext context,
- [NotNull] ViewLocationCacheResult value)
+ ViewLocationExpanderContext context,
+ ViewLocationCacheResult value)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var cacheKey = GenerateKey(context, copyViewExpanderValues: true);
_cache.TryAdd(cacheKey, value);
}
diff --git a/src/Microsoft.AspNet.Mvc.Razor/DependencyInjection/MvcRazorMvcBuilderExtensions.cs b/src/Microsoft.AspNet.Mvc.Razor/DependencyInjection/MvcRazorMvcBuilderExtensions.cs
index 07b56d8ffd..9d1324557d 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/DependencyInjection/MvcRazorMvcBuilderExtensions.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/DependencyInjection/MvcRazorMvcBuilderExtensions.cs
@@ -4,13 +4,11 @@
using System;
using System.Linq;
using System.Reflection;
-using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.Razor;
using Microsoft.AspNet.Mvc.Razor.Compilation;
using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
using Microsoft.Framework.DependencyInjection.Extensions;
-using Microsoft.Framework.Internal;
namespace Microsoft.Framework.DependencyInjection
{
@@ -26,9 +24,19 @@ namespace Microsoft.Framework.DependencyInjection
/// An action to configure the .
/// The .
public static IMvcBuilder AddRazorOptions(
- [NotNull] this IMvcBuilder builder,
- [NotNull] Action setupAction)
+ this IMvcBuilder builder,
+ Action setupAction)
{
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
+ if (setupAction == null)
+ {
+ throw new ArgumentNullException(nameof(setupAction));
+ }
+
builder.Services.Configure(setupAction);
return builder;
}
@@ -45,10 +53,20 @@ namespace Microsoft.Framework.DependencyInjection
/// An action to initialize the .
/// The instance this method extends.
public static IMvcBuilder InitializeTagHelper(
- [NotNull] this IMvcBuilder builder,
- [NotNull] Action initialize)
+ this IMvcBuilder builder,
+ Action initialize)
where TTagHelper : ITagHelper
{
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
+ if (initialize == null)
+ {
+ throw new ArgumentNullException(nameof(initialize));
+ }
+
var initializer = new TagHelperInitializer(initialize);
builder.Services.AddInstance(typeof(ITagHelperInitializer), initializer);
@@ -57,9 +75,19 @@ namespace Microsoft.Framework.DependencyInjection
}
public static IMvcBuilder AddPrecompiledRazorViews(
- [NotNull] this IMvcBuilder builder,
- [NotNull] params Assembly[] assemblies)
+ this IMvcBuilder builder,
+ params Assembly[] assemblies)
{
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
+ if (assemblies == null)
+ {
+ throw new ArgumentNullException(nameof(assemblies));
+ }
+
builder.Services.Replace(
ServiceDescriptor.Singleton(serviceProvider =>
ActivatorUtilities.CreateInstance(
diff --git a/src/Microsoft.AspNet.Mvc.Razor/DependencyInjection/MvcRazorMvcCoreBuilderExtensions.cs b/src/Microsoft.AspNet.Mvc.Razor/DependencyInjection/MvcRazorMvcCoreBuilderExtensions.cs
index 409eeb293d..43039e4133 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/DependencyInjection/MvcRazorMvcCoreBuilderExtensions.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/DependencyInjection/MvcRazorMvcCoreBuilderExtensions.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;
@@ -13,24 +13,38 @@ using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
using Microsoft.Framework.Caching.Memory;
using Microsoft.Framework.DependencyInjection.Extensions;
-using Microsoft.Framework.Internal;
using Microsoft.Framework.OptionsModel;
namespace Microsoft.Framework.DependencyInjection
{
public static class MvcRazorMvcCoreBuilderExtensions
{
- public static IMvcCoreBuilder AddRazorViewEngine([NotNull] this IMvcCoreBuilder builder)
+ public static IMvcCoreBuilder AddRazorViewEngine(this IMvcCoreBuilder builder)
{
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
builder.AddViews();
AddRazorViewEngineServices(builder.Services);
return builder;
}
public static IMvcCoreBuilder AddRazorViewEngine(
- [NotNull] this IMvcCoreBuilder builder,
- [NotNull] Action setupAction)
+ this IMvcCoreBuilder builder,
+ Action setupAction)
{
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
+ if (setupAction == null)
+ {
+ throw new ArgumentNullException(nameof(setupAction));
+ }
+
builder.AddViews();
AddRazorViewEngineServices(builder.Services);
@@ -43,9 +57,19 @@ namespace Microsoft.Framework.DependencyInjection
}
public static IMvcCoreBuilder AddPrecompiledRazorViews(
- [NotNull] this IMvcCoreBuilder builder,
- [NotNull] params Assembly[] assemblies)
+ this IMvcCoreBuilder builder,
+ params Assembly[] assemblies)
{
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
+ if (assemblies == null)
+ {
+ throw new ArgumentNullException(nameof(assemblies));
+ }
+
AddRazorViewEngine(builder);
builder.Services.Replace(
@@ -69,10 +93,20 @@ namespace Microsoft.Framework.DependencyInjection
/// An action to initialize the .
/// The instance this method extends.
public static IMvcCoreBuilder InitializeTagHelper(
- [NotNull] this IMvcCoreBuilder builder,
- [NotNull] Action initialize)
+ this IMvcCoreBuilder builder,
+ Action initialize)
where TTagHelper : ITagHelper
{
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
+ if (initialize == null)
+ {
+ throw new ArgumentNullException(nameof(initialize));
+ }
+
var initializer = new TagHelperInitializer(initialize);
builder.Services.AddInstance(typeof(ITagHelperInitializer), initializer);
diff --git a/src/Microsoft.AspNet.Mvc.Razor/HelperResult.cs b/src/Microsoft.AspNet.Mvc.Razor/HelperResult.cs
index 9abfa2d9d4..72d0ce3d94 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/HelperResult.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/HelperResult.cs
@@ -5,7 +5,6 @@ using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNet.Html.Abstractions;
-using Microsoft.Framework.Internal;
using Microsoft.Framework.WebEncoders;
namespace Microsoft.AspNet.Mvc.Razor
@@ -24,8 +23,13 @@ namespace Microsoft.AspNet.Mvc.Razor
/// is called.
/// Calls to result in a blocking invocation of
/// .
- public HelperResult([NotNull] Func asyncAction)
+ public HelperResult(Func asyncAction)
{
+ if (asyncAction == null)
+ {
+ throw new ArgumentNullException(nameof(asyncAction));
+ }
+
_asyncAction = asyncAction;
}
@@ -42,8 +46,18 @@ namespace Microsoft.AspNet.Mvc.Razor
///
/// The instance to write to.
/// The to encode the content.
- public virtual void WriteTo([NotNull] TextWriter writer, [NotNull] IHtmlEncoder encoder)
+ public virtual void WriteTo(TextWriter writer, IHtmlEncoder encoder)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
+ if (encoder == null)
+ {
+ throw new ArgumentNullException(nameof(encoder));
+ }
+
_asyncAction(writer).GetAwaiter().GetResult();
}
}
diff --git a/src/Microsoft.AspNet.Mvc.Razor/IRazorViewFactory.cs b/src/Microsoft.AspNet.Mvc.Razor/IRazorViewFactory.cs
index 8860b278bf..c49731f8ae 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/IRazorViewFactory.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/IRazorViewFactory.cs
@@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNet.Mvc.ViewEngines;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor
{
@@ -19,6 +18,6 @@ namespace Microsoft.AspNet.Mvc.Razor
/// The instance to execute.
/// Determines if the view is to be executed as a partial.
/// A instance that renders the contents of the
- IView GetView([NotNull] IRazorViewEngine viewEngine, [NotNull] IRazorPage page, bool isPartial);
+ IView GetView(IRazorViewEngine viewEngine, IRazorPage page, bool isPartial);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Mvc.Razor/ITagHelperInitializerOfT.cs b/src/Microsoft.AspNet.Mvc.Razor/ITagHelperInitializerOfT.cs
index 55c1b665fe..a053bfff9f 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/ITagHelperInitializerOfT.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/ITagHelperInitializerOfT.cs
@@ -3,7 +3,6 @@
using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor
{
@@ -19,6 +18,6 @@ namespace Microsoft.AspNet.Mvc.Razor
///
/// The to initialize.
/// The for the executing view.
- void Initialize([NotNull] TTagHelper helper, [NotNull] ViewContext context);
+ void Initialize(TTagHelper helper, ViewContext context);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Mvc.Razor/Internal/MvcRazorMvcViewOptionsSetup.cs b/src/Microsoft.AspNet.Mvc.Razor/Internal/MvcRazorMvcViewOptionsSetup.cs
index ea32167cd4..f397a03bec 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/Internal/MvcRazorMvcViewOptionsSetup.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/Internal/MvcRazorMvcViewOptionsSetup.cs
@@ -1,9 +1,8 @@
-// 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;
using Microsoft.Framework.DependencyInjection;
-using Microsoft.Framework.Internal;
using Microsoft.Framework.OptionsModel;
namespace Microsoft.AspNet.Mvc.Razor.Internal
@@ -28,9 +27,19 @@ namespace Microsoft.AspNet.Mvc.Razor.Internal
/// The application's .
/// The to configure.
public static void ConfigureMvc(
- [NotNull] IServiceProvider serviceProvider,
- [NotNull] MvcViewOptions options)
+ IServiceProvider serviceProvider,
+ MvcViewOptions options)
{
+ if (serviceProvider == null)
+ {
+ throw new ArgumentNullException(nameof(serviceProvider));
+ }
+
+ if (options == null)
+ {
+ throw new ArgumentNullException(nameof(options));
+ }
+
var razorViewEngine = serviceProvider.GetRequiredService();
options.ViewEngines.Add(razorViewEngine);
}
diff --git a/src/Microsoft.AspNet.Mvc.Razor/Internal/RazorFileInfoCollectionGenerator.cs b/src/Microsoft.AspNet.Mvc.Razor/Internal/RazorFileInfoCollectionGenerator.cs
index 954a27ee20..a7c42b8dc0 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/Internal/RazorFileInfoCollectionGenerator.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/Internal/RazorFileInfoCollectionGenerator.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.Runtime.CompilerServices;
using System.Text;
using Microsoft.AspNet.Mvc.Razor.Precompilation;
using Microsoft.Dnx.Runtime;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor.Internal
{
@@ -19,8 +19,13 @@ namespace Microsoft.AspNet.Mvc.Razor.Internal
///
/// The .
///
- public static string GenerateCode([NotNull] RazorFileInfoCollection fileInfoCollection)
+ public static string GenerateCode(RazorFileInfoCollection fileInfoCollection)
{
+ if (fileInfoCollection == null)
+ {
+ throw new ArgumentNullException(nameof(fileInfoCollection));
+ }
+
var builder = new StringBuilder();
builder.Append(
diff --git a/src/Microsoft.AspNet.Mvc.Razor/LanguageViewLocationExpander.cs b/src/Microsoft.AspNet.Mvc.Razor/LanguageViewLocationExpander.cs
index 2e9ecdc692..286d7fc7bd 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/LanguageViewLocationExpander.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/LanguageViewLocationExpander.cs
@@ -4,9 +4,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
-using System.Linq;
using System.Threading;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor
{
@@ -45,8 +43,13 @@ namespace Microsoft.AspNet.Mvc.Razor
}
///
- public void PopulateValues([NotNull] ViewLocationExpanderContext context)
+ public void PopulateValues(ViewLocationExpanderContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
// Using CurrentUICulture so it loads the locale specific resources for the views.
#if DNX451
context.Values[ValueKey] = Thread.CurrentThread.CurrentUICulture.Name;
@@ -57,9 +60,19 @@ namespace Microsoft.AspNet.Mvc.Razor
///
public virtual IEnumerable ExpandViewLocations(
- [NotNull] ViewLocationExpanderContext context,
- [NotNull] IEnumerable viewLocations)
+ ViewLocationExpanderContext context,
+ IEnumerable viewLocations)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (viewLocations == null)
+ {
+ throw new ArgumentNullException(nameof(viewLocations));
+ }
+
string value;
context.Values.TryGetValue(ValueKey, out value);
diff --git a/src/Microsoft.AspNet.Mvc.Razor/Precompilation/GeneratorResultExtensions.cs b/src/Microsoft.AspNet.Mvc.Razor/Precompilation/GeneratorResultExtensions.cs
index 8d7d665467..bc385e3335 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/Precompilation/GeneratorResultExtensions.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/Precompilation/GeneratorResultExtensions.cs
@@ -6,16 +6,31 @@ using System.Linq;
using Microsoft.AspNet.Razor.CodeGenerators;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor.Precompilation
{
public static class GeneratorResultExtensions
{
- public static string GetMainClassName([NotNull] this GeneratorResults results,
- [NotNull] IMvcRazorHost host,
- [NotNull] SyntaxTree syntaxTree)
+ public static string GetMainClassName(
+ this GeneratorResults results,
+ IMvcRazorHost host,
+ SyntaxTree syntaxTree)
{
+ if (results == null)
+ {
+ throw new ArgumentNullException(nameof(results));
+ }
+
+ if (host == null)
+ {
+ throw new ArgumentNullException(nameof(host));
+ }
+
+ if (syntaxTree == null)
+ {
+ throw new ArgumentNullException(nameof(syntaxTree));
+ }
+
// The mainClass name should return directly from the generator results.
var classes = syntaxTree.GetRoot().DescendantNodes().OfType();
var mainClass = classes.FirstOrDefault(c =>
diff --git a/src/Microsoft.AspNet.Mvc.Razor/Precompilation/PrecompilationCacheEntry.cs b/src/Microsoft.AspNet.Mvc.Razor/Precompilation/PrecompilationCacheEntry.cs
index a4f977225e..72e3eca347 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/Precompilation/PrecompilationCacheEntry.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/Precompilation/PrecompilationCacheEntry.cs
@@ -1,9 +1,9 @@
// 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.CodeAnalysis;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor.Precompilation
{
@@ -17,9 +17,20 @@ namespace Microsoft.AspNet.Mvc.Razor.Precompilation
///
/// The of the file being cached.
/// The to cache.
- public PrecompilationCacheEntry([NotNull] RazorFileInfo fileInfo,
- [NotNull] SyntaxTree syntaxTree)
+ public PrecompilationCacheEntry(
+ RazorFileInfo fileInfo,
+ SyntaxTree syntaxTree)
{
+ if (fileInfo == null)
+ {
+ throw new ArgumentNullException(nameof(fileInfo));
+ }
+
+ if (syntaxTree == null)
+ {
+ throw new ArgumentNullException(nameof(syntaxTree));
+ }
+
FileInfo = fileInfo;
SyntaxTree = syntaxTree;
}
@@ -30,8 +41,13 @@ namespace Microsoft.AspNet.Mvc.Razor.Precompilation
/// The produced from parsing the Razor
/// file. This does not contain s produced from compiling the parsed
/// .
- public PrecompilationCacheEntry([NotNull] IReadOnlyList diagnostics)
+ public PrecompilationCacheEntry(IReadOnlyList diagnostics)
{
+ if (diagnostics == null)
+ {
+ throw new ArgumentNullException(nameof(diagnostics));
+ }
+
Diagnostics = diagnostics;
}
diff --git a/src/Microsoft.AspNet.Mvc.Razor/Precompilation/RazorErrorExtensions.cs b/src/Microsoft.AspNet.Mvc.Razor/Precompilation/RazorErrorExtensions.cs
index 411f9e5abb..2e3795ebc7 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/Precompilation/RazorErrorExtensions.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/Precompilation/RazorErrorExtensions.cs
@@ -5,14 +5,23 @@ using System;
using Microsoft.AspNet.Razor;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor.Precompilation
{
public static class RazorErrorExtensions
{
- public static Diagnostic ToDiagnostics([NotNull] this RazorError error, [NotNull] string filePath)
+ public static Diagnostic ToDiagnostics(this RazorError error, string filePath)
{
+ if (error == null)
+ {
+ throw new ArgumentNullException(nameof(error));
+ }
+
+ if (filePath == null)
+ {
+ throw new ArgumentNullException(nameof(filePath));
+ }
+
var descriptor = new DiagnosticDescriptor(
id: "Razor",
title: "Razor parsing error",
diff --git a/src/Microsoft.AspNet.Mvc.Razor/Precompilation/RazorPreCompiler.cs b/src/Microsoft.AspNet.Mvc.Razor/Precompilation/RazorPreCompiler.cs
index caf088d3a0..c03b76240c 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/Precompilation/RazorPreCompiler.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/Precompilation/RazorPreCompiler.cs
@@ -19,7 +19,6 @@ using Microsoft.CodeAnalysis.CSharp;
using Microsoft.Dnx.Compilation;
using Microsoft.Dnx.Compilation.CSharp;
using Microsoft.Framework.Caching.Memory;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor.Precompilation
{
@@ -28,10 +27,25 @@ namespace Microsoft.AspNet.Mvc.Razor.Precompilation
private const string CacheKeyDirectorySeparator = "/";
public RazorPreCompiler(
- [NotNull] BeforeCompileContext compileContext,
- [NotNull] IFileProvider fileProvider,
- [NotNull] IMemoryCache precompilationCache)
+ BeforeCompileContext compileContext,
+ IFileProvider fileProvider,
+ IMemoryCache precompilationCache)
{
+ if (compileContext == null)
+ {
+ throw new ArgumentNullException(nameof(compileContext));
+ }
+
+ if (fileProvider == null)
+ {
+ throw new ArgumentNullException(nameof(fileProvider));
+ }
+
+ if (precompilationCache == null)
+ {
+ throw new ArgumentNullException(nameof(precompilationCache));
+ }
+
CompileContext = compileContext;
FileProvider = fileProvider;
// There should always be a syntax tree even if there are no files (we generate one)
@@ -137,9 +151,19 @@ namespace Microsoft.AspNet.Mvc.Razor.Precompilation
}
protected virtual RazorFileInfoCollection GeneratePrecompiledAssembly(
- [NotNull] IEnumerable syntaxTrees,
- [NotNull] IEnumerable razorFileInfos)
+ IEnumerable syntaxTrees,
+ IEnumerable razorFileInfos)
{
+ if (syntaxTrees == null)
+ {
+ throw new ArgumentNullException(nameof(syntaxTrees));
+ }
+
+ if (razorFileInfos == null)
+ {
+ throw new ArgumentNullException(nameof(razorFileInfos));
+ }
+
var resourcePrefix = string.Join(".", CompileContext.Compilation.AssemblyName,
nameof(RazorPreCompiler),
Path.GetRandomFileName());
@@ -241,8 +265,13 @@ namespace Microsoft.AspNet.Mvc.Razor.Precompilation
}
}
- protected virtual PrecompilationCacheEntry GetCacheEntry([NotNull] RelativeFileInfo fileInfo)
+ protected virtual PrecompilationCacheEntry GetCacheEntry(RelativeFileInfo fileInfo)
{
+ if (fileInfo == null)
+ {
+ throw new ArgumentNullException(nameof(fileInfo));
+ }
+
using (var stream = fileInfo.FileInfo.CreateReadStream())
{
var host = GetRazorHost();
diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs
index d5507a3ce4..0502789a59 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs
@@ -14,12 +14,10 @@ using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc.Actions;
using Microsoft.AspNet.Mvc.Razor.Internal;
using Microsoft.AspNet.Mvc.Rendering;
-using Microsoft.AspNet.Mvc.Routing;
using Microsoft.AspNet.Mvc.ViewFeatures;
using Microsoft.AspNet.PageExecutionInstrumentation;
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
using Microsoft.Framework.DependencyInjection;
-using Microsoft.Framework.Internal;
using Microsoft.Framework.WebEncoders;
namespace Microsoft.AspNet.Mvc.Razor
@@ -227,8 +225,13 @@ namespace Microsoft.AspNet.Mvc.Razor
/// All writes to the or after calling this method will
/// be buffered until is called.
///
- public void StartTagHelperWritingScope([NotNull] TextWriter writer)
+ public void StartTagHelperWritingScope(TextWriter writer)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
// If there isn't a base writer take the ViewContext.Writer
if (_originalWriter == null)
{
@@ -297,8 +300,13 @@ namespace Microsoft.AspNet.Mvc.Razor
///
/// A that on completion writes the content.
///
- public Task WriteTagHelperAsync([NotNull] TagHelperExecutionContext tagHelperExecutionContext)
+ public Task WriteTagHelperAsync(TagHelperExecutionContext tagHelperExecutionContext)
{
+ if (tagHelperExecutionContext == null)
+ {
+ throw new ArgumentNullException(nameof(tagHelperExecutionContext));
+ }
+
return WriteTagHelperToAsync(Output, tagHelperExecutionContext);
}
@@ -313,9 +321,19 @@ namespace Microsoft.AspNet.Mvc.Razor
/// to the .
///
public async Task WriteTagHelperToAsync(
- [NotNull] TextWriter writer,
- [NotNull] TagHelperExecutionContext tagHelperExecutionContext)
+ TextWriter writer,
+ TagHelperExecutionContext tagHelperExecutionContext)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
+ if (tagHelperExecutionContext == null)
+ {
+ throw new ArgumentNullException(nameof(tagHelperExecutionContext));
+ }
+
var tagHelperOutput = tagHelperExecutionContext.Output;
var isTagNameNullOrWhitespace = string.IsNullOrWhiteSpace(tagHelperOutput.TagName);
@@ -395,8 +413,13 @@ namespace Microsoft.AspNet.Mvc.Razor
/// For all other types, the encoded result of is written to the
/// .
///
- public virtual void WriteTo([NotNull] TextWriter writer, object value)
+ public virtual void WriteTo(TextWriter writer, object value)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
WriteTo(writer, HtmlEncoder, value, escapeQuotes: false);
}
@@ -417,11 +440,21 @@ namespace Microsoft.AspNet.Mvc.Razor
/// .
///
public static void WriteTo(
- [NotNull] TextWriter writer,
- [NotNull] IHtmlEncoder encoder,
+ TextWriter writer,
+ IHtmlEncoder encoder,
object value,
bool escapeQuotes)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
+ if (encoder == null)
+ {
+ throw new ArgumentNullException(nameof(encoder));
+ }
+
if (value == null || value == HtmlString.Empty)
{
return;
@@ -475,8 +508,13 @@ namespace Microsoft.AspNet.Mvc.Razor
///
/// The instance to write to.
/// The to write.
- public virtual void WriteTo([NotNull] TextWriter writer, string value)
+ public virtual void WriteTo(TextWriter writer, string value)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
WriteTo(writer, HtmlEncoder, value);
}
@@ -502,8 +540,13 @@ namespace Microsoft.AspNet.Mvc.Razor
///
/// The instance to write to.
/// The to write.
- public virtual void WriteLiteralTo([NotNull] TextWriter writer, object value)
+ public virtual void WriteLiteralTo(TextWriter writer, object value)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
if (value != null)
{
WriteLiteralTo(writer, value.ToString());
@@ -515,8 +558,13 @@ namespace Microsoft.AspNet.Mvc.Razor
///
/// The instance to write to.
/// The to write.
- public virtual void WriteLiteralTo([NotNull] TextWriter writer, string value)
+ public virtual void WriteLiteralTo(TextWriter writer, string value)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
if (!string.IsNullOrEmpty(value))
{
writer.Write(value);
@@ -525,20 +573,45 @@ namespace Microsoft.AspNet.Mvc.Razor
public virtual void WriteAttribute(
string name,
- [NotNull] PositionTagged prefix,
- [NotNull] PositionTagged suffix,
+ PositionTagged prefix,
+ PositionTagged suffix,
params AttributeValue[] values)
{
+ if (prefix == null)
+ {
+ throw new ArgumentNullException(nameof(prefix));
+ }
+
+ if (suffix == null)
+ {
+ throw new ArgumentNullException(nameof(suffix));
+ }
+
WriteAttributeTo(Output, name, prefix, suffix, values);
}
public virtual void WriteAttributeTo(
- [NotNull] TextWriter writer,
+ TextWriter writer,
string name,
- [NotNull] PositionTagged prefix,
- [NotNull] PositionTagged suffix,
+ PositionTagged prefix,
+ PositionTagged suffix,
params AttributeValue[] values)
{
+ if (writer == null)
+ {
+ throw new ArgumentNullException(nameof(writer));
+ }
+
+ if (prefix == null)
+ {
+ throw new ArgumentNullException(nameof(prefix));
+ }
+
+ if (suffix == null)
+ {
+ throw new ArgumentNullException(nameof(suffix));
+ }
+
if (values.Length == 0)
{
// Explicitly empty attribute, so write the prefix
@@ -647,8 +720,13 @@ namespace Microsoft.AspNet.Mvc.Razor
}
}
- public virtual string Href([NotNull] string contentPath)
+ public virtual string Href(string contentPath)
{
+ if (contentPath == null)
+ {
+ throw new ArgumentNullException(nameof(contentPath));
+ }
+
if (_urlHelper == null)
{
_urlHelper = Context.RequestServices.GetRequiredService();
@@ -725,8 +803,18 @@ namespace Microsoft.AspNet.Mvc.Razor
///
/// The name of the section to create.
/// The to execute when rendering the section.
- public void DefineSection([NotNull] string name, [NotNull] RenderAsyncDelegate section)
+ public void DefineSection(string name, RenderAsyncDelegate section)
{
+ if (name == null)
+ {
+ throw new ArgumentNullException(nameof(name));
+ }
+
+ if (section == null)
+ {
+ throw new ArgumentNullException(nameof(section));
+ }
+
if (SectionWriters.ContainsKey(name))
{
throw new InvalidOperationException(Resources.FormatSectionAlreadyDefined(name));
@@ -734,8 +822,13 @@ namespace Microsoft.AspNet.Mvc.Razor
SectionWriters[name] = section;
}
- public bool IsSectionDefined([NotNull] string name)
+ public bool IsSectionDefined(string name)
{
+ if (name == null)
+ {
+ throw new ArgumentNullException(nameof(name));
+ }
+
EnsureMethodCanBeInvoked(nameof(IsSectionDefined));
return PreviousSectionWriters.ContainsKey(name);
}
@@ -749,8 +842,13 @@ namespace Microsoft.AspNet.Mvc.Razor
/// The method writes to the and the value returned is a token
/// value that allows the Write (produced due to @RenderSection(..)) to succeed. However the
/// value does not represent the rendered content.
- public HtmlString RenderSection([NotNull] string name)
+ public HtmlString RenderSection(string name)
{
+ if (name == null)
+ {
+ throw new ArgumentNullException(nameof(name));
+ }
+
return RenderSection(name, required: true);
}
@@ -764,8 +862,13 @@ namespace Microsoft.AspNet.Mvc.Razor
/// The method writes to the and the value returned is a token
/// value that allows the Write (produced due to @RenderSection(..)) to succeed. However the
/// value does not represent the rendered content.
- public HtmlString RenderSection([NotNull] string name, bool required)
+ public HtmlString RenderSection(string name, bool required)
{
+ if (name == null)
+ {
+ throw new ArgumentNullException(nameof(name));
+ }
+
EnsureMethodCanBeInvoked(nameof(RenderSection));
var task = RenderSectionAsyncCore(name, required);
@@ -781,8 +884,13 @@ namespace Microsoft.AspNet.Mvc.Razor
/// The method writes to the and the value returned is a token
/// value that allows the Write (produced due to @RenderSection(..)) to succeed. However the
/// value does not represent the rendered content.
- public Task RenderSectionAsync([NotNull] string name)
+ public Task RenderSectionAsync(string name)
{
+ if (name == null)
+ {
+ throw new ArgumentNullException(nameof(name));
+ }
+
return RenderSectionAsync(name, required: true);
}
@@ -797,8 +905,13 @@ namespace Microsoft.AspNet.Mvc.Razor
/// value does not represent the rendered content.
/// if is true and the section
/// was not registered using the @section in the Razor page.
- public Task RenderSectionAsync([NotNull] string name, bool required)
+ public Task RenderSectionAsync(string name, bool required)
{
+ if (name == null)
+ {
+ throw new ArgumentNullException(nameof(name));
+ }
+
EnsureMethodCanBeInvoked(nameof(RenderSectionAsync));
return RenderSectionAsyncCore(name, required);
}
diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorPageActivator.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorPageActivator.cs
index d01b782fae..1feed27c87 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/RazorPageActivator.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/RazorPageActivator.cs
@@ -32,8 +32,18 @@ namespace Microsoft.AspNet.Mvc.Razor
}
///
- public void Activate([NotNull] IRazorPage page, [NotNull] ViewContext context)
+ public void Activate(IRazorPage page, ViewContext context)
{
+ if (page == null)
+ {
+ throw new ArgumentNullException(nameof(page));
+ }
+
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
var activationInfo = _activationInfo.GetOrAdd(page.GetType(),
CreateViewActivationInfo);
diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorPageOfT.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorPageOfT.cs
index a313a65030..c276b2b291 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/RazorPageOfT.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/RazorPageOfT.cs
@@ -8,7 +8,6 @@ using Microsoft.AspNet.Mvc.Razor.Internal;
using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.AspNet.Mvc.ViewFeatures;
using Microsoft.Framework.DependencyInjection;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor
{
@@ -41,8 +40,13 @@ namespace Microsoft.AspNet.Mvc.Razor
///
/// Compiler normally infers from the given .
///
- public ModelExpression CreateModelExpression([NotNull] Expression> expression)
+ public ModelExpression CreateModelExpression(Expression> expression)
{
+ if (expression == null)
+ {
+ throw new ArgumentNullException(nameof(expression));
+ }
+
if (_provider == null)
{
_provider = Context.RequestServices.GetRequiredService();
diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorPageResult.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorPageResult.cs
index 1c7a1bc6b9..92628d18a5 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/RazorPageResult.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/RazorPageResult.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.Mvc.Razor
{
@@ -16,8 +16,18 @@ namespace Microsoft.AspNet.Mvc.Razor
///
/// The name of the page that was located.
/// The located .
- public RazorPageResult([NotNull] string name, [NotNull] IRazorPage page)
+ public RazorPageResult(string name, IRazorPage page)
{
+ if (name == null)
+ {
+ throw new ArgumentNullException(nameof(name));
+ }
+
+ if (page == null)
+ {
+ throw new ArgumentNullException(nameof(page));
+ }
+
Name = name;
Page = page;
}
@@ -27,8 +37,18 @@ namespace Microsoft.AspNet.Mvc.Razor
///
/// The name of the page that was located.
/// The locations that were searched.
- public RazorPageResult([NotNull] string name, [NotNull] IEnumerable searchedLocations)
+ public RazorPageResult(string name, IEnumerable searchedLocations)
{
+ if (name == null)
+ {
+ throw new ArgumentNullException(nameof(name));
+ }
+
+ if (searchedLocations == null)
+ {
+ throw new ArgumentNullException(nameof(searchedLocations));
+ }
+
Name = name;
SearchedLocations = searchedLocations;
}
diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorTextWriter.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorTextWriter.cs
index afdcaab6be..dc3dba35b7 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/RazorTextWriter.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/RazorTextWriter.cs
@@ -6,9 +6,7 @@ using System.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNet.Html.Abstractions;
-using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.AspNet.Mvc.ViewFeatures;
-using Microsoft.Framework.Internal;
using Microsoft.Framework.WebEncoders;
namespace Microsoft.AspNet.Mvc.Razor
@@ -66,8 +64,13 @@ namespace Microsoft.AspNet.Mvc.Razor
}
///
- public override void Write([NotNull] char[] buffer, int index, int count)
+ public override void Write(char[] buffer, int index, int count)
{
+ if (buffer == null)
+ {
+ throw new ArgumentNullException(nameof(buffer));
+ }
+
if (index < 0)
{
throw new ArgumentOutOfRangeException(nameof(index));
@@ -110,8 +113,13 @@ namespace Microsoft.AspNet.Mvc.Razor
}
///
- public override Task WriteAsync([NotNull] char[] buffer, int index, int count)
+ public override Task WriteAsync(char[] buffer, int index, int count)
{
+ if (buffer == null)
+ {
+ throw new ArgumentNullException(nameof(buffer));
+ }
+
if (index < 0)
{
throw new ArgumentOutOfRangeException(nameof(index));
diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorView.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorView.cs
index 86bb79369d..976ddce3a8 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/RazorView.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/RazorView.cs
@@ -10,7 +10,6 @@ using Microsoft.AspNet.Http.Features;
using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.AspNet.Mvc.ViewEngines;
using Microsoft.AspNet.PageExecutionInstrumentation;
-using Microsoft.Framework.Internal;
using Microsoft.Framework.WebEncoders;
namespace Microsoft.AspNet.Mvc.Razor
@@ -75,8 +74,18 @@ namespace Microsoft.AspNet.Mvc.Razor
}
///
- public virtual async Task RenderAsync([NotNull] ViewContext context)
+ public virtual async Task RenderAsync(ViewContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
_pageExecutionFeature = context.HttpContext.Features.Get();
// Partials don't execute _ViewStart pages, but may execute Layout pages if the Layout property
diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorViewEngine.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorViewEngine.cs
index b07789c852..e0cd76aa44 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/RazorViewEngine.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/RazorViewEngine.cs
@@ -7,9 +7,7 @@ using System.Diagnostics;
using System.Globalization;
using System.Linq;
using Microsoft.AspNet.Mvc.Actions;
-using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.AspNet.Mvc.ViewEngines;
-using Microsoft.Framework.Internal;
using Microsoft.Framework.OptionsModel;
namespace Microsoft.AspNet.Mvc.Razor
@@ -101,9 +99,14 @@ namespace Microsoft.AspNet.Mvc.Razor
///
public ViewEngineResult FindView(
- [NotNull] ActionContext context,
+ ActionContext context,
string viewName)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
if (string.IsNullOrEmpty(viewName))
{
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(viewName));
@@ -115,9 +118,14 @@ namespace Microsoft.AspNet.Mvc.Razor
///
public ViewEngineResult FindPartialView(
- [NotNull] ActionContext context,
+ ActionContext context,
string partialViewName)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
if (string.IsNullOrEmpty(partialViewName))
{
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(partialViewName));
@@ -129,9 +137,14 @@ namespace Microsoft.AspNet.Mvc.Razor
///
public RazorPageResult FindPage(
- [NotNull] ActionContext context,
+ ActionContext context,
string pageName)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
if (string.IsNullOrEmpty(pageName))
{
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(pageName));
@@ -154,9 +167,19 @@ namespace Microsoft.AspNet.Mvc.Razor
/// consistently cased results.
///
public static string GetNormalizedRouteValue(
- [NotNull] ActionContext context,
- [NotNull] string key)
+ ActionContext context,
+ string key)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (key == null)
+ {
+ throw new ArgumentNullException(nameof(key));
+ }
+
object routeValue;
if (!context.RouteData.Values.TryGetValue(key, out routeValue))
{
diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorViewFactory.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorViewFactory.cs
index 85b3acf259..e6999880dc 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/RazorViewFactory.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/RazorViewFactory.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.Mvc.ViewEngines;
-using Microsoft.Framework.Internal;
using Microsoft.Framework.WebEncoders;
namespace Microsoft.AspNet.Mvc.Razor
@@ -23,9 +23,10 @@ namespace Microsoft.AspNet.Mvc.Razor
/// The used to activate pages.
/// The used for discovery of _ViewStart
/// pages
- public RazorViewFactory(IRazorPageActivator pageActivator,
- IViewStartProvider viewStartProvider,
- IHtmlEncoder htmlEncoder)
+ public RazorViewFactory(
+ IRazorPageActivator pageActivator,
+ IViewStartProvider viewStartProvider,
+ IHtmlEncoder htmlEncoder)
{
_pageActivator = pageActivator;
_viewStartProvider = viewStartProvider;
@@ -33,10 +34,21 @@ namespace Microsoft.AspNet.Mvc.Razor
}
///
- public IView GetView([NotNull] IRazorViewEngine viewEngine,
- [NotNull] IRazorPage page,
- bool isPartial)
+ public IView GetView(
+ IRazorViewEngine viewEngine,
+ IRazorPage page,
+ bool isPartial)
{
+ if (viewEngine == null)
+ {
+ throw new ArgumentNullException(nameof(viewEngine));
+ }
+
+ if (page == null)
+ {
+ throw new ArgumentNullException(nameof(page));
+ }
+
var razorView = new RazorView(
viewEngine,
_pageActivator,
diff --git a/src/Microsoft.AspNet.Mvc.Razor/TagHelperContentWrapperTextWriter.cs b/src/Microsoft.AspNet.Mvc.Razor/TagHelperContentWrapperTextWriter.cs
index ba2e305015..84a4f8f48d 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/TagHelperContentWrapperTextWriter.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/TagHelperContentWrapperTextWriter.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.IO;
using System.Text;
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor
{
@@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Mvc.Razor
/// Initializes a new instance of the class.
///
/// The in which output is written.
- public TagHelperContentWrapperTextWriter([NotNull] Encoding encoding)
+ public TagHelperContentWrapperTextWriter(Encoding encoding)
: this(encoding, new DefaultTagHelperContent())
{
}
@@ -27,8 +27,18 @@ namespace Microsoft.AspNet.Mvc.Razor
///
/// The in which output is written.
/// The to write to.
- public TagHelperContentWrapperTextWriter([NotNull] Encoding encoding, [NotNull] TagHelperContent content)
+ public TagHelperContentWrapperTextWriter(Encoding encoding, TagHelperContent content)
{
+ if (encoding == null)
+ {
+ throw new ArgumentNullException(nameof(encoding));
+ }
+
+ if (content == null)
+ {
+ throw new ArgumentNullException(nameof(content));
+ }
+
Content = content;
Encoding = encoding;
}
diff --git a/src/Microsoft.AspNet.Mvc.Razor/TagHelperInitializerOfT.cs b/src/Microsoft.AspNet.Mvc.Razor/TagHelperInitializerOfT.cs
index b4f9c976ec..0c8aa1ae48 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/TagHelperInitializerOfT.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/TagHelperInitializerOfT.cs
@@ -4,7 +4,6 @@
using System;
using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor
{
@@ -18,14 +17,29 @@ namespace Microsoft.AspNet.Mvc.Razor
/// Creates a .
///
/// The initialization delegate.
- public TagHelperInitializer([NotNull] Action action)
+ public TagHelperInitializer(Action action)
{
+ if (action == null)
+ {
+ throw new ArgumentNullException(nameof(action));
+ }
+
_initializeDelegate = action;
}
///
- public void Initialize([NotNull] TTagHelper helper, [NotNull] ViewContext context)
+ public void Initialize(TTagHelper helper, ViewContext context)
{
+ if (helper == null)
+ {
+ throw new ArgumentNullException(nameof(helper));
+ }
+
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
_initializeDelegate(helper, context);
}
}
diff --git a/src/Microsoft.AspNet.Mvc.Razor/ViewLocationCacheResult.cs b/src/Microsoft.AspNet.Mvc.Razor/ViewLocationCacheResult.cs
index cfd1241018..6188d21ee6 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/ViewLocationCacheResult.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/ViewLocationCacheResult.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;
@@ -21,10 +21,20 @@ namespace Microsoft.AspNet.Mvc.Razor
/// Locations that were searched
/// in addition to .
public ViewLocationCacheResult(
- [NotNull] string foundLocation,
- [NotNull] IEnumerable searchedLocations)
- : this (searchedLocations)
+ string foundLocation,
+ IEnumerable searchedLocations)
+ : this(searchedLocations)
{
+ if (foundLocation == null)
+ {
+ throw new ArgumentNullException(nameof(foundLocation));
+ }
+
+ if (searchedLocations == null)
+ {
+ throw new ArgumentNullException(nameof(searchedLocations));
+ }
+
ViewLocation = foundLocation;
SearchedLocations = searchedLocations;
IsFoundResult = true;
@@ -35,8 +45,13 @@ namespace Microsoft.AspNet.Mvc.Razor
/// failed view lookup.
///
/// Locations that were searched.
- public ViewLocationCacheResult([NotNull] IEnumerable searchedLocations)
+ public ViewLocationCacheResult(IEnumerable searchedLocations)
{
+ if (searchedLocations == null)
+ {
+ throw new ArgumentNullException(nameof(searchedLocations));
+ }
+
SearchedLocations = searchedLocations;
ViewLocation = null;
IsFoundResult = false;
diff --git a/src/Microsoft.AspNet.Mvc.Razor/ViewLocationExpanderContext.cs b/src/Microsoft.AspNet.Mvc.Razor/ViewLocationExpanderContext.cs
index 86bab84e67..1e775dcda4 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/ViewLocationExpanderContext.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/ViewLocationExpanderContext.cs
@@ -1,9 +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.AspNet.Mvc.Actions;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor
{
@@ -18,10 +17,20 @@ namespace Microsoft.AspNet.Mvc.Razor
/// The for the current executing action.
/// The view name.
/// Determines if the view being discovered is a partial.
- public ViewLocationExpanderContext([NotNull] ActionContext actionContext,
- [NotNull] string viewName,
+ public ViewLocationExpanderContext(ActionContext actionContext,
+ string viewName,
bool isPartial)
{
+ if (actionContext == null)
+ {
+ throw new ArgumentNullException(nameof(actionContext));
+ }
+
+ if (viewName == null)
+ {
+ throw new ArgumentNullException(nameof(viewName));
+ }
+
ActionContext = actionContext;
ViewName = viewName;
IsPartial = isPartial;
diff --git a/src/Microsoft.AspNet.Mvc.Razor/ViewStartProvider.cs b/src/Microsoft.AspNet.Mvc.Razor/ViewStartProvider.cs
index 34b1e11359..c0bdcde162 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/ViewStartProvider.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/ViewStartProvider.cs
@@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor
{
@@ -19,8 +18,13 @@ namespace Microsoft.AspNet.Mvc.Razor
}
///
- public IEnumerable GetViewStartPages([NotNull] string path)
+ public IEnumerable GetViewStartPages(string path)
{
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
var viewStartLocations = ViewHierarchyUtility.GetViewStartLocations(path);
var viewStarts = viewStartLocations.Select(_pageFactory.CreateInstance)
.Where(p => p != null)
diff --git a/src/Microsoft.AspNet.Mvc.Razor/VirtualPathRazorPageFactory.cs b/src/Microsoft.AspNet.Mvc.Razor/VirtualPathRazorPageFactory.cs
index 4d29760242..93f1d60b22 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/VirtualPathRazorPageFactory.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/VirtualPathRazorPageFactory.cs
@@ -3,7 +3,6 @@
using System;
using Microsoft.AspNet.Mvc.Razor.Compilation;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.Razor
{
@@ -47,8 +46,13 @@ namespace Microsoft.AspNet.Mvc.Razor
}
///
- public IRazorPage CreateInstance([NotNull] string relativePath)
+ public IRazorPage CreateInstance(string relativePath)
{
+ if (relativePath == null)
+ {
+ throw new ArgumentNullException(nameof(relativePath));
+ }
+
if (relativePath.StartsWith("~/", StringComparison.Ordinal))
{
// For tilde slash paths, drop the leading ~ to make it work with the underlying IFileProvider.
diff --git a/src/Microsoft.AspNet.Mvc.Razor/project.json b/src/Microsoft.AspNet.Mvc.Razor/project.json
index 48f1cbfd04..31a5cae4c8 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/project.json
+++ b/src/Microsoft.AspNet.Mvc.Razor/project.json
@@ -14,7 +14,6 @@
"Microsoft.AspNet.Razor.Runtime.Precompilation": "4.0.0-*",
"Microsoft.AspNet.PageExecutionInstrumentation.Interfaces": "1.0.0-*",
"Microsoft.Framework.HashCodeCombiner.Sources": { "version": "1.0.0-*", "type": "build" },
- "Microsoft.Framework.NotNullAttribute.Sources": { "version": "1.0.0-*", "type": "build" },
"Microsoft.Framework.PropertyActivator.Sources": { "version": "1.0.0-*", "type": "build" },
"Microsoft.Framework.PropertyHelper.Sources": { "version": "1.0.0-*", "type": "build" },
"Microsoft.Dnx.Compilation.CSharp.Common": "1.0.0-*",
diff --git a/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/AttributeMatcher.cs b/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/AttributeMatcher.cs
index 7e354456a3..eccce9c611 100644
--- a/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/AttributeMatcher.cs
+++ b/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/AttributeMatcher.cs
@@ -4,9 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Reflection;
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.TagHelpers.Internal
{
@@ -24,9 +22,19 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal
/// The modes and their required attributes.
/// The .
public static ModeMatchResult DetermineMode(
- [NotNull] TagHelperContext context,
- [NotNull] IEnumerable> modeInfos)
+ TagHelperContext context,
+ IEnumerable> modeInfos)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (modeInfos == null)
+ {
+ throw new ArgumentNullException(nameof(modeInfos));
+ }
+
// true == full match, false == partial match
var matchedAttributes = new Dictionary(StringComparer.OrdinalIgnoreCase);
var result = new ModeMatchResult();
diff --git a/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/FileProviderGlobbingDirectory.cs b/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/FileProviderGlobbingDirectory.cs
index bccd443063..d6211badd8 100644
--- a/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/FileProviderGlobbingDirectory.cs
+++ b/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/FileProviderGlobbingDirectory.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 Microsoft.AspNet.FileProviders;
using Microsoft.Framework.FileSystemGlobbing.Abstractions;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.TagHelpers.Internal
{
@@ -17,10 +17,15 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal
private readonly bool _isRoot;
public FileProviderGlobbingDirectory(
- [NotNull] IFileProvider fileProvider,
+ IFileProvider fileProvider,
IFileInfo fileInfo,
FileProviderGlobbingDirectory parent)
{
+ if (fileProvider == null)
+ {
+ throw new ArgumentNullException(nameof(fileProvider));
+ }
+
_fileProvider = fileProvider;
_fileInfo = fileInfo;
_parent = parent;
@@ -54,7 +59,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal
// We're the root, so just use our name
return Name;
}
-
+
return _parent.FullName + DirectorySeparatorChar + Name;
}
}
diff --git a/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/FileProviderGlobbingFile.cs b/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/FileProviderGlobbingFile.cs
index b41ec9eaeb..a78d28eb8b 100644
--- a/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/FileProviderGlobbingFile.cs
+++ b/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/FileProviderGlobbingFile.cs
@@ -1,9 +1,9 @@
// 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.FileProviders;
using Microsoft.Framework.FileSystemGlobbing.Abstractions;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.TagHelpers.Internal
{
@@ -11,8 +11,18 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal
{
private const char DirectorySeparatorChar = '/';
- public FileProviderGlobbingFile([NotNull] IFileInfo fileInfo, [NotNull] DirectoryInfoBase parent)
+ public FileProviderGlobbingFile(IFileInfo fileInfo, DirectoryInfoBase parent)
{
+ if (fileInfo == null)
+ {
+ throw new ArgumentNullException(nameof(fileInfo));
+ }
+
+ if (parent == null)
+ {
+ throw new ArgumentNullException(nameof(parent));
+ }
+
Name = fileInfo.Name;
ParentDirectory = parent;
FullName = ParentDirectory.FullName + DirectorySeparatorChar + Name;
diff --git a/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/FileVersionProvider.cs b/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/FileVersionProvider.cs
index fd9c42ed37..a9a116fb62 100644
--- a/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/FileVersionProvider.cs
+++ b/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/FileVersionProvider.cs
@@ -7,7 +7,6 @@ using Microsoft.AspNet.FileProviders;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.WebUtilities;
using Microsoft.Framework.Caching.Memory;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.TagHelpers.Internal
{
@@ -28,10 +27,20 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal
/// Name of the application.
/// where versioned urls of files are cached.
public FileVersionProvider(
- [NotNull] IFileProvider fileProvider,
- [NotNull] IMemoryCache cache,
- [NotNull] PathString requestPathBase)
+ IFileProvider fileProvider,
+ IMemoryCache cache,
+ PathString requestPathBase)
{
+ if (fileProvider == null)
+ {
+ throw new ArgumentNullException(nameof(fileProvider));
+ }
+
+ if (cache == null)
+ {
+ throw new ArgumentNullException(nameof(cache));
+ }
+
_fileProvider = fileProvider;
_cache = cache;
_requestPathBase = requestPathBase;
@@ -45,8 +54,13 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal
///
/// The version query string is appended as with the key "v".
///
- public string AddFileVersionToPath([NotNull] string path)
+ public string AddFileVersionToPath(string path)
{
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
var resolvedPath = path;
var queryStringOrFragmentStartIndex = path.IndexOfAny(new char[] { '?', '#' });
@@ -80,7 +94,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal
}
string value;
- if(!_cache.TryGetValue(path, out value))
+ if (!_cache.TryGetValue(path, out value))
{
value = QueryHelpers.AddQueryString(path, VersionKey, GetHashForFile(fileInfo));
_cache.Set(
diff --git a/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/GlobbingUrlBuilder.cs b/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/GlobbingUrlBuilder.cs
index d8fa1610ea..92a9a2b4bb 100644
--- a/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/GlobbingUrlBuilder.cs
+++ b/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/GlobbingUrlBuilder.cs
@@ -6,10 +6,8 @@ using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNet.FileProviders;
using Microsoft.AspNet.Http;
-using Microsoft.AspNet.Razor.Runtime.TagHelpers;
using Microsoft.Framework.Caching.Memory;
using Microsoft.Framework.FileSystemGlobbing;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.TagHelpers.Internal
{
@@ -37,8 +35,13 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal
/// The file provider.
/// The cache.
/// The request path base.
- public GlobbingUrlBuilder([NotNull] IFileProvider fileProvider, IMemoryCache cache, PathString requestPathBase)
+ public GlobbingUrlBuilder(IFileProvider fileProvider, IMemoryCache cache, PathString requestPathBase)
{
+ if (fileProvider == null)
+ {
+ throw new ArgumentNullException(nameof(fileProvider));
+ }
+
FileProvider = fileProvider;
Cache = cache;
RequestPathBase = requestPathBase;
diff --git a/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/ModeMatchResult.cs b/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/ModeMatchResult.cs
index 4ae14d7f00..898b8f60d8 100644
--- a/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/ModeMatchResult.cs
+++ b/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/ModeMatchResult.cs
@@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
-using Microsoft.Framework.Internal;
using Microsoft.Framework.Logging;
namespace Microsoft.AspNet.Mvc.TagHelpers.Internal
@@ -41,12 +40,22 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal
/// The value of .
/// The path to the view the is on.
public void LogDetails(
- [NotNull] ILogger logger,
- [NotNull] TTagHelper tagHelper,
+ ILogger logger,
+ TTagHelper tagHelper,
string uniqueId,
string viewPath)
where TTagHelper : ITagHelper
{
+ if (logger == null)
+ {
+ throw new ArgumentNullException(nameof(logger));
+ }
+
+ if (tagHelper == null)
+ {
+ throw new ArgumentNullException(nameof(tagHelper));
+ }
+
if (logger.IsEnabled(LogLevel.Warning) && PartiallyMatchedAttributes.Any())
{
// Build the list of partial matches that contain attributes not appearing in at least one full match
diff --git a/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/PartialModeMatchLogValuesOfT.cs b/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/PartialModeMatchLogValuesOfT.cs
index 4a3c79629a..6627e71493 100644
--- a/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/PartialModeMatchLogValuesOfT.cs
+++ b/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/PartialModeMatchLogValuesOfT.cs
@@ -4,8 +4,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Microsoft.AspNet.Razor.Runtime.TagHelpers;
-using Microsoft.Framework.Internal;
using Microsoft.Framework.Logging;
namespace Microsoft.AspNet.Mvc.TagHelpers.Internal
@@ -29,8 +27,13 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal
public PartialModeMatchLogValues(
string uniqueId,
string viewPath,
- [NotNull] IEnumerable> partialMatches)
+ IEnumerable> partialMatches)
{
+ if (partialMatches == null)
+ {
+ throw new ArgumentNullException(nameof(partialMatches));
+ }
+
_uniqueId = uniqueId;
_viewPath = viewPath;
_partialMatches = partialMatches;
diff --git a/src/Microsoft.AspNet.Mvc.TagHelpers/TagHelperContentExtensions.cs b/src/Microsoft.AspNet.Mvc.TagHelpers/TagHelperContentExtensions.cs
index 380a52d1fc..dc3e0aa5dc 100644
--- a/src/Microsoft.AspNet.Mvc.TagHelpers/TagHelperContentExtensions.cs
+++ b/src/Microsoft.AspNet.Mvc.TagHelpers/TagHelperContentExtensions.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.Text;
using Microsoft.AspNet.Mvc.Razor;
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
-using Microsoft.Framework.Internal;
using Microsoft.Framework.WebEncoders;
namespace Microsoft.AspNet.Mvc.TagHelpers
@@ -29,11 +29,26 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
/// is written to the .
///
public static TagHelperContent Append(
- [NotNull] this TagHelperContent content,
- [NotNull] IHtmlEncoder encoder,
- [NotNull] Encoding encoding,
+ this TagHelperContent content,
+ IHtmlEncoder encoder,
+ Encoding encoding,
object value)
{
+ if (content == null)
+ {
+ throw new ArgumentNullException(nameof(content));
+ }
+
+ if (encoder == null)
+ {
+ throw new ArgumentNullException(nameof(encoder));
+ }
+
+ if (encoding == null)
+ {
+ throw new ArgumentNullException(nameof(encoding));
+ }
+
using (var writer = new TagHelperContentWrapperTextWriter(encoding, content))
{
RazorPage.WriteTo(writer, encoder, value, escapeQuotes: true);
diff --git a/src/Microsoft.AspNet.Mvc.TagHelpers/TagHelperOutputExtensions.cs b/src/Microsoft.AspNet.Mvc.TagHelpers/TagHelperOutputExtensions.cs
index cb738ba070..55b326a9fd 100644
--- a/src/Microsoft.AspNet.Mvc.TagHelpers/TagHelperOutputExtensions.cs
+++ b/src/Microsoft.AspNet.Mvc.TagHelpers/TagHelperOutputExtensions.cs
@@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.TagHelpers
{
@@ -35,10 +34,25 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
/// attribute order not being maintained.
///
public static void CopyHtmlAttribute(
- [NotNull] this TagHelperOutput tagHelperOutput,
- [NotNull] string attributeName,
- [NotNull] TagHelperContext context)
+ this TagHelperOutput tagHelperOutput,
+ string attributeName,
+ TagHelperContext context)
{
+ if (tagHelperOutput == null)
+ {
+ throw new ArgumentNullException(nameof(tagHelperOutput));
+ }
+
+ if (attributeName == null)
+ {
+ throw new ArgumentNullException(nameof(attributeName));
+ }
+
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
if (!tagHelperOutput.Attributes.ContainsName(attributeName))
{
var copiedAttribute = false;
@@ -77,9 +91,19 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
/// Existing on the given
/// are not overridden; "class" attributes are merged with spaces.
public static void MergeAttributes(
- [NotNull] this TagHelperOutput tagHelperOutput,
- [NotNull] TagBuilder tagBuilder)
+ this TagHelperOutput tagHelperOutput,
+ TagBuilder tagBuilder)
{
+ if (tagHelperOutput == null)
+ {
+ throw new ArgumentNullException(nameof(tagHelperOutput));
+ }
+
+ if (tagBuilder == null)
+ {
+ throw new ArgumentNullException(nameof(tagBuilder));
+ }
+
foreach (var attribute in tagBuilder.Attributes)
{
if (!tagHelperOutput.Attributes.ContainsName(attribute.Key))
@@ -109,9 +133,19 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
/// The this method extends.
/// Attributes to remove.
public static void RemoveRange(
- [NotNull] this TagHelperOutput tagHelperOutput,
- [NotNull] IEnumerable attributes)
+ this TagHelperOutput tagHelperOutput,
+ IEnumerable attributes)
{
+ if (tagHelperOutput == null)
+ {
+ throw new ArgumentNullException(nameof(tagHelperOutput));
+ }
+
+ if (attributes == null)
+ {
+ throw new ArgumentNullException(nameof(attributes));
+ }
+
foreach (var attribute in attributes.ToArray())
{
tagHelperOutput.Attributes.Remove(attribute);
diff --git a/src/Microsoft.AspNet.Mvc.TagHelpers/project.json b/src/Microsoft.AspNet.Mvc.TagHelpers/project.json
index 8c471361a0..4c9e0c730a 100644
--- a/src/Microsoft.AspNet.Mvc.TagHelpers/project.json
+++ b/src/Microsoft.AspNet.Mvc.TagHelpers/project.json
@@ -13,8 +13,7 @@
"Microsoft.Framework.Caching.Memory": "1.0.0-*",
"Microsoft.Framework.FileSystemGlobbing": "1.0.0-*",
"Microsoft.Framework.Logging.Abstractions": { "version": "1.0.0-*", "type": "build" },
- "Microsoft.Framework.PropertyHelper.Sources": { "version": "1.0.0-*", "type": "build" },
- "Microsoft.Framework.NotNullAttribute.Sources": { "version": "1.0.0-*", "type": "build" }
+ "Microsoft.Framework.PropertyHelper.Sources": { "version": "1.0.0-*", "type": "build" }
},
"frameworks": {
"dnx451": { },
diff --git a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/MvcRazorHostTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/MvcRazorHostTest.cs
index edb55b4daa..9d929509e3 100644
--- a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/MvcRazorHostTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/MvcRazorHostTest.cs
@@ -55,14 +55,15 @@ namespace Microsoft.AspNet.Mvc.Razor
// Arrange
var rootedAppPath = $"{rootPrefix}SomeComputer/Location/Project/";
var rootedFilePath = $"{rootPrefix}SomeComputer/Location/Project/src/file.cshtml";
+ var chunkTreeCache = new DefaultChunkTreeCache(new TestFileProvider());
var host = new MvcRazorHost(
- chunkTreeCache: null,
+ chunkTreeCache,
pathNormalizer: new DesignTimeRazorPathNormalizer(rootedAppPath));
var parser = new RazorParser(
host.CodeLanguage.CreateCodeParser(),
host.CreateMarkupParser(),
tagHelperDescriptorResolver: null);
- var chunkInheritanceUtility = new PathValidatingChunkInheritanceUtility(host);
+ var chunkInheritanceUtility = new PathValidatingChunkInheritanceUtility(host, chunkTreeCache);
host.ChunkInheritanceUtility = chunkInheritanceUtility;
// Act
@@ -80,10 +81,11 @@ namespace Microsoft.AspNet.Mvc.Razor
// Arrange
var rootedAppPath = $"{rootPrefix}SomeComputer/Location/Project/";
var rootedFilePath = $"{rootPrefix}SomeComputer/Location/Project/src/file.cshtml";
+ var chunkTreeCache = new DefaultChunkTreeCache(new TestFileProvider());
var host = new MvcRazorHost(
- chunkTreeCache: null,
+ chunkTreeCache,
pathNormalizer: new DesignTimeRazorPathNormalizer(rootedAppPath));
- var chunkInheritanceUtility = new PathValidatingChunkInheritanceUtility(host);
+ var chunkInheritanceUtility = new PathValidatingChunkInheritanceUtility(host, chunkTreeCache);
var codeGeneratorContext = new CodeGeneratorContext(
new ChunkGeneratorContext(
host,
@@ -371,8 +373,9 @@ namespace Microsoft.AspNet.Mvc.Razor
RunDesignTimeTest(host, "Model", expectedLineMappings);
}
- private static void RunRuntimeTest(MvcRazorHost host,
- string testName)
+ private static void RunRuntimeTest(
+ MvcRazorHost host,
+ string testName)
{
var inputFile = "TestFiles/Input/" + testName + ".cshtml";
var outputFile = "TestFiles/Output/Runtime/" + testName + ".cs";
@@ -396,9 +399,10 @@ namespace Microsoft.AspNet.Mvc.Razor
#endif
}
- private static void RunDesignTimeTest(MvcRazorHost host,
- string testName,
- IEnumerable expectedLineMappings)
+ private static void RunDesignTimeTest(
+ MvcRazorHost host,
+ string testName,
+ IEnumerable expectedLineMappings)
{
var inputFile = "TestFiles/Input/" + testName + ".cshtml";
var outputFile = "TestFiles/Output/DesignTime/" + testName + ".cs";
@@ -457,13 +461,14 @@ namespace Microsoft.AspNet.Mvc.Razor
#endif
}
- private static LineMapping BuildLineMapping(int documentAbsoluteIndex,
- int documentLineIndex,
- int documentCharacterIndex,
- int generatedAbsoluteIndex,
- int generatedLineIndex,
- int generatedCharacterIndex,
- int contentLength)
+ private static LineMapping BuildLineMapping(
+ int documentAbsoluteIndex,
+ int documentLineIndex,
+ int documentCharacterIndex,
+ int generatedAbsoluteIndex,
+ int generatedLineIndex,
+ int generatedCharacterIndex,
+ int contentLength)
{
var documentLocation = new SourceLocation(documentAbsoluteIndex,
documentLineIndex,
@@ -479,14 +484,14 @@ namespace Microsoft.AspNet.Mvc.Razor
private class PathValidatingChunkInheritanceUtility : ChunkInheritanceUtility
{
- public PathValidatingChunkInheritanceUtility(MvcRazorHost razorHost)
- : base(razorHost, chunkTreeCache: null, defaultInheritedChunks: new Chunk[0])
+ public PathValidatingChunkInheritanceUtility(MvcRazorHost razorHost, IChunkTreeCache chunkTreeCache)
+ : base(razorHost, chunkTreeCache, defaultInheritedChunks: new Chunk[0])
{
}
public string InheritedChunkTreePagePath { get; private set; }
- public override IReadOnlyList GetInheritedChunkTreeResults([NotNull] string pagePath)
+ public override IReadOnlyList GetInheritedChunkTreeResults(string pagePath)
{
InheritedChunkTreePagePath = pagePath;
@@ -522,10 +527,11 @@ namespace Microsoft.AspNet.Mvc.Razor
{
private readonly GeneratedTagHelperAttributeContext _tagHelperAttributeContext;
- public TestCSharpCodeGenerator(CodeGeneratorContext context,
- string defaultModel,
- string activateAttribute,
- GeneratedTagHelperAttributeContext tagHelperAttributeContext)
+ public TestCSharpCodeGenerator(
+ CodeGeneratorContext context,
+ string defaultModel,
+ string activateAttribute,
+ GeneratedTagHelperAttributeContext tagHelperAttributeContext)
: base(context, defaultModel, activateAttribute, tagHelperAttributeContext)
{
_tagHelperAttributeContext = tagHelperAttributeContext;
diff --git a/test/Microsoft.AspNet.Mvc.Razor.Test/RazorPageTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Test/RazorPageTest.cs
index c2bc586d16..5932347e00 100644
--- a/test/Microsoft.AspNet.Mvc.Razor.Test/RazorPageTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Razor.Test/RazorPageTest.cs
@@ -23,9 +23,8 @@ namespace Microsoft.AspNet.Mvc.Razor
{
public class RazorPageTest
{
-#pragma warning disable 1998
- private readonly RenderAsyncDelegate _nullRenderAsyncDelegate = async writer => { };
-#pragma warning restore 1998
+ private readonly RenderAsyncDelegate _nullRenderAsyncDelegate = writer => Task.FromResult(0);
+ private readonly Func NullAsyncWrite = CreateAsyncWriteDelegate(string.Empty);
[Fact]
public async Task WritingScopesRedirectContentWrittenToViewContextWriter()
@@ -304,7 +303,7 @@ namespace Microsoft.AspNet.Mvc.Razor
{
{ "baz", _nullRenderAsyncDelegate }
};
- page.RenderBodyDelegateAsync = CreateBodyAction("body-content");
+ page.RenderBodyDelegateAsync = CreateAsyncWriteDelegate("body-content");
// Act
await page.ExecuteAsync();
@@ -328,7 +327,7 @@ namespace Microsoft.AspNet.Mvc.Razor
{
{ "baz", _nullRenderAsyncDelegate }
};
- page.RenderBodyDelegateAsync = CreateBodyAction("body-content");
+ page.RenderBodyDelegateAsync = CreateAsyncWriteDelegate("body-content");
// Act
await page.ExecuteAsync();
@@ -341,7 +340,7 @@ namespace Microsoft.AspNet.Mvc.Razor
public async Task RenderSection_ThrowsIfSectionIsRenderedMoreThanOnce()
{
// Arrange
- var expected = new HelperResult(asyncAction: null);
+ var expected = new HelperResult(NullAsyncWrite);
var page = CreatePage(v =>
{
v.Path = "/Views/TestPath/Test.cshtml";
@@ -365,7 +364,7 @@ namespace Microsoft.AspNet.Mvc.Razor
public async Task RenderSectionAsync_ThrowsIfSectionIsRenderedMoreThanOnce()
{
// Arrange
- var expected = new HelperResult(asyncAction: null);
+ var expected = new HelperResult(NullAsyncWrite);
var page = CreatePage(async v =>
{
v.Path = "/Views/TestPath/Test.cshtml";
@@ -389,7 +388,7 @@ namespace Microsoft.AspNet.Mvc.Razor
public async Task RenderSectionAsync_ThrowsIfSectionIsRenderedMoreThanOnce_WithSyncMethod()
{
// Arrange
- var expected = new HelperResult(asyncAction: null);
+ var expected = new HelperResult(NullAsyncWrite);
var page = CreatePage(async v =>
{
v.Path = "/Views/TestPath/Test.cshtml";
@@ -413,7 +412,7 @@ namespace Microsoft.AspNet.Mvc.Razor
public async Task RenderSectionAsync_ThrowsIfNotInvokedFromLayoutPage()
{
// Arrange
- var expected = new HelperResult(asyncAction: null);
+ var expected = new HelperResult(NullAsyncWrite);
var page = CreatePage(async v =>
{
v.Path = "/Views/TestPath/Test.cshtml";
@@ -437,7 +436,7 @@ namespace Microsoft.AspNet.Mvc.Razor
{
});
page.Path = path;
- page.RenderBodyDelegateAsync = CreateBodyAction("some content");
+ page.RenderBodyDelegateAsync = CreateAsyncWriteDelegate("some content");
// Act
await page.ExecuteAsync();
@@ -457,7 +456,7 @@ namespace Microsoft.AspNet.Mvc.Razor
{
});
page.Path = path;
- page.RenderBodyDelegateAsync = CreateBodyAction("some content");
+ page.RenderBodyDelegateAsync = CreateAsyncWriteDelegate("some content");
page.PreviousSectionWriters = new Dictionary
{
{ sectionName, _nullRenderAsyncDelegate }
@@ -483,7 +482,7 @@ namespace Microsoft.AspNet.Mvc.Razor
v.RenderSection(sectionA);
v.RenderSection(sectionB);
});
- page.RenderBodyDelegateAsync = CreateBodyAction("some content");
+ page.RenderBodyDelegateAsync = CreateAsyncWriteDelegate("some content");
page.PreviousSectionWriters = new Dictionary
{
{ sectionA, _nullRenderAsyncDelegate },
@@ -517,7 +516,7 @@ namespace Microsoft.AspNet.Mvc.Razor
v.Write(v.RenderSection("footer"));
v.WriteLiteral("Layout end");
});
- page.RenderBodyDelegateAsync = CreateBodyAction("body content" + Environment.NewLine);
+ page.RenderBodyDelegateAsync = CreateAsyncWriteDelegate("body content" + Environment.NewLine);
page.PreviousSectionWriters = new Dictionary
{
{
@@ -837,7 +836,7 @@ namespace Microsoft.AspNet.Mvc.Razor
var executionContext = new TagHelperExecutionContext(
"p",
tagMode: TagMode.StartTagAndEndTag,
- items: null,
+ items: new Dictionary