`throw new ArgumentNullException(...)` -> `[NotNull]`
- add `[NotNull]` in some `public` or `protected` callers as well - add `[NotNull]` in `SeekableTextReader` constructors - add `where TSymbolType : struct` to replace incorrect `null` checks - remove `T` type parameters in changed files e.g. change to `TWriter` - remove tests of removed code nits: - change `TextReaderExtensions` to consistently call other extensions as statics - wrap some long doc comments
This commit is contained in:
parent
42552c982d
commit
cef0971d3e
|
|
@ -1,12 +1,17 @@
|
|||
// 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;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Generator
|
||||
{
|
||||
public class CSharpRazorCodeGenerator : RazorCodeGenerator
|
||||
{
|
||||
public CSharpRazorCodeGenerator(string className, string rootNamespaceName, string sourceFileName, RazorEngineHost host)
|
||||
public CSharpRazorCodeGenerator(
|
||||
string className,
|
||||
[NotNull] string rootNamespaceName,
|
||||
string sourceFileName,
|
||||
[NotNull] RazorEngineHost host)
|
||||
: base(className, rootNamespaceName, sourceFileName, host)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
using System;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
||||
{
|
||||
|
|
@ -19,13 +20,8 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
|||
}
|
||||
|
||||
// Special case for statement padding to account for brace positioning in the editor.
|
||||
public string BuildStatementPadding(Span target)
|
||||
public string BuildStatementPadding([NotNull] Span target)
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
throw new ArgumentNullException("target");
|
||||
}
|
||||
|
||||
var padding = CalculatePadding(target, generatedStart: 0);
|
||||
|
||||
// We treat statement padding specially so for brace positioning, so that in the following example:
|
||||
|
|
@ -52,20 +48,15 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
|||
return BuildExpressionPadding(target, generatedStart: 0);
|
||||
}
|
||||
|
||||
public string BuildExpressionPadding(Span target, int generatedStart)
|
||||
public string BuildExpressionPadding([NotNull] Span target, int generatedStart)
|
||||
{
|
||||
var padding = CalculatePadding(target, generatedStart);
|
||||
|
||||
return BuildPaddingInternal(padding);
|
||||
}
|
||||
|
||||
internal int CalculatePadding(Span target, int generatedStart)
|
||||
internal int CalculatePadding([NotNull] Span target, int generatedStart)
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
throw new ArgumentNullException("target");
|
||||
}
|
||||
|
||||
int padding;
|
||||
|
||||
padding = CollectSpacesAndTabs(target, _host.TabSize) - generatedStart;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
// 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;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
||||
{
|
||||
public class CSharpBaseTypeVisitor : CodeVisitor<CSharpCodeWriter>
|
||||
{
|
||||
public CSharpBaseTypeVisitor(CSharpCodeWriter writer, CodeBuilderContext context)
|
||||
public CSharpBaseTypeVisitor([NotNull] CSharpCodeWriter writer, [NotNull] CodeBuilderContext context)
|
||||
: base(writer, context)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
public string CurrentBaseType { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -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.Globalization;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
||||
{
|
||||
|
|
@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
|||
private CSharpPaddingBuilder _paddingBuilder;
|
||||
private CSharpTagHelperCodeRenderer _tagHelperCodeRenderer;
|
||||
|
||||
public CSharpCodeVisitor(CSharpCodeWriter writer, CodeBuilderContext context)
|
||||
public CSharpCodeVisitor([NotNull] CSharpCodeWriter writer, [NotNull] CodeBuilderContext context)
|
||||
: base(writer, context)
|
||||
{
|
||||
_paddingBuilder = new CSharpPaddingBuilder(context.Host);
|
||||
|
|
@ -34,13 +34,9 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
|||
|
||||
return _tagHelperCodeRenderer;
|
||||
}
|
||||
[param: NotNull]
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(TagHelperRenderer));
|
||||
}
|
||||
|
||||
_tagHelperCodeRenderer = value;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
||||
{
|
||||
|
|
@ -32,8 +33,8 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
|||
/// <see cref="CSharpTagHelperAttributeValueVisitor"/> is writing the value.
|
||||
/// </param>
|
||||
public CSharpTagHelperAttributeValueVisitor(
|
||||
CSharpCodeWriter writer,
|
||||
CodeBuilderContext context,
|
||||
[NotNull] CSharpCodeWriter writer,
|
||||
[NotNull] CodeBuilderContext context,
|
||||
string attributeTypeName)
|
||||
: base(writer, context)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
||||
{
|
||||
|
|
@ -13,7 +14,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
|||
|
||||
private bool _foundTagHelpers;
|
||||
|
||||
public CSharpUsingVisitor(CSharpCodeWriter writer, CodeBuilderContext context)
|
||||
public CSharpUsingVisitor([NotNull] CSharpCodeWriter writer, [NotNull] CodeBuilderContext context)
|
||||
: base(writer, context)
|
||||
{
|
||||
ImportedUsings = new List<string>();
|
||||
|
|
|
|||
|
|
@ -1,42 +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 System.Collections.Generic;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Generator.Compiler
|
||||
{
|
||||
public abstract class ChunkVisitor<T> : IChunkVisitor where T : CodeWriter
|
||||
public abstract class ChunkVisitor<TWriter> : IChunkVisitor
|
||||
where TWriter : CodeWriter
|
||||
{
|
||||
public ChunkVisitor(T writer, CodeBuilderContext context)
|
||||
public ChunkVisitor([NotNull] TWriter writer, [NotNull] CodeBuilderContext context)
|
||||
{
|
||||
Writer = writer;
|
||||
Context = context;
|
||||
}
|
||||
|
||||
protected T Writer { get; private set; }
|
||||
protected TWriter Writer { get; private set; }
|
||||
protected CodeBuilderContext Context { get; private set; }
|
||||
|
||||
public void Accept(IList<Chunk> chunks)
|
||||
public void Accept([NotNull] IList<Chunk> chunks)
|
||||
{
|
||||
if (chunks == null)
|
||||
{
|
||||
throw new ArgumentNullException("chunks");
|
||||
}
|
||||
|
||||
foreach (Chunk chunk in chunks)
|
||||
{
|
||||
Accept(chunk);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Accept(Chunk chunk)
|
||||
public virtual void Accept([NotNull] Chunk chunk)
|
||||
{
|
||||
if (chunk == null)
|
||||
{
|
||||
throw new ArgumentNullException("chunk");
|
||||
}
|
||||
|
||||
if (chunk is LiteralChunk)
|
||||
{
|
||||
Visit((LiteralChunk)chunk);
|
||||
|
|
|
|||
|
|
@ -1,13 +1,17 @@
|
|||
// 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;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Generator.Compiler
|
||||
{
|
||||
public class CodeVisitor<T> : ChunkVisitor<T> where T : CodeWriter
|
||||
public class CodeVisitor<TWriter> : ChunkVisitor<TWriter>
|
||||
where TWriter : CodeWriter
|
||||
{
|
||||
public CodeVisitor(T writer, CodeBuilderContext context)
|
||||
public CodeVisitor([NotNull] TWriter writer, [NotNull] CodeBuilderContext context)
|
||||
: base(writer, context)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Visit(LiteralChunk chunk)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
using System;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Generator
|
||||
{
|
||||
|
|
@ -11,20 +12,16 @@ namespace Microsoft.AspNet.Razor.Generator
|
|||
{
|
||||
private CodeGeneratorContext _context;
|
||||
|
||||
protected RazorCodeGenerator(string className, string rootNamespaceName, string sourceFileName, RazorEngineHost host)
|
||||
protected RazorCodeGenerator(
|
||||
string className,
|
||||
[NotNull] string rootNamespaceName,
|
||||
string sourceFileName,
|
||||
[NotNull] RazorEngineHost host)
|
||||
{
|
||||
if (string.IsNullOrEmpty(className))
|
||||
{
|
||||
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "className");
|
||||
}
|
||||
if (rootNamespaceName == null)
|
||||
{
|
||||
throw new ArgumentNullException("rootNamespaceName");
|
||||
}
|
||||
if (host == null)
|
||||
{
|
||||
throw new ArgumentNullException("host");
|
||||
}
|
||||
|
||||
ClassName = className;
|
||||
RootNamespaceName = rootNamespaceName;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
{
|
||||
[SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes", Justification = "All generic type parameters are required")]
|
||||
public abstract class LanguageCharacteristics<TTokenizer, TSymbol, TSymbolType>
|
||||
where TSymbolType : struct
|
||||
where TTokenizer : Tokenizer<TSymbol, TSymbolType>
|
||||
where TSymbol : SymbolBase<TSymbolType>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Parser
|
||||
{
|
||||
|
|
@ -13,12 +14,8 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
private Stack<BlockBuilder> _blocks = new Stack<BlockBuilder>();
|
||||
private Action<SpanBuilder, SourceLocation, string> _markupSpanFactory;
|
||||
|
||||
protected MarkupRewriter(Action<SpanBuilder, SourceLocation, string> markupSpanFactory)
|
||||
protected MarkupRewriter([NotNull] Action<SpanBuilder, SourceLocation, string> markupSpanFactory)
|
||||
{
|
||||
if (markupSpanFactory == null)
|
||||
{
|
||||
throw new ArgumentNullException("markupSpanFactory");
|
||||
}
|
||||
_markupSpanFactory = markupSpanFactory;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +1,14 @@
|
|||
// 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.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Parser
|
||||
{
|
||||
public static class ParserVisitorExtensions
|
||||
{
|
||||
public static void Visit(this ParserVisitor self, ParserResults result)
|
||||
public static void Visit([NotNull] this ParserVisitor self, [NotNull] ParserResults result)
|
||||
{
|
||||
if (self == null)
|
||||
{
|
||||
throw new ArgumentNullException("self");
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
throw new ArgumentNullException("result");
|
||||
}
|
||||
|
||||
result.Document.Accept(self);
|
||||
foreach (RazorError error in result.ParserErrors)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,63 +5,47 @@ using System;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Parser
|
||||
{
|
||||
internal static class TextReaderExtensions
|
||||
{
|
||||
public static string ReadUntil(this TextReader reader, char terminator)
|
||||
public static string ReadUntil([NotNull] this TextReader reader, char terminator)
|
||||
{
|
||||
return ReadUntil(reader, terminator, inclusive: false);
|
||||
}
|
||||
|
||||
public static string ReadUntil(this TextReader reader, char terminator, bool inclusive)
|
||||
public static string ReadUntil([NotNull] this TextReader reader, char terminator, bool inclusive)
|
||||
{
|
||||
if (reader == null)
|
||||
{
|
||||
throw new ArgumentNullException("reader");
|
||||
}
|
||||
|
||||
// Rather not allocate an array to use ReadUntil(TextReader, params char[]) so we'll just call the predicate version directly
|
||||
return reader.ReadUntil(c => c == terminator, inclusive);
|
||||
return ReadUntil(reader, c => c == terminator, inclusive);
|
||||
}
|
||||
|
||||
public static string ReadUntil(this TextReader reader, params char[] terminators)
|
||||
public static string ReadUntil([NotNull] this TextReader reader, [NotNull] params char[] terminators)
|
||||
{
|
||||
// NOTE: Using named parameters would be difficult here, hence the inline comment
|
||||
return reader.ReadUntil(inclusive: false, terminators: terminators);
|
||||
return ReadUntil(reader, inclusive: false, terminators: terminators);
|
||||
}
|
||||
|
||||
public static string ReadUntil(this TextReader reader, bool inclusive, params char[] terminators)
|
||||
public static string ReadUntil(
|
||||
[NotNull] this TextReader reader,
|
||||
bool inclusive,
|
||||
[NotNull] params char[] terminators)
|
||||
{
|
||||
if (reader == null)
|
||||
{
|
||||
throw new ArgumentNullException("reader");
|
||||
}
|
||||
if (terminators == null)
|
||||
{
|
||||
throw new ArgumentNullException("terminators");
|
||||
}
|
||||
|
||||
return reader.ReadUntil(c => terminators.Any(tc => tc == c), inclusive: inclusive);
|
||||
return ReadUntil(reader, c => terminators.Any(tc => tc == c), inclusive: inclusive);
|
||||
}
|
||||
|
||||
public static string ReadUntil(this TextReader reader, Predicate<char> condition)
|
||||
public static string ReadUntil([NotNull] this TextReader reader, [NotNull] Predicate<char> condition)
|
||||
{
|
||||
return reader.ReadUntil(condition, inclusive: false);
|
||||
return ReadUntil(reader, condition, inclusive: false);
|
||||
}
|
||||
|
||||
public static string ReadUntil(this TextReader reader, Predicate<char> condition, bool inclusive)
|
||||
public static string ReadUntil(
|
||||
[NotNull] this TextReader reader,
|
||||
[NotNull] Predicate<char> condition,
|
||||
bool inclusive)
|
||||
{
|
||||
if (reader == null)
|
||||
{
|
||||
throw new ArgumentNullException("reader");
|
||||
}
|
||||
if (condition == null)
|
||||
{
|
||||
throw new ArgumentNullException("condition");
|
||||
}
|
||||
|
||||
var builder = new StringBuilder();
|
||||
var ch = -1;
|
||||
while ((ch = reader.Peek()) != -1 && !condition((char)ch))
|
||||
|
|
@ -78,33 +62,27 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
return builder.ToString();
|
||||
}
|
||||
|
||||
public static string ReadWhile(this TextReader reader, Predicate<char> condition)
|
||||
public static string ReadWhile([NotNull] this TextReader reader, [NotNull] Predicate<char> condition)
|
||||
{
|
||||
return reader.ReadWhile(condition, inclusive: false);
|
||||
return ReadWhile(reader, condition, inclusive: false);
|
||||
}
|
||||
|
||||
public static string ReadWhile(this TextReader reader, Predicate<char> condition, bool inclusive)
|
||||
public static string ReadWhile(
|
||||
[NotNull] this TextReader reader,
|
||||
[NotNull] Predicate<char> condition,
|
||||
bool inclusive)
|
||||
{
|
||||
if (reader == null)
|
||||
{
|
||||
throw new ArgumentNullException("reader");
|
||||
}
|
||||
if (condition == null)
|
||||
{
|
||||
throw new ArgumentNullException("condition");
|
||||
}
|
||||
|
||||
return reader.ReadUntil(ch => !condition(ch), inclusive);
|
||||
return ReadUntil(reader, ch => !condition(ch), inclusive);
|
||||
}
|
||||
|
||||
public static string ReadWhiteSpace(this TextReader reader)
|
||||
public static string ReadWhiteSpace([NotNull] this TextReader reader)
|
||||
{
|
||||
return reader.ReadWhile(c => Char.IsWhiteSpace(c));
|
||||
return ReadWhile(reader, c => Char.IsWhiteSpace(c));
|
||||
}
|
||||
|
||||
public static string ReadUntilWhiteSpace(this TextReader reader)
|
||||
public static string ReadUntilWhiteSpace([NotNull] this TextReader reader)
|
||||
{
|
||||
return reader.ReadUntil(c => Char.IsWhiteSpace(c));
|
||||
return ReadUntil(reader, c => Char.IsWhiteSpace(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ using Microsoft.AspNet.Razor.Utils;
|
|||
namespace Microsoft.AspNet.Razor.Parser
|
||||
{
|
||||
public abstract partial class TokenizerBackedParser<TTokenizer, TSymbol, TSymbolType> : ParserBase
|
||||
where TSymbolType : struct
|
||||
where TTokenizer : Tokenizer<TSymbol, TSymbolType>
|
||||
where TSymbol : SymbolBase<TSymbolType>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
{
|
||||
[SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes", Justification = "All generic type parameters are required")]
|
||||
public abstract partial class TokenizerBackedParser<TTokenizer, TSymbol, TSymbolType> : ParserBase
|
||||
where TSymbolType : struct
|
||||
where TTokenizer : Tokenizer<TSymbol, TSymbolType>
|
||||
where TSymbol : SymbolBase<TSymbolType>
|
||||
{
|
||||
|
|
@ -104,7 +105,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
|||
PutBack(symbols[i]);
|
||||
}
|
||||
|
||||
// The PutBacks above will set CurrentSymbol to null. EnsureCurrent will set our CurrentSymbol to the
|
||||
// The PutBacks above will set CurrentSymbol to null. EnsureCurrent will set our CurrentSymbol to the
|
||||
// next symbol.
|
||||
EnsureCurrent();
|
||||
|
||||
|
|
|
|||
|
|
@ -5,12 +5,14 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Parser
|
||||
{
|
||||
internal class WhiteSpaceRewriter : MarkupRewriter
|
||||
{
|
||||
public WhiteSpaceRewriter(Action<SpanBuilder, SourceLocation, string> markupSpanFactory) : base(markupSpanFactory)
|
||||
public WhiteSpaceRewriter([NotNull] Action<SpanBuilder, SourceLocation, string> markupSpanFactory)
|
||||
: base(markupSpanFactory)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ using System.IO;
|
|||
using Microsoft.AspNet.Razor.Editor;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Text;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Razor
|
||||
{
|
||||
|
|
@ -67,12 +68,8 @@ namespace Microsoft.AspNet.Razor
|
|||
/// </summary>
|
||||
/// <param name="host">The <see cref="RazorEngineHost"/> which defines the environment in which the generated code will live. <see cref="F:RazorEngineHost.DesignTimeMode"/> should be set if design-time code mappings are desired</param>
|
||||
/// <param name="sourceFileName">The physical path to use in line pragmas</param>
|
||||
public RazorEditorParser(RazorEngineHost host, string sourceFileName)
|
||||
public RazorEditorParser([NotNull] RazorEngineHost host, string sourceFileName)
|
||||
{
|
||||
if (host == null)
|
||||
{
|
||||
throw new ArgumentNullException("host");
|
||||
}
|
||||
if (string.IsNullOrEmpty(sourceFileName))
|
||||
{
|
||||
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "sourceFileName");
|
||||
|
|
|
|||
|
|
@ -51,24 +51,17 @@ namespace Microsoft.AspNet.Razor
|
|||
/// Creates a host which uses the specified code language and the HTML markup language
|
||||
/// </summary>
|
||||
/// <param name="codeLanguage">The code language to use</param>
|
||||
public RazorEngineHost(RazorCodeLanguage codeLanguage)
|
||||
public RazorEngineHost([NotNull] RazorCodeLanguage codeLanguage)
|
||||
: this(codeLanguage, () => new HtmlMarkupParser())
|
||||
{
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Justification = "The code path is safe, it is a property setter and not dependent on other state")]
|
||||
public RazorEngineHost(RazorCodeLanguage codeLanguage, Func<ParserBase> markupParserFactory)
|
||||
public RazorEngineHost(
|
||||
[NotNull] RazorCodeLanguage codeLanguage,
|
||||
[NotNull] Func<ParserBase> markupParserFactory)
|
||||
: this()
|
||||
{
|
||||
if (codeLanguage == null)
|
||||
{
|
||||
throw new ArgumentNullException("codeLanguage");
|
||||
}
|
||||
if (markupParserFactory == null)
|
||||
{
|
||||
throw new ArgumentNullException("markupParserFactory");
|
||||
}
|
||||
|
||||
CodeLanguage = codeLanguage;
|
||||
_markupParserFactory = markupParserFactory;
|
||||
}
|
||||
|
|
@ -173,8 +166,9 @@ namespace Microsoft.AspNet.Razor
|
|||
/// <param name="incomingRazorParser">The <see cref="RazorParser"/></param>
|
||||
/// <param name="sourceFileName">The file name of the Razor file being parsed.</param>
|
||||
/// <returns>Either the same code parser, after modifications, or a different code parser.</returns>
|
||||
public virtual RazorParser DecorateRazorParser([NotNull] RazorParser incomingRazorParser,
|
||||
string sourceFileName)
|
||||
public virtual RazorParser DecorateRazorParser(
|
||||
[NotNull] RazorParser incomingRazorParser,
|
||||
string sourceFileName)
|
||||
{
|
||||
return incomingRazorParser;
|
||||
}
|
||||
|
|
@ -184,12 +178,8 @@ namespace Microsoft.AspNet.Razor
|
|||
/// </summary>
|
||||
/// <param name="incomingCodeParser">The code parser</param>
|
||||
/// <returns>Either the same code parser, after modifications, or a different code parser</returns>
|
||||
public virtual ParserBase DecorateCodeParser(ParserBase incomingCodeParser)
|
||||
public virtual ParserBase DecorateCodeParser([NotNull] ParserBase incomingCodeParser)
|
||||
{
|
||||
if (incomingCodeParser == null)
|
||||
{
|
||||
throw new ArgumentNullException("incomingCodeParser");
|
||||
}
|
||||
return incomingCodeParser;
|
||||
}
|
||||
|
||||
|
|
@ -198,12 +188,8 @@ namespace Microsoft.AspNet.Razor
|
|||
/// </summary>
|
||||
/// <param name="incomingMarkupParser">The markup parser</param>
|
||||
/// <returns>Either the same markup parser, after modifications, or a different markup parser</returns>
|
||||
public virtual ParserBase DecorateMarkupParser(ParserBase incomingMarkupParser)
|
||||
public virtual ParserBase DecorateMarkupParser([NotNull] ParserBase incomingMarkupParser)
|
||||
{
|
||||
if (incomingMarkupParser == null)
|
||||
{
|
||||
throw new ArgumentNullException("incomingMarkupParser");
|
||||
}
|
||||
return incomingMarkupParser;
|
||||
}
|
||||
|
||||
|
|
@ -212,12 +198,8 @@ namespace Microsoft.AspNet.Razor
|
|||
/// </summary>
|
||||
/// <param name="incomingCodeGenerator">The code generator</param>
|
||||
/// <returns>Either the same code generator, after modifications, or a different code generator</returns>
|
||||
public virtual RazorCodeGenerator DecorateCodeGenerator(RazorCodeGenerator incomingCodeGenerator)
|
||||
public virtual RazorCodeGenerator DecorateCodeGenerator([NotNull] RazorCodeGenerator incomingCodeGenerator)
|
||||
{
|
||||
if (incomingCodeGenerator == null)
|
||||
{
|
||||
throw new ArgumentNullException("incomingCodeGenerator");
|
||||
}
|
||||
return incomingCodeGenerator;
|
||||
}
|
||||
|
||||
|
|
@ -226,12 +208,10 @@ namespace Microsoft.AspNet.Razor
|
|||
/// </summary>
|
||||
/// <param name="incomingBuilder">The code builder</param>
|
||||
/// <returns>Either the same code builder, after modifications, or a different code builder.</returns>
|
||||
public virtual CodeBuilder DecorateCodeBuilder(CodeBuilder incomingBuilder, CodeBuilderContext context)
|
||||
public virtual CodeBuilder DecorateCodeBuilder(
|
||||
[NotNull] CodeBuilder incomingBuilder,
|
||||
CodeBuilderContext context)
|
||||
{
|
||||
if (incomingBuilder == null)
|
||||
{
|
||||
throw new ArgumentNullException("incomingBuilder");
|
||||
}
|
||||
return incomingBuilder;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
|
|
@ -28,14 +27,11 @@ namespace Microsoft.AspNet.Razor
|
|||
/// <summary>
|
||||
/// Constructs a new RazorTemplateEngine with the specified host
|
||||
/// </summary>
|
||||
/// <param name="host">The host which defines the environment in which the generated template code will live</param>
|
||||
public RazorTemplateEngine(RazorEngineHost host)
|
||||
/// <param name="host">
|
||||
/// The host which defines the environment in which the generated template code will live.
|
||||
/// </param>
|
||||
public RazorTemplateEngine([NotNull] RazorEngineHost host)
|
||||
{
|
||||
if (host == null)
|
||||
{
|
||||
throw new ArgumentNullException("host");
|
||||
}
|
||||
|
||||
Host = host;
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +40,7 @@ namespace Microsoft.AspNet.Razor
|
|||
/// </summary>
|
||||
public RazorEngineHost Host { get; }
|
||||
|
||||
public ParserResults ParseTemplate(ITextBuffer input)
|
||||
public ParserResults ParseTemplate([NotNull] ITextBuffer input)
|
||||
{
|
||||
return ParseTemplate(input, cancelToken: null);
|
||||
}
|
||||
|
|
@ -53,29 +49,32 @@ namespace Microsoft.AspNet.Razor
|
|||
/// Parses the template specified by the TextBuffer and returns it's result
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// IMPORTANT: This does NOT need to be called before GeneratedCode! GenerateCode will automatically
|
||||
/// parse the document first.
|
||||
///
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The cancel token provided can be used to cancel the parse. However, please note
|
||||
/// that the parse occurs _synchronously_, on the callers thread. This parameter is
|
||||
/// provided so that if the caller is in a background thread with a CancellationToken,
|
||||
/// it can pass it along to the parser.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <param name="input">The input text to parse</param>
|
||||
/// <param name="cancelToken">A token used to cancel the parser</param>
|
||||
/// <returns>The resulting parse tree</returns>
|
||||
/// <param name="input">The input text to parse.</param>
|
||||
/// <param name="cancelToken">A token used to cancel the parser.</param>
|
||||
/// <returns>The resulting parse tree.</returns>
|
||||
[SuppressMessage(
|
||||
"Microsoft.Reliability", "CA2000:Dispose objects before losing scope",
|
||||
Justification = "Input object would be disposed if we dispose the wrapper. We don't own the input so " +
|
||||
"we don't want to dispose it")]
|
||||
public ParserResults ParseTemplate(ITextBuffer input, CancellationToken? cancelToken)
|
||||
public ParserResults ParseTemplate([NotNull] ITextBuffer input, CancellationToken? cancelToken)
|
||||
{
|
||||
return ParseTemplateCore(input.ToDocument(), sourceFileName: null, cancelToken: cancelToken);
|
||||
}
|
||||
|
||||
// See ParseTemplate(ITextBuffer, CancellationToken?),
|
||||
// this overload simply wraps a TextReader in a TextBuffer (see ITextBuffer and BufferingTextReader)
|
||||
public ParserResults ParseTemplate(TextReader input, string sourceFileName)
|
||||
public ParserResults ParseTemplate([NotNull] TextReader input, string sourceFileName)
|
||||
{
|
||||
return ParseTemplateCore(new SeekableTextReader(input), sourceFileName, cancelToken: null);
|
||||
}
|
||||
|
|
@ -85,13 +84,13 @@ namespace Microsoft.AspNet.Razor
|
|||
"CA2000:Dispose objects before losing scope",
|
||||
Justification = "Input object would be disposed if we dispose the wrapper. We don't own the input so " +
|
||||
"we don't want to dispose it")]
|
||||
public ParserResults ParseTemplate(TextReader input, CancellationToken? cancelToken)
|
||||
public ParserResults ParseTemplate([NotNull] TextReader input, CancellationToken? cancelToken)
|
||||
{
|
||||
return ParseTemplateCore(new SeekableTextReader(input), sourceFileName: null, cancelToken: cancelToken);
|
||||
}
|
||||
|
||||
protected internal virtual ParserResults ParseTemplateCore(
|
||||
ITextDocument input,
|
||||
[NotNull] ITextDocument input,
|
||||
string sourceFileName,
|
||||
CancellationToken? cancelToken)
|
||||
{
|
||||
|
|
@ -101,12 +100,12 @@ namespace Microsoft.AspNet.Razor
|
|||
return parser.Parse(input);
|
||||
}
|
||||
|
||||
public GeneratorResults GenerateCode(ITextBuffer input)
|
||||
public GeneratorResults GenerateCode([NotNull] ITextBuffer input)
|
||||
{
|
||||
return GenerateCode(input, className: null, rootNamespace: null, sourceFileName: null, cancelToken: null);
|
||||
}
|
||||
|
||||
public GeneratorResults GenerateCode(ITextBuffer input, CancellationToken? cancelToken)
|
||||
public GeneratorResults GenerateCode([NotNull] ITextBuffer input, CancellationToken? cancelToken)
|
||||
{
|
||||
return GenerateCode(
|
||||
input,
|
||||
|
|
@ -116,7 +115,11 @@ namespace Microsoft.AspNet.Razor
|
|||
cancelToken: cancelToken);
|
||||
}
|
||||
|
||||
public GeneratorResults GenerateCode(ITextBuffer input, string className, string rootNamespace, string sourceFileName)
|
||||
public GeneratorResults GenerateCode(
|
||||
[NotNull] ITextBuffer input,
|
||||
string className,
|
||||
string rootNamespace,
|
||||
string sourceFileName)
|
||||
{
|
||||
return GenerateCode(input, className, rootNamespace, sourceFileName, cancelToken: null);
|
||||
}
|
||||
|
|
@ -125,22 +128,34 @@ namespace Microsoft.AspNet.Razor
|
|||
/// Parses the template specified by the TextBuffer, generates code for it, and returns the constructed code.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// The cancel token provided can be used to cancel the parse. However, please note
|
||||
/// that the parse occurs _synchronously_, on the callers thread. This parameter is
|
||||
/// provided so that if the caller is in a background thread with a CancellationToken,
|
||||
/// it can pass it along to the parser.
|
||||
///
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The className, rootNamespace and sourceFileName parameters are optional and override the default
|
||||
/// specified by the Host. For example, the WebPageRazorHost in System.Web.WebPages.Razor configures the
|
||||
/// Class Name, Root Namespace and Source File Name based on the virtual path of the page being compiled.
|
||||
/// However, the built-in RazorEngineHost class uses constant defaults, so the caller will likely want to
|
||||
/// change them using these parameters
|
||||
/// change them using these parameters.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <param name="input">The input text to parse</param>
|
||||
/// <param name="cancelToken">A token used to cancel the parser</param>
|
||||
/// <param name="className">The name of the generated class, overriding whatever is specified in the Host. The default value (defined in the Host) can be used by providing null for this argument</param>
|
||||
/// <param name="rootNamespace">The namespace in which the generated class will reside, overriding whatever is specified in the Host. The default value (defined in the Host) can be used by providing null for this argument</param>
|
||||
/// <param name="sourceFileName">The file name to use in line pragmas, usually the original Razor file, overriding whatever is specified in the Host. The default value (defined in the Host) can be used by providing null for this argument</param>
|
||||
/// <param name="input">The input text to parse.</param>
|
||||
/// <param name="cancelToken">A token used to cancel the parser.</param>
|
||||
/// <param name="className">
|
||||
/// The name of the generated class, overriding whatever is specified in the Host. The default value (defined
|
||||
/// in the Host) can be used by providing null for this argument.
|
||||
/// </param>
|
||||
/// <param name="rootNamespace">The namespace in which the generated class will reside, overriding whatever is
|
||||
/// specified in the Host. The default value (defined in the Host) can be used by providing null for this
|
||||
/// argument.
|
||||
/// </param>
|
||||
/// <param name="sourceFileName">
|
||||
/// The file name to use in line pragmas, usually the original Razor file, overriding whatever is specified in
|
||||
/// the Host. The default value (defined in the Host) can be used by providing null for this argument.
|
||||
/// </param>
|
||||
/// <returns>The resulting parse tree AND generated code.</returns>
|
||||
[SuppressMessage(
|
||||
"Microsoft.Reliability",
|
||||
|
|
@ -148,7 +163,7 @@ namespace Microsoft.AspNet.Razor
|
|||
Justification = "Input object would be disposed if we dispose the wrapper. We don't own the input so " +
|
||||
"we don't want to dispose it")]
|
||||
public GeneratorResults GenerateCode(
|
||||
ITextBuffer input,
|
||||
[NotNull] ITextBuffer input,
|
||||
string className,
|
||||
string rootNamespace,
|
||||
string sourceFileName,
|
||||
|
|
@ -164,12 +179,12 @@ namespace Microsoft.AspNet.Razor
|
|||
}
|
||||
|
||||
// See GenerateCode override which takes ITextBuffer, and BufferingTextReader for details.
|
||||
public GeneratorResults GenerateCode(TextReader input)
|
||||
public GeneratorResults GenerateCode([NotNull] TextReader input)
|
||||
{
|
||||
return GenerateCode(input, className: null, rootNamespace: null, sourceFileName: null, cancelToken: null);
|
||||
}
|
||||
|
||||
public GeneratorResults GenerateCode(TextReader input, CancellationToken? cancelToken)
|
||||
public GeneratorResults GenerateCode([NotNull] TextReader input, CancellationToken? cancelToken)
|
||||
{
|
||||
return GenerateCode(
|
||||
input,
|
||||
|
|
@ -180,7 +195,7 @@ namespace Microsoft.AspNet.Razor
|
|||
}
|
||||
|
||||
public GeneratorResults GenerateCode(
|
||||
TextReader input,
|
||||
[NotNull] TextReader input,
|
||||
string className,
|
||||
|
||||
string rootNamespace, string sourceFileName)
|
||||
|
|
@ -196,7 +211,9 @@ namespace Microsoft.AspNet.Razor
|
|||
/// <see cref="RazorEngineHost.DefaultClassName"/> (<c>Host.DefaultClassName</c>).</param>
|
||||
/// <param name="rootNamespace">The namespace in which the generated class will reside. When <c>null</c>,
|
||||
/// defaults to <see cref="RazorEngineHost.DefaultNamespace"/> (<c>Host.DefaultNamespace</c>).</param>
|
||||
/// <param name="sourceFileName">The file name to use in line pragmas, usually the original Razor file.</param>
|
||||
/// <param name="sourceFileName">
|
||||
/// The file name to use in line pragmas, usually the original Razor file.
|
||||
/// </param>
|
||||
/// <returns>A <see cref="GeneratorResults"/> that represents the results of parsing the content.</returns>
|
||||
/// <remarks>
|
||||
/// This overload calculates the checksum of the contents of <paramref name="inputStream"/> prior to code
|
||||
|
|
@ -264,7 +281,7 @@ namespace Microsoft.AspNet.Razor
|
|||
Justification = "Input object would be disposed if we dispose the wrapper. We don't own the input so " +
|
||||
"we don't want to dispose it")]
|
||||
public GeneratorResults GenerateCode(
|
||||
TextReader input,
|
||||
[NotNull] TextReader input,
|
||||
string className,
|
||||
string rootNamespace,
|
||||
string sourceFileName,
|
||||
|
|
@ -280,7 +297,7 @@ namespace Microsoft.AspNet.Razor
|
|||
}
|
||||
|
||||
protected internal virtual GeneratorResults GenerateCodeCore(
|
||||
ITextDocument input,
|
||||
[NotNull] ITextDocument input,
|
||||
string className,
|
||||
string rootNamespace,
|
||||
string sourceFileName,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Text;
|
||||
using Microsoft.AspNet.Razor.Utils;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Text
|
||||
{
|
||||
|
|
@ -17,13 +18,8 @@ namespace Microsoft.AspNet.Razor.Text
|
|||
private int _currentCharacter;
|
||||
private SourceLocationTracker _locationTracker;
|
||||
|
||||
public BufferingTextReader(TextReader source)
|
||||
public BufferingTextReader([NotNull] TextReader source)
|
||||
{
|
||||
if (source == null)
|
||||
{
|
||||
throw new ArgumentNullException("source");
|
||||
}
|
||||
|
||||
InnerReader = source;
|
||||
_locationTracker = new SourceLocationTracker();
|
||||
|
||||
|
|
|
|||
|
|
@ -4,42 +4,38 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Internal.Web.Utils;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Text
|
||||
{
|
||||
[DebuggerDisplay("({Location})\"{Value}\"")]
|
||||
public class LocationTagged<T> : IFormattable
|
||||
public class LocationTagged<TValue> : IFormattable
|
||||
{
|
||||
private LocationTagged()
|
||||
{
|
||||
Location = SourceLocation.Undefined;
|
||||
Value = default(T);
|
||||
Value = default(TValue);
|
||||
}
|
||||
|
||||
public LocationTagged(T value, int offset, int line, int col)
|
||||
public LocationTagged([NotNull] TValue value, int offset, int line, int col)
|
||||
: this(value, new SourceLocation(offset, line, col))
|
||||
{
|
||||
}
|
||||
|
||||
public LocationTagged(T value, SourceLocation location)
|
||||
public LocationTagged([NotNull] TValue value, SourceLocation location)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException("value");
|
||||
}
|
||||
|
||||
Location = location;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public SourceLocation Location { get; }
|
||||
|
||||
public T Value { get; }
|
||||
public TValue Value { get; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
LocationTagged<T> other = obj as LocationTagged<T>;
|
||||
LocationTagged<TValue> other = obj as LocationTagged<TValue>;
|
||||
if (ReferenceEquals(other, null))
|
||||
{
|
||||
return false;
|
||||
|
|
@ -81,17 +77,17 @@ namespace Microsoft.AspNet.Razor.Text
|
|||
}
|
||||
}
|
||||
|
||||
public static implicit operator T(LocationTagged<T> value)
|
||||
public static implicit operator TValue(LocationTagged<TValue> value)
|
||||
{
|
||||
return value.Value;
|
||||
}
|
||||
|
||||
public static bool operator ==(LocationTagged<T> left, LocationTagged<T> right)
|
||||
public static bool operator ==(LocationTagged<TValue> left, LocationTagged<TValue> right)
|
||||
{
|
||||
return Equals(left, right);
|
||||
}
|
||||
|
||||
public static bool operator !=(LocationTagged<T> left, LocationTagged<T> right)
|
||||
public static bool operator !=(LocationTagged<TValue> left, LocationTagged<TValue> right)
|
||||
{
|
||||
return !Equals(left, right);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.IO;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Text
|
||||
{
|
||||
|
|
@ -18,12 +19,12 @@ namespace Microsoft.AspNet.Razor.Text
|
|||
UpdateState();
|
||||
}
|
||||
|
||||
public SeekableTextReader(TextReader source)
|
||||
public SeekableTextReader([NotNull] TextReader source)
|
||||
: this(source.ReadToEnd())
|
||||
{
|
||||
}
|
||||
|
||||
public SeekableTextReader(ITextBuffer buffer)
|
||||
public SeekableTextReader([NotNull] ITextBuffer buffer)
|
||||
: this(buffer.ReadToEnd())
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Razor.Utils;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Text
|
||||
{
|
||||
|
|
@ -12,13 +13,8 @@ namespace Microsoft.AspNet.Razor.Text
|
|||
private Stack<BacktrackContext> _bookmarks = new Stack<BacktrackContext>();
|
||||
private SourceLocationTracker _tracker = new SourceLocationTracker();
|
||||
|
||||
public TextBufferReader(ITextBuffer buffer)
|
||||
public TextBufferReader([NotNull] ITextBuffer buffer)
|
||||
{
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException("buffer");
|
||||
}
|
||||
|
||||
InnerBuffer = buffer;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using System.Diagnostics;
|
|||
using System.Globalization;
|
||||
using System.Text;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Internal.Web.Utils;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Text
|
||||
|
|
@ -23,7 +24,13 @@ namespace Microsoft.AspNet.Razor.Text
|
|||
{
|
||||
}
|
||||
|
||||
public TextChange(int oldPosition, int oldLength, ITextBuffer oldBuffer, int newPosition, int newLength, ITextBuffer newBuffer)
|
||||
public TextChange(
|
||||
int oldPosition,
|
||||
int oldLength,
|
||||
[NotNull] ITextBuffer oldBuffer,
|
||||
int newPosition,
|
||||
int newLength,
|
||||
[NotNull] ITextBuffer newBuffer)
|
||||
: this()
|
||||
{
|
||||
if (oldPosition < 0)
|
||||
|
|
@ -42,14 +49,6 @@ namespace Microsoft.AspNet.Razor.Text
|
|||
{
|
||||
throw new ArgumentOutOfRangeException("newLength", CommonResources.FormatArgument_Must_Be_GreaterThanOrEqualTo(0));
|
||||
}
|
||||
if (oldBuffer == null)
|
||||
{
|
||||
throw new ArgumentNullException("oldBuffer");
|
||||
}
|
||||
if (newBuffer == null)
|
||||
{
|
||||
throw new ArgumentNullException("newBuffer");
|
||||
}
|
||||
|
||||
OldPosition = oldPosition;
|
||||
NewPosition = newPosition;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using System.Diagnostics;
|
|||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Text;
|
||||
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Tokenizer
|
||||
{
|
||||
|
|
@ -14,7 +15,7 @@ namespace Microsoft.AspNet.Razor.Tokenizer
|
|||
{
|
||||
private Dictionary<char, Func<CSharpSymbolType>> _operatorHandlers;
|
||||
|
||||
public CSharpTokenizer(ITextDocument source)
|
||||
public CSharpTokenizer([NotNull] ITextDocument source)
|
||||
: base(source)
|
||||
{
|
||||
CurrentState = Data;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using System.Diagnostics;
|
|||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Text;
|
||||
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Tokenizer
|
||||
{
|
||||
|
|
@ -14,7 +15,7 @@ namespace Microsoft.AspNet.Razor.Tokenizer
|
|||
{
|
||||
private const char TransitionChar = '@';
|
||||
|
||||
public HtmlTokenizer(ITextDocument source)
|
||||
public HtmlTokenizer([NotNull] ITextDocument source)
|
||||
: base(source)
|
||||
{
|
||||
CurrentState = Data;
|
||||
|
|
|
|||
|
|
@ -3,28 +3,39 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Tokenizer.Symbols
|
||||
{
|
||||
public class CSharpSymbol : SymbolBase<CSharpSymbolType>
|
||||
{
|
||||
// Helper constructor
|
||||
public CSharpSymbol(int offset, int line, int column, string content, CSharpSymbolType type)
|
||||
public CSharpSymbol(int offset, int line, int column, [NotNull] string content, CSharpSymbolType type)
|
||||
: this(new SourceLocation(offset, line, column), content, type, Enumerable.Empty<RazorError>())
|
||||
{
|
||||
}
|
||||
|
||||
public CSharpSymbol(SourceLocation start, string content, CSharpSymbolType type)
|
||||
public CSharpSymbol(SourceLocation start, [NotNull] string content, CSharpSymbolType type)
|
||||
: this(start, content, type, Enumerable.Empty<RazorError>())
|
||||
{
|
||||
}
|
||||
|
||||
public CSharpSymbol(int offset, int line, int column, string content, CSharpSymbolType type, IEnumerable<RazorError> errors)
|
||||
public CSharpSymbol(
|
||||
int offset,
|
||||
int line,
|
||||
int column,
|
||||
[NotNull] string content,
|
||||
CSharpSymbolType type,
|
||||
IEnumerable<RazorError> errors)
|
||||
: base(new SourceLocation(offset, line, column), content, type, errors)
|
||||
{
|
||||
}
|
||||
|
||||
public CSharpSymbol(SourceLocation start, string content, CSharpSymbolType type, IEnumerable<RazorError> errors)
|
||||
public CSharpSymbol(
|
||||
SourceLocation start,
|
||||
[NotNull] string content,
|
||||
CSharpSymbolType type,
|
||||
IEnumerable<RazorError> errors)
|
||||
: base(start, content, type, errors)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,28 +3,39 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Tokenizer.Symbols
|
||||
{
|
||||
public class HtmlSymbol : SymbolBase<HtmlSymbolType>
|
||||
{
|
||||
// Helper constructor
|
||||
public HtmlSymbol(int offset, int line, int column, string content, HtmlSymbolType type)
|
||||
public HtmlSymbol(int offset, int line, int column, [NotNull] string content, HtmlSymbolType type)
|
||||
: this(new SourceLocation(offset, line, column), content, type, Enumerable.Empty<RazorError>())
|
||||
{
|
||||
}
|
||||
|
||||
public HtmlSymbol(SourceLocation start, string content, HtmlSymbolType type)
|
||||
public HtmlSymbol(SourceLocation start, [NotNull] string content, HtmlSymbolType type)
|
||||
: base(start, content, type, Enumerable.Empty<RazorError>())
|
||||
{
|
||||
}
|
||||
|
||||
public HtmlSymbol(int offset, int line, int column, string content, HtmlSymbolType type, IEnumerable<RazorError> errors)
|
||||
public HtmlSymbol(
|
||||
int offset,
|
||||
int line,
|
||||
int column,
|
||||
[NotNull] string content,
|
||||
HtmlSymbolType type,
|
||||
IEnumerable<RazorError> errors)
|
||||
: base(new SourceLocation(offset, line, column), content, type, errors)
|
||||
{
|
||||
}
|
||||
|
||||
public HtmlSymbol(SourceLocation start, string content, HtmlSymbolType type, IEnumerable<RazorError> errors)
|
||||
public HtmlSymbol(
|
||||
SourceLocation start,
|
||||
[NotNull] string content,
|
||||
HtmlSymbolType type,
|
||||
IEnumerable<RazorError> errors)
|
||||
: base(start, content, type, errors)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,23 +5,20 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Internal.Web.Utils;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Tokenizer.Symbols
|
||||
{
|
||||
public abstract class SymbolBase<TType> : ISymbol
|
||||
where TType: struct
|
||||
{
|
||||
protected SymbolBase(SourceLocation start, string content, TType type, IEnumerable<RazorError> errors)
|
||||
protected SymbolBase(
|
||||
SourceLocation start,
|
||||
[NotNull] string content,
|
||||
TType type,
|
||||
IEnumerable<RazorError> errors)
|
||||
{
|
||||
if (content == null)
|
||||
{
|
||||
throw new ArgumentNullException("content");
|
||||
}
|
||||
if (type == null)
|
||||
{
|
||||
throw new ArgumentNullException("type");
|
||||
}
|
||||
|
||||
Start = start;
|
||||
Content = content;
|
||||
Type = type;
|
||||
|
|
|
|||
|
|
@ -13,19 +13,17 @@ using System.Text;
|
|||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Text;
|
||||
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Tokenizer
|
||||
{
|
||||
public abstract partial class Tokenizer<TSymbol, TSymbolType> : StateMachine<TSymbol>, ITokenizer
|
||||
where TSymbolType : struct
|
||||
where TSymbol : SymbolBase<TSymbolType>
|
||||
{
|
||||
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "TextDocumentReader does not require disposal")]
|
||||
protected Tokenizer(ITextDocument source)
|
||||
protected Tokenizer([NotNull] ITextDocument source)
|
||||
{
|
||||
if (source == null)
|
||||
{
|
||||
throw new ArgumentNullException("source");
|
||||
}
|
||||
Source = new TextDocumentReader(source);
|
||||
Buffer = new StringBuilder();
|
||||
CurrentErrors = new List<RazorError>();
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ namespace Microsoft.AspNet.Razor.Tokenizer
|
|||
{
|
||||
[SuppressMessage("Microsoft.Design", "CA1005:AvoidExcessiveParametersOnGenericTypes", Justification = "All generic parameters are required")]
|
||||
public class TokenizerView<TTokenizer, TSymbol, TSymbolType>
|
||||
where TSymbolType : struct
|
||||
where TTokenizer : Tokenizer<TSymbol, TSymbolType>
|
||||
where TSymbol : SymbolBase<TSymbolType>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Utils
|
||||
{
|
||||
|
|
@ -10,12 +11,8 @@ namespace Microsoft.AspNet.Razor.Utils
|
|||
private Action _action;
|
||||
private bool _invoked;
|
||||
|
||||
public DisposableAction(Action action)
|
||||
public DisposableAction([NotNull] Action action)
|
||||
{
|
||||
if (action == null)
|
||||
{
|
||||
throw new ArgumentNullException("action");
|
||||
}
|
||||
_action = action;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,12 +21,6 @@ namespace Microsoft.AspNet.Razor.Test.Editor
|
|||
private static readonly TestFile SimpleCSHTMLDocumentGenerated = TestFile.Create("TestFiles/DesignTime/Simple.txt");
|
||||
private const string TestLinePragmaFileName = "C:\\This\\Path\\Is\\Just\\For\\Line\\Pragmas.cshtml";
|
||||
|
||||
[Fact]
|
||||
public void ConstructorRequiresNonNullHost()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("host", () => new RazorEditorParser(null, TestLinePragmaFileName));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConstructorRequiresNonNullPhysicalPath()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
// 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.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.Text;
|
||||
|
|
@ -16,11 +15,6 @@ namespace Microsoft.AspNet.Razor.Test.Framework
|
|||
|
||||
public RawTextSymbol(SourceLocation start, string content)
|
||||
{
|
||||
if (content == null)
|
||||
{
|
||||
throw new ArgumentNullException("content");
|
||||
}
|
||||
|
||||
Start = start;
|
||||
Content = content;
|
||||
}
|
||||
|
|
@ -28,7 +22,7 @@ namespace Microsoft.AspNet.Razor.Test.Framework
|
|||
public override bool Equals(object obj)
|
||||
{
|
||||
var other = obj as RawTextSymbol;
|
||||
return Equals(Start, other.Start) && Equals(Content, other.Content);
|
||||
return other != null && Equals(Start, other.Start) && Equals(Content, other.Content);
|
||||
}
|
||||
|
||||
internal bool EquivalentTo(ISymbol sym)
|
||||
|
|
|
|||
|
|
@ -42,24 +42,12 @@ namespace Microsoft.AspNet.Razor.Test.Generator
|
|||
Assert.Throws<ArgumentException>("className", () => new CSharpRazorCodeGenerator(string.Empty, TestRootNamespaceName, TestPhysicalPath, CreateHost()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConstructorRequiresNonNullRootNamespaceName()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("rootNamespaceName", () => new CSharpRazorCodeGenerator("Foo", null, TestPhysicalPath, CreateHost()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConstructorAllowsEmptyRootNamespaceName()
|
||||
{
|
||||
new CSharpRazorCodeGenerator("Foo", string.Empty, TestPhysicalPath, CreateHost());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConstructorRequiresNonNullHost()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("host", () => new CSharpRazorCodeGenerator("Foo", TestRootNamespaceName, TestPhysicalPath, null));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("NestedCodeBlocks")]
|
||||
[InlineData("CodeBlock")]
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#if !DNXCORE50
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
|
|
@ -15,25 +14,6 @@ namespace Microsoft.AspNet.Razor.Test.Parser
|
|||
{
|
||||
public class ParserVisitorExtensionsTest
|
||||
{
|
||||
[Fact]
|
||||
public void VisitThrowsOnNullVisitor()
|
||||
{
|
||||
ParserVisitor target = null;
|
||||
var errorSink = new ErrorSink();
|
||||
var results = new ParserResults(new BlockBuilder() { Type = BlockType.Comment }.Build(),
|
||||
Enumerable.Empty<TagHelperDescriptor>(),
|
||||
errorSink);
|
||||
|
||||
Assert.Throws<ArgumentNullException>("self", () => target.Visit(results));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VisitThrowsOnNullResults()
|
||||
{
|
||||
var target = new Mock<ParserVisitor>().Object;
|
||||
Assert.Throws<ArgumentNullException>("result", () => target.Visit(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VisitSendsDocumentToVisitor()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
// 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.Parser;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Xunit;
|
||||
|
|
@ -10,12 +9,6 @@ namespace Microsoft.AspNet.Razor.Test.Parser
|
|||
{
|
||||
public class WhitespaceRewriterTest
|
||||
{
|
||||
[Fact]
|
||||
public void Constructor_Requires_NonNull_SymbolConverter()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("markupSpanFactory", () => new WhiteSpaceRewriter(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Rewrite_Moves_Whitespace_Preceeding_ExpressionBlock_To_Parent_Block()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
// 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.Generator;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Xunit;
|
||||
|
|
@ -10,19 +9,6 @@ namespace Microsoft.AspNet.Razor.Test
|
|||
{
|
||||
public class RazorEngineHostTest
|
||||
{
|
||||
[Fact]
|
||||
public void ConstructorRequiresNonNullCodeLanguage()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("codeLanguage", () => new RazorEngineHost(null));
|
||||
Assert.Throws<ArgumentNullException>("codeLanguage", () => new RazorEngineHost(null, () => new HtmlMarkupParser()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConstructorRequiresNonNullMarkupParser()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("markupParserFactory", () => new RazorEngineHost(new CSharpRazorCodeLanguage(), null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConstructorWithCodeLanguageSetsPropertiesAppropriately()
|
||||
{
|
||||
|
|
@ -54,24 +40,6 @@ namespace Microsoft.AspNet.Razor.Test
|
|||
Assert.Same(expected, host.CreateMarkupParser());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DecorateCodeParserRequiresNonNullCodeParser()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("incomingCodeParser", () => CreateHost().DecorateCodeParser(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DecorateMarkupParserRequiresNonNullMarkupParser()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("incomingMarkupParser", () => CreateHost().DecorateMarkupParser(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DecorateCodeGeneratorRequiresNonNullCodeGenerator()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("incomingCodeGenerator", () => CreateHost().DecorateCodeGenerator(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DecorateCodeParserDoesNotModifyIncomingParser()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#if !DNXCORE50
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
|
@ -19,12 +18,6 @@ namespace Microsoft.AspNet.Razor.Test
|
|||
{
|
||||
public class RazorTemplateEngineTest
|
||||
{
|
||||
[Fact]
|
||||
public void ConstructorRequiresNonNullHost()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("host", () => new RazorTemplateEngine(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConstructorInitializesHost()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,12 +28,6 @@ namespace Microsoft.AspNet.Razor.Test.Text
|
|||
return new BufferingTextReader(new StringReader(testString));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConstructorRequiresNonNullSourceReader()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("source", () => new BufferingTextReader(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PeekReturnsCurrentCharacterWithoutAdvancingPosition()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,12 +15,6 @@ namespace Microsoft.AspNet.Razor.Test.Text
|
|||
return new TextBufferReader(new StringTextBuffer(testString));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConstructorRequiresNonNullTextBuffer()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("buffer", () => new TextBufferReader(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PeekReturnsCurrentCharacterWithoutAdvancingPosition()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -46,18 +46,6 @@ namespace Microsoft.AspNet.Razor.Test.Text
|
|||
ExceptionHelpers.ValidateArgumentException(parameterName, "Value must be greater than or equal to 0.", exception);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConstructorRequiresNonNullOldBuffer()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("oldBuffer", () => new TextChange(0, 0, null, 0, 0, new Mock<ITextBuffer>().Object));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConstructorRequiresNonNullNewBuffer()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("newBuffer", () => new TextChange(0, 0, new Mock<ITextBuffer>().Object, 0, 0, null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConstructorInitializesProperties()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,79 +10,6 @@ namespace Microsoft.AspNet.Razor.Test.Text
|
|||
{
|
||||
public class TextReaderExtensionsTest
|
||||
{
|
||||
[Fact]
|
||||
public void ReadUntilWithCharThrowsArgNullIfReaderNull()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("reader", () => TextReaderExtensions.ReadUntil(null, '@'));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadUntilInclusiveWithCharThrowsArgNullIfReaderNull()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("reader", () => TextReaderExtensions.ReadUntil(null, '@', inclusive: true));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadUntilWithMultipleTerminatorsThrowsArgNullIfReaderNull()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("reader", () => TextReaderExtensions.ReadUntil(null, '/', '>'));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadUntilInclusiveWithMultipleTerminatorsThrowsArgNullIfReaderNull()
|
||||
{
|
||||
// NOTE: Using named parameters would be difficult here, hence the inline comment
|
||||
Assert.Throws<ArgumentNullException>("reader", () => TextReaderExtensions.ReadUntil(null, /* inclusive */ true, '/', '>'));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadUntilWithPredicateThrowsArgNullIfReaderNull()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("reader", () => TextReaderExtensions.ReadUntil(null, c => true));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadUntilInclusiveWithPredicateThrowsArgNullIfReaderNull()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("reader", () => TextReaderExtensions.ReadUntil(null, c => true, inclusive: true));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadUntilWithPredicateThrowsArgExceptionIfPredicateNull()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("condition", () => TextReaderExtensions.ReadUntil(new StringReader("Foo"), (Predicate<char>)null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadUntilInclusiveWithPredicateThrowsArgExceptionIfPredicateNull()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("condition", () => TextReaderExtensions.ReadUntil(new StringReader("Foo"), (Predicate<char>)null, inclusive: true));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadWhileWithPredicateThrowsArgNullIfReaderNull()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("reader", () => TextReaderExtensions.ReadWhile(null, c => true));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadWhileInclusiveWithPredicateThrowsArgNullIfReaderNull()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("reader", () => TextReaderExtensions.ReadWhile(null, c => true, inclusive: true));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadWhileWithPredicateThrowsArgNullIfPredicateNull()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("condition", () => TextReaderExtensions.ReadWhile(new StringReader("Foo"), (Predicate<char>)null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadWhileInclusiveWithPredicateThrowsArgNullIfPredicateNull()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("condition", () => TextReaderExtensions.ReadWhile(new StringReader("Foo"), (Predicate<char>)null, inclusive: true));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadUntilWithCharReadsAllTextUpToSpecifiedCharacterButNotPast()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
// 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.Tokenizer;
|
||||
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -10,12 +8,6 @@ namespace Microsoft.AspNet.Razor.Test.Tokenizer
|
|||
{
|
||||
public class CSharpTokenizerTest : CSharpTokenizerTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void Constructor_Throws_ArgNull_If_Null_Source_Provided()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("source", () => new CSharpTokenizer(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Next_Returns_Null_When_EOF_Reached()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
// 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.Tokenizer;
|
||||
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -10,12 +8,6 @@ namespace Microsoft.AspNet.Razor.Test.Tokenizer
|
|||
{
|
||||
public class HtmlTokenizerTest : HtmlTokenizerTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void Constructor_Throws_ArgNull_If_Null_Source_Provided()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("source", () => new HtmlTokenizer(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Next_Returns_Null_When_EOF_Reached()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ using Xunit;
|
|||
namespace Microsoft.AspNet.Razor.Test.Tokenizer
|
||||
{
|
||||
public abstract class TokenizerTestBase<TSymbol, TSymbolType>
|
||||
where TSymbolType : struct
|
||||
where TSymbol : SymbolBase<TSymbolType>
|
||||
{
|
||||
protected abstract TSymbol IgnoreRemaining { get; }
|
||||
|
|
|
|||
|
|
@ -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.AspNet.Razor.Utils;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -10,12 +9,6 @@ namespace Microsoft.AspNet.Razor.Test.Utils
|
|||
{
|
||||
public class DisposableActionTest
|
||||
{
|
||||
[Fact]
|
||||
public void ConstructorRequiresNonNullAction()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("action", () => new DisposableAction(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ActionIsExecutedOnDispose()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue