parent
3d0f436a06
commit
9acd0f578c
|
|
@ -1,7 +1,6 @@
|
||||||
// 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.
|
// 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.IO;
|
||||||
using Microsoft.AspNetCore.Razor.CodeGenerators;
|
using Microsoft.AspNetCore.Razor.CodeGenerators;
|
||||||
|
|
||||||
|
|
@ -10,7 +9,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specifies the contracts for a Razor host that parses Razor files and generates C# code.
|
/// Specifies the contracts for a Razor host that parses Razor files and generates C# code.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IMvcRazorHost : IDisposable
|
public interface IMvcRazorHost
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parses and generates the contents of a Razor file represented by <paramref name="inputStream"/>.
|
/// Parses and generates the contents of a Razor file represented by <paramref name="inputStream"/>.
|
||||||
|
|
|
||||||
|
|
@ -295,7 +295,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
||||||
}
|
}
|
||||||
|
|
||||||
var inheritedChunkTrees = GetInheritedChunkTrees(sourceFileName);
|
var inheritedChunkTrees = GetInheritedChunkTrees(sourceFileName);
|
||||||
|
|
||||||
return new MvcRazorParser(razorParser, inheritedChunkTrees, DefaultInheritedChunks, ModelExpressionType);
|
return new MvcRazorParser(razorParser, inheritedChunkTrees, DefaultInheritedChunks, ModelExpressionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -345,11 +344,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
_chunkTreeCache.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
private IReadOnlyList<ChunkTree> GetInheritedChunkTrees(string sourceFileName)
|
private IReadOnlyList<ChunkTree> GetInheritedChunkTrees(string sourceFileName)
|
||||||
{
|
{
|
||||||
var inheritedChunkTrees = GetInheritedChunkTreeResults(sourceFileName)
|
var inheritedChunkTrees = GetInheritedChunkTreeResults(sourceFileName)
|
||||||
|
|
|
||||||
|
|
@ -32,83 +32,81 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Directives
|
||||||
new UsingChunk { Namespace = "AppNamespace.Model" },
|
new UsingChunk { Namespace = "AppNamespace.Model" },
|
||||||
};
|
};
|
||||||
var cache = new DefaultChunkTreeCache(fileProvider);
|
var cache = new DefaultChunkTreeCache(fileProvider);
|
||||||
using (var host = new MvcRazorHost(cache, new TagHelperDescriptorResolver(designTime: false)))
|
var host = new MvcRazorHost(cache, new TagHelperDescriptorResolver(designTime: false));
|
||||||
{
|
var utility = new ChunkInheritanceUtility(host, cache, defaultChunks);
|
||||||
var utility = new ChunkInheritanceUtility(host, cache, defaultChunks);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var chunkTreeResults = utility.GetInheritedChunkTreeResults(
|
var chunkTreeResults = utility.GetInheritedChunkTreeResults(
|
||||||
PlatformNormalizer.NormalizePath(@"Views\home\Index.cshtml"));
|
PlatformNormalizer.NormalizePath(@"Views\home\Index.cshtml"));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Collection(chunkTreeResults,
|
Assert.Collection(chunkTreeResults,
|
||||||
chunkTreeResult =>
|
chunkTreeResult =>
|
||||||
{
|
{
|
||||||
var viewImportsPath = @"/Views/_ViewImports.cshtml";
|
var viewImportsPath = @"/Views/_ViewImports.cshtml";
|
||||||
Assert.Collection(chunkTreeResult.ChunkTree.Children,
|
Assert.Collection(chunkTreeResult.ChunkTree.Children,
|
||||||
chunk =>
|
chunk =>
|
||||||
{
|
{
|
||||||
Assert.IsType<LiteralChunk>(chunk);
|
Assert.IsType<LiteralChunk>(chunk);
|
||||||
Assert.Equal(viewImportsPath, chunk.Start.FilePath);
|
Assert.Equal(viewImportsPath, chunk.Start.FilePath);
|
||||||
},
|
},
|
||||||
chunk =>
|
chunk =>
|
||||||
{
|
{
|
||||||
var injectChunk = Assert.IsType<InjectChunk>(chunk);
|
var injectChunk = Assert.IsType<InjectChunk>(chunk);
|
||||||
Assert.Equal("MyHelper<TModel>", injectChunk.TypeName);
|
Assert.Equal("MyHelper<TModel>", injectChunk.TypeName);
|
||||||
Assert.Equal("Helper", injectChunk.MemberName);
|
Assert.Equal("Helper", injectChunk.MemberName);
|
||||||
Assert.Equal(viewImportsPath, chunk.Start.FilePath);
|
Assert.Equal(viewImportsPath, chunk.Start.FilePath);
|
||||||
},
|
},
|
||||||
chunk =>
|
chunk =>
|
||||||
{
|
{
|
||||||
Assert.IsType<LiteralChunk>(chunk);
|
Assert.IsType<LiteralChunk>(chunk);
|
||||||
Assert.Equal(viewImportsPath, chunk.Start.FilePath);
|
Assert.Equal(viewImportsPath, chunk.Start.FilePath);
|
||||||
},
|
},
|
||||||
chunk =>
|
chunk =>
|
||||||
{
|
{
|
||||||
var setBaseTypeChunk = Assert.IsType<SetBaseTypeChunk>(chunk);
|
var setBaseTypeChunk = Assert.IsType<SetBaseTypeChunk>(chunk);
|
||||||
Assert.Equal("MyBaseType", setBaseTypeChunk.TypeName);
|
Assert.Equal("MyBaseType", setBaseTypeChunk.TypeName);
|
||||||
Assert.Equal(viewImportsPath, chunk.Start.FilePath);
|
Assert.Equal(viewImportsPath, chunk.Start.FilePath);
|
||||||
},
|
},
|
||||||
chunk =>
|
chunk =>
|
||||||
{
|
{
|
||||||
Assert.IsType<LiteralChunk>(chunk);
|
Assert.IsType<LiteralChunk>(chunk);
|
||||||
Assert.Equal(viewImportsPath, chunk.Start.FilePath);
|
Assert.Equal(viewImportsPath, chunk.Start.FilePath);
|
||||||
},
|
},
|
||||||
chunk =>
|
chunk =>
|
||||||
{
|
{
|
||||||
Assert.IsType<StatementChunk>(chunk);
|
Assert.IsType<StatementChunk>(chunk);
|
||||||
Assert.Equal(viewImportsPath, chunk.Start.FilePath);
|
Assert.Equal(viewImportsPath, chunk.Start.FilePath);
|
||||||
},
|
},
|
||||||
chunk =>
|
chunk =>
|
||||||
{
|
{
|
||||||
Assert.IsType<LiteralChunk>(chunk);
|
Assert.IsType<LiteralChunk>(chunk);
|
||||||
Assert.Equal(viewImportsPath, chunk.Start.FilePath);
|
Assert.Equal(viewImportsPath, chunk.Start.FilePath);
|
||||||
});
|
});
|
||||||
Assert.Equal(viewImportsPath, chunkTreeResult.FilePath);
|
Assert.Equal(viewImportsPath, chunkTreeResult.FilePath);
|
||||||
},
|
},
|
||||||
chunkTreeResult =>
|
chunkTreeResult =>
|
||||||
{
|
{
|
||||||
var viewImportsPath = "/Views/home/_ViewImports.cshtml";
|
var viewImportsPath = "/Views/home/_ViewImports.cshtml";
|
||||||
Assert.Collection(chunkTreeResult.ChunkTree.Children,
|
Assert.Collection(chunkTreeResult.ChunkTree.Children,
|
||||||
chunk =>
|
chunk =>
|
||||||
{
|
{
|
||||||
Assert.IsType<LiteralChunk>(chunk);
|
Assert.IsType<LiteralChunk>(chunk);
|
||||||
Assert.Equal(viewImportsPath, chunk.Start.FilePath);
|
Assert.Equal(viewImportsPath, chunk.Start.FilePath);
|
||||||
},
|
},
|
||||||
chunk =>
|
chunk =>
|
||||||
{
|
{
|
||||||
var usingChunk = Assert.IsType<UsingChunk>(chunk);
|
var usingChunk = Assert.IsType<UsingChunk>(chunk);
|
||||||
Assert.Equal("MyNamespace", usingChunk.Namespace);
|
Assert.Equal("MyNamespace", usingChunk.Namespace);
|
||||||
Assert.Equal(viewImportsPath, chunk.Start.FilePath);
|
Assert.Equal(viewImportsPath, chunk.Start.FilePath);
|
||||||
},
|
},
|
||||||
chunk =>
|
chunk =>
|
||||||
{
|
{
|
||||||
Assert.IsType<LiteralChunk>(chunk);
|
Assert.IsType<LiteralChunk>(chunk);
|
||||||
Assert.Equal(viewImportsPath, chunk.Start.FilePath);
|
Assert.Equal(viewImportsPath, chunk.Start.FilePath);
|
||||||
});
|
});
|
||||||
Assert.Equal(viewImportsPath, chunkTreeResult.FilePath);
|
Assert.Equal(viewImportsPath, chunkTreeResult.FilePath);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -120,21 +118,19 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Directives
|
||||||
fileProvider.AddFile(@"/Views/_Layout.cshtml", string.Empty);
|
fileProvider.AddFile(@"/Views/_Layout.cshtml", string.Empty);
|
||||||
fileProvider.AddFile(@"/Views/home/_not-viewimports.cshtml", string.Empty);
|
fileProvider.AddFile(@"/Views/home/_not-viewimports.cshtml", string.Empty);
|
||||||
var cache = new DefaultChunkTreeCache(fileProvider);
|
var cache = new DefaultChunkTreeCache(fileProvider);
|
||||||
using (var host = new MvcRazorHost(cache, new TagHelperDescriptorResolver(designTime: false)))
|
var host = new MvcRazorHost(cache, new TagHelperDescriptorResolver(designTime: false));
|
||||||
|
var defaultChunks = new Chunk[]
|
||||||
{
|
{
|
||||||
var defaultChunks = new Chunk[]
|
|
||||||
{
|
|
||||||
new InjectChunk("MyTestHtmlHelper", "Html"),
|
new InjectChunk("MyTestHtmlHelper", "Html"),
|
||||||
new UsingChunk { Namespace = "AppNamespace.Model" },
|
new UsingChunk { Namespace = "AppNamespace.Model" },
|
||||||
};
|
};
|
||||||
var utility = new ChunkInheritanceUtility(host, cache, defaultChunks);
|
var utility = new ChunkInheritanceUtility(host, cache, defaultChunks);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var chunkTrees = utility.GetInheritedChunkTreeResults(PlatformNormalizer.NormalizePath(@"Views\home\Index.cshtml"));
|
var chunkTrees = utility.GetInheritedChunkTreeResults(PlatformNormalizer.NormalizePath(@"Views\home\Index.cshtml"));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Empty(chunkTrees);
|
Assert.Empty(chunkTrees);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -145,15 +141,14 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Directives
|
||||||
fileProvider.AddFile(@"/Views/_ViewImports.cshtml",
|
fileProvider.AddFile(@"/Views/_ViewImports.cshtml",
|
||||||
"@inject DifferentHelper<TModel> Html");
|
"@inject DifferentHelper<TModel> Html");
|
||||||
var cache = new DefaultChunkTreeCache(fileProvider);
|
var cache = new DefaultChunkTreeCache(fileProvider);
|
||||||
using (var host = new MvcRazorHost(cache, new TagHelperDescriptorResolver(designTime: false)))
|
var host = new MvcRazorHost(cache, new TagHelperDescriptorResolver(designTime: false));
|
||||||
|
var defaultChunks = new Chunk[]
|
||||||
{
|
{
|
||||||
var defaultChunks = new Chunk[]
|
|
||||||
{
|
|
||||||
new InjectChunk("MyTestHtmlHelper", "Html"),
|
new InjectChunk("MyTestHtmlHelper", "Html"),
|
||||||
new UsingChunk { Namespace = "AppNamespace.Model" },
|
new UsingChunk { Namespace = "AppNamespace.Model" },
|
||||||
};
|
};
|
||||||
var inheritedChunkTrees = new ChunkTree[]
|
var inheritedChunkTrees = new ChunkTree[]
|
||||||
{
|
{
|
||||||
new ChunkTree
|
new ChunkTree
|
||||||
{
|
{
|
||||||
Children = new Chunk[]
|
Children = new Chunk[]
|
||||||
|
|
@ -169,20 +164,19 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Directives
|
||||||
new UsingChunk { Namespace = "AppNamespace.Model" },
|
new UsingChunk { Namespace = "AppNamespace.Model" },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var utility = new ChunkInheritanceUtility(host, cache, defaultChunks);
|
var utility = new ChunkInheritanceUtility(host, cache, defaultChunks);
|
||||||
var chunkTree = new ChunkTree();
|
var chunkTree = new ChunkTree();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
utility.MergeInheritedChunkTrees(chunkTree, inheritedChunkTrees, "dynamic");
|
utility.MergeInheritedChunkTrees(chunkTree, inheritedChunkTrees, "dynamic");
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Collection(chunkTree.Children,
|
Assert.Collection(chunkTree.Children,
|
||||||
chunk => Assert.Same(defaultChunks[1], chunk),
|
chunk => Assert.Same(defaultChunks[1], chunk),
|
||||||
chunk => Assert.Same(inheritedChunkTrees[0].Children[0], chunk),
|
chunk => Assert.Same(inheritedChunkTrees[0].Children[0], chunk),
|
||||||
chunk => Assert.Same(defaultChunks[0], chunk));
|
chunk => Assert.Same(defaultChunks[0], chunk));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -56,23 +56,22 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
||||||
var rootedAppPath = $"{rootPrefix}SomeComputer/Location/Project/";
|
var rootedAppPath = $"{rootPrefix}SomeComputer/Location/Project/";
|
||||||
var rootedFilePath = $"{rootPrefix}SomeComputer/Location/Project/src/file.cshtml";
|
var rootedFilePath = $"{rootPrefix}SomeComputer/Location/Project/src/file.cshtml";
|
||||||
var chunkTreeCache = new DefaultChunkTreeCache(new TestFileProvider());
|
var chunkTreeCache = new DefaultChunkTreeCache(new TestFileProvider());
|
||||||
using (var host = new MvcRazorHost(
|
var host = new MvcRazorHost(
|
||||||
chunkTreeCache,
|
chunkTreeCache,
|
||||||
pathNormalizer: new DesignTimeRazorPathNormalizer(rootedAppPath)))
|
pathNormalizer: new DesignTimeRazorPathNormalizer(rootedAppPath));
|
||||||
{
|
|
||||||
var parser = new RazorParser(
|
|
||||||
host.CodeLanguage.CreateCodeParser(),
|
|
||||||
host.CreateMarkupParser(),
|
|
||||||
tagHelperDescriptorResolver: null);
|
|
||||||
var chunkInheritanceUtility = new PathValidatingChunkInheritanceUtility(host, chunkTreeCache);
|
|
||||||
host.ChunkInheritanceUtility = chunkInheritanceUtility;
|
|
||||||
|
|
||||||
// Act
|
var parser = new RazorParser(
|
||||||
host.DecorateRazorParser(parser, rootedFilePath);
|
host.CodeLanguage.CreateCodeParser(),
|
||||||
|
host.CreateMarkupParser(),
|
||||||
|
tagHelperDescriptorResolver: null);
|
||||||
|
var chunkInheritanceUtility = new PathValidatingChunkInheritanceUtility(host, chunkTreeCache);
|
||||||
|
host.ChunkInheritanceUtility = chunkInheritanceUtility;
|
||||||
|
|
||||||
// Assert
|
// Act
|
||||||
Assert.Equal("src/file.cshtml", chunkInheritanceUtility.InheritedChunkTreePagePath, StringComparer.Ordinal);
|
host.DecorateRazorParser(parser, rootedFilePath);
|
||||||
}
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal("src/file.cshtml", chunkInheritanceUtility.InheritedChunkTreePagePath, StringComparer.Ordinal);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
|
|
@ -84,28 +83,27 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
||||||
var rootedAppPath = $"{rootPrefix}SomeComputer/Location/Project/";
|
var rootedAppPath = $"{rootPrefix}SomeComputer/Location/Project/";
|
||||||
var rootedFilePath = $"{rootPrefix}SomeComputer/Location/Project/src/file.cshtml";
|
var rootedFilePath = $"{rootPrefix}SomeComputer/Location/Project/src/file.cshtml";
|
||||||
var chunkTreeCache = new DefaultChunkTreeCache(new TestFileProvider());
|
var chunkTreeCache = new DefaultChunkTreeCache(new TestFileProvider());
|
||||||
using (var host = new MvcRazorHost(
|
var host = new MvcRazorHost(
|
||||||
chunkTreeCache,
|
chunkTreeCache,
|
||||||
pathNormalizer: new DesignTimeRazorPathNormalizer(rootedAppPath)))
|
pathNormalizer: new DesignTimeRazorPathNormalizer(rootedAppPath));
|
||||||
{
|
|
||||||
var chunkInheritanceUtility = new PathValidatingChunkInheritanceUtility(host, chunkTreeCache);
|
|
||||||
var codeGeneratorContext = new CodeGeneratorContext(
|
|
||||||
new ChunkGeneratorContext(
|
|
||||||
host,
|
|
||||||
host.DefaultClassName,
|
|
||||||
host.DefaultNamespace,
|
|
||||||
rootedFilePath,
|
|
||||||
shouldGenerateLinePragmas: true),
|
|
||||||
new ErrorSink());
|
|
||||||
var codeGenerator = new CSharpCodeGenerator(codeGeneratorContext);
|
|
||||||
host.ChunkInheritanceUtility = chunkInheritanceUtility;
|
|
||||||
|
|
||||||
// Act
|
var chunkInheritanceUtility = new PathValidatingChunkInheritanceUtility(host, chunkTreeCache);
|
||||||
host.DecorateCodeGenerator(codeGenerator, codeGeneratorContext);
|
var codeGeneratorContext = new CodeGeneratorContext(
|
||||||
|
new ChunkGeneratorContext(
|
||||||
|
host,
|
||||||
|
host.DefaultClassName,
|
||||||
|
host.DefaultNamespace,
|
||||||
|
rootedFilePath,
|
||||||
|
shouldGenerateLinePragmas: true),
|
||||||
|
new ErrorSink());
|
||||||
|
var codeGenerator = new CSharpCodeGenerator(codeGeneratorContext);
|
||||||
|
host.ChunkInheritanceUtility = chunkInheritanceUtility;
|
||||||
|
|
||||||
// Assert
|
// Act
|
||||||
Assert.Equal("src/file.cshtml", chunkInheritanceUtility.InheritedChunkTreePagePath, StringComparer.Ordinal);
|
host.DecorateCodeGenerator(codeGenerator, codeGeneratorContext);
|
||||||
}
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal("src/file.cshtml", chunkInheritanceUtility.InheritedChunkTreePagePath, StringComparer.Ordinal);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -113,14 +111,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var fileProvider = new TestFileProvider();
|
var fileProvider = new TestFileProvider();
|
||||||
using (var host = new MvcRazorHost(new DefaultChunkTreeCache(fileProvider), new TagHelperDescriptorResolver(designTime: false)))
|
var host = new MvcRazorHost(
|
||||||
{
|
new DefaultChunkTreeCache(fileProvider),
|
||||||
// Act
|
new TagHelperDescriptorResolver(designTime: false));
|
||||||
var instrumented = host.EnableInstrumentation;
|
|
||||||
|
|
||||||
// Assert
|
// Act
|
||||||
Assert.True(instrumented);
|
var instrumented = host.EnableInstrumentation;
|
||||||
}
|
|
||||||
|
// Assert
|
||||||
|
Assert.True(instrumented);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -128,53 +127,52 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var fileProvider = new TestFileProvider();
|
var fileProvider = new TestFileProvider();
|
||||||
using (var host = new MvcRazorHostWithNormalizedNewLine(new DefaultChunkTreeCache(fileProvider))
|
var host = new MvcRazorHostWithNormalizedNewLine(new DefaultChunkTreeCache(fileProvider))
|
||||||
{
|
{
|
||||||
DesignTimeMode = true
|
DesignTimeMode = true
|
||||||
})
|
};
|
||||||
{
|
|
||||||
var expectedLineMappings = new[]
|
|
||||||
{
|
|
||||||
BuildLineMapping(
|
|
||||||
documentAbsoluteIndex: 33,
|
|
||||||
documentLineIndex: 2,
|
|
||||||
documentCharacterIndex: 14,
|
|
||||||
generatedAbsoluteIndex: 654,
|
|
||||||
generatedLineIndex: 17,
|
|
||||||
generatedCharacterIndex: 48,
|
|
||||||
contentLength: 91),
|
|
||||||
BuildLineMapping(
|
|
||||||
documentAbsoluteIndex: 7,
|
|
||||||
documentLineIndex: 0,
|
|
||||||
documentCharacterIndex: 7,
|
|
||||||
generatedAbsoluteIndex: 836,
|
|
||||||
generatedLineIndex: 19,
|
|
||||||
generatedCharacterIndex: 28,
|
|
||||||
contentLength: 8),
|
|
||||||
BuildLineMapping(
|
|
||||||
documentAbsoluteIndex: 145,
|
|
||||||
documentLineIndex: 4,
|
|
||||||
documentCharacterIndex: 17,
|
|
||||||
generatedAbsoluteIndex: 2530,
|
|
||||||
generatedLineIndex: 50,
|
|
||||||
generatedCharacterIndex: 133,
|
|
||||||
contentLength: 3),
|
|
||||||
BuildLineMapping(
|
|
||||||
documentAbsoluteIndex: 172,
|
|
||||||
documentLineIndex: 5,
|
|
||||||
documentCharacterIndex: 18,
|
|
||||||
generatedAbsoluteIndex: 2897,
|
|
||||||
generatedLineIndex: 56,
|
|
||||||
generatedCharacterIndex: 125,
|
|
||||||
contentLength: 5),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Act and Assert
|
var expectedLineMappings = new[]
|
||||||
RunDesignTimeTest(
|
{
|
||||||
host,
|
BuildLineMapping(
|
||||||
testName: "ModelExpressionTagHelper",
|
documentAbsoluteIndex: 33,
|
||||||
expectedLineMappings: expectedLineMappings);
|
documentLineIndex: 2,
|
||||||
}
|
documentCharacterIndex: 14,
|
||||||
|
generatedAbsoluteIndex: 654,
|
||||||
|
generatedLineIndex: 17,
|
||||||
|
generatedCharacterIndex: 48,
|
||||||
|
contentLength: 91),
|
||||||
|
BuildLineMapping(
|
||||||
|
documentAbsoluteIndex: 7,
|
||||||
|
documentLineIndex: 0,
|
||||||
|
documentCharacterIndex: 7,
|
||||||
|
generatedAbsoluteIndex: 836,
|
||||||
|
generatedLineIndex: 19,
|
||||||
|
generatedCharacterIndex: 28,
|
||||||
|
contentLength: 8),
|
||||||
|
BuildLineMapping(
|
||||||
|
documentAbsoluteIndex: 145,
|
||||||
|
documentLineIndex: 4,
|
||||||
|
documentCharacterIndex: 17,
|
||||||
|
generatedAbsoluteIndex: 2530,
|
||||||
|
generatedLineIndex: 50,
|
||||||
|
generatedCharacterIndex: 133,
|
||||||
|
contentLength: 3),
|
||||||
|
BuildLineMapping(
|
||||||
|
documentAbsoluteIndex: 172,
|
||||||
|
documentLineIndex: 5,
|
||||||
|
documentCharacterIndex: 18,
|
||||||
|
generatedAbsoluteIndex: 2897,
|
||||||
|
generatedLineIndex: 56,
|
||||||
|
generatedCharacterIndex: 125,
|
||||||
|
contentLength: 5),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Act and Assert
|
||||||
|
RunDesignTimeTest(
|
||||||
|
host,
|
||||||
|
testName: "ModelExpressionTagHelper",
|
||||||
|
expectedLineMappings: expectedLineMappings);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
|
|
@ -189,11 +187,10 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var fileProvider = new TestFileProvider();
|
var fileProvider = new TestFileProvider();
|
||||||
using (var host = new TestMvcRazorHost(new DefaultChunkTreeCache(fileProvider)))
|
var host = new TestMvcRazorHost(new DefaultChunkTreeCache(fileProvider));
|
||||||
{
|
|
||||||
// Act and Assert
|
// Act and Assert
|
||||||
RunRuntimeTest(host, scenarioName);
|
RunRuntimeTest(host, scenarioName);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -201,36 +198,35 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var fileProvider = new TestFileProvider();
|
var fileProvider = new TestFileProvider();
|
||||||
using (var host = new MvcRazorHostWithNormalizedNewLine(new DefaultChunkTreeCache(fileProvider))
|
var host = new MvcRazorHostWithNormalizedNewLine(new DefaultChunkTreeCache(fileProvider))
|
||||||
{
|
{
|
||||||
DesignTimeMode = true
|
DesignTimeMode = true
|
||||||
})
|
};
|
||||||
|
|
||||||
|
host.NamespaceImports.Clear();
|
||||||
|
var expectedLineMappings = new[]
|
||||||
{
|
{
|
||||||
host.NamespaceImports.Clear();
|
BuildLineMapping(
|
||||||
var expectedLineMappings = new[]
|
documentAbsoluteIndex: 13,
|
||||||
{
|
documentLineIndex: 0,
|
||||||
BuildLineMapping(
|
documentCharacterIndex: 13,
|
||||||
documentAbsoluteIndex: 13,
|
generatedAbsoluteIndex: 1499,
|
||||||
documentLineIndex: 0,
|
generatedLineIndex: 34,
|
||||||
documentCharacterIndex: 13,
|
generatedCharacterIndex: 13,
|
||||||
generatedAbsoluteIndex: 1499,
|
contentLength: 4),
|
||||||
generatedLineIndex: 34,
|
BuildLineMapping(
|
||||||
generatedCharacterIndex: 13,
|
documentAbsoluteIndex: 43,
|
||||||
contentLength: 4),
|
documentLineIndex: 2,
|
||||||
BuildLineMapping(
|
documentCharacterIndex: 5,
|
||||||
documentAbsoluteIndex: 43,
|
generatedAbsoluteIndex: 1583,
|
||||||
documentLineIndex: 2,
|
generatedLineIndex: 39,
|
||||||
documentCharacterIndex: 5,
|
generatedCharacterIndex: 6,
|
||||||
generatedAbsoluteIndex: 1583,
|
contentLength: 21),
|
||||||
generatedLineIndex: 39,
|
};
|
||||||
generatedCharacterIndex: 6,
|
|
||||||
contentLength: 21),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Act and Assert
|
// Act and Assert
|
||||||
RunDesignTimeTest(host, "Basic", expectedLineMappings);
|
RunDesignTimeTest(host, "Basic", expectedLineMappings);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -238,27 +234,26 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var fileProvider = new TestFileProvider();
|
var fileProvider = new TestFileProvider();
|
||||||
using (var host = new MvcRazorHostWithNormalizedNewLine(new DefaultChunkTreeCache(fileProvider))
|
var host = new MvcRazorHostWithNormalizedNewLine(new DefaultChunkTreeCache(fileProvider))
|
||||||
{
|
{
|
||||||
DesignTimeMode = true
|
DesignTimeMode = true
|
||||||
})
|
};
|
||||||
{
|
|
||||||
host.NamespaceImports.Clear();
|
|
||||||
var expectedLineMappings = new[]
|
|
||||||
{
|
|
||||||
BuildLineMapping(
|
|
||||||
documentAbsoluteIndex: 8,
|
|
||||||
documentLineIndex: 0,
|
|
||||||
documentCharacterIndex: 8,
|
|
||||||
generatedAbsoluteIndex: 666,
|
|
||||||
generatedLineIndex: 21,
|
|
||||||
generatedCharacterIndex: 8,
|
|
||||||
contentLength: 26),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Act and Assert
|
host.NamespaceImports.Clear();
|
||||||
RunDesignTimeTest(host, "_ViewImports", expectedLineMappings);
|
var expectedLineMappings = new[]
|
||||||
}
|
{
|
||||||
|
BuildLineMapping(
|
||||||
|
documentAbsoluteIndex: 8,
|
||||||
|
documentLineIndex: 0,
|
||||||
|
documentCharacterIndex: 8,
|
||||||
|
generatedAbsoluteIndex: 666,
|
||||||
|
generatedLineIndex: 21,
|
||||||
|
generatedCharacterIndex: 8,
|
||||||
|
contentLength: 26),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Act and Assert
|
||||||
|
RunDesignTimeTest(host, "_ViewImports", expectedLineMappings);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -266,35 +261,34 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var fileProvider = new TestFileProvider();
|
var fileProvider = new TestFileProvider();
|
||||||
using (var host = new MvcRazorHostWithNormalizedNewLine(new DefaultChunkTreeCache(fileProvider))
|
var host = new MvcRazorHostWithNormalizedNewLine(new DefaultChunkTreeCache(fileProvider))
|
||||||
{
|
{
|
||||||
DesignTimeMode = true
|
DesignTimeMode = true
|
||||||
})
|
};
|
||||||
{
|
|
||||||
host.NamespaceImports.Clear();
|
|
||||||
var expectedLineMappings = new[]
|
|
||||||
{
|
|
||||||
BuildLineMapping(
|
|
||||||
documentAbsoluteIndex: 1,
|
|
||||||
documentLineIndex: 0,
|
|
||||||
documentCharacterIndex: 1,
|
|
||||||
generatedAbsoluteIndex: 66,
|
|
||||||
generatedLineIndex: 3,
|
|
||||||
generatedCharacterIndex: 0,
|
|
||||||
contentLength: 17),
|
|
||||||
BuildLineMapping(
|
|
||||||
documentAbsoluteIndex: 28,
|
|
||||||
documentLineIndex: 1,
|
|
||||||
documentCharacterIndex: 8,
|
|
||||||
generatedAbsoluteIndex: 711,
|
|
||||||
generatedLineIndex: 26,
|
|
||||||
generatedCharacterIndex: 8,
|
|
||||||
contentLength: 20),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Act and Assert
|
host.NamespaceImports.Clear();
|
||||||
RunDesignTimeTest(host, "Inject", expectedLineMappings);
|
var expectedLineMappings = new[]
|
||||||
}
|
{
|
||||||
|
BuildLineMapping(
|
||||||
|
documentAbsoluteIndex: 1,
|
||||||
|
documentLineIndex: 0,
|
||||||
|
documentCharacterIndex: 1,
|
||||||
|
generatedAbsoluteIndex: 66,
|
||||||
|
generatedLineIndex: 3,
|
||||||
|
generatedCharacterIndex: 0,
|
||||||
|
contentLength: 17),
|
||||||
|
BuildLineMapping(
|
||||||
|
documentAbsoluteIndex: 28,
|
||||||
|
documentLineIndex: 1,
|
||||||
|
documentCharacterIndex: 8,
|
||||||
|
generatedAbsoluteIndex: 711,
|
||||||
|
generatedLineIndex: 26,
|
||||||
|
generatedCharacterIndex: 8,
|
||||||
|
contentLength: 20),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Act and Assert
|
||||||
|
RunDesignTimeTest(host, "Inject", expectedLineMappings);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -302,43 +296,42 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var fileProvider = new TestFileProvider();
|
var fileProvider = new TestFileProvider();
|
||||||
using (var host = new MvcRazorHostWithNormalizedNewLine(new DefaultChunkTreeCache(fileProvider))
|
var host = new MvcRazorHostWithNormalizedNewLine(new DefaultChunkTreeCache(fileProvider))
|
||||||
{
|
{
|
||||||
DesignTimeMode = true
|
DesignTimeMode = true
|
||||||
})
|
};
|
||||||
{
|
|
||||||
host.NamespaceImports.Clear();
|
|
||||||
var expectedLineMappings = new[]
|
|
||||||
{
|
|
||||||
BuildLineMapping(
|
|
||||||
documentAbsoluteIndex: 7,
|
|
||||||
documentLineIndex: 0,
|
|
||||||
documentCharacterIndex: 7,
|
|
||||||
generatedAbsoluteIndex: 397,
|
|
||||||
generatedLineIndex: 11,
|
|
||||||
generatedCharacterIndex: 28,
|
|
||||||
contentLength: 7),
|
|
||||||
BuildLineMapping(
|
|
||||||
documentAbsoluteIndex: 24,
|
|
||||||
documentLineIndex: 1,
|
|
||||||
documentCharacterIndex: 8,
|
|
||||||
generatedAbsoluteIndex: 760,
|
|
||||||
generatedLineIndex: 25,
|
|
||||||
generatedCharacterIndex: 8,
|
|
||||||
contentLength: 20),
|
|
||||||
BuildLineMapping(
|
|
||||||
documentAbsoluteIndex: 54,
|
|
||||||
documentLineIndex: 2,
|
|
||||||
documentCharacterIndex: 8,
|
|
||||||
generatedAbsoluteIndex: 990,
|
|
||||||
generatedLineIndex: 33,
|
|
||||||
generatedCharacterIndex: 8,
|
|
||||||
contentLength: 23),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Act and Assert
|
host.NamespaceImports.Clear();
|
||||||
RunDesignTimeTest(host, "InjectWithModel", expectedLineMappings);
|
var expectedLineMappings = new[]
|
||||||
}
|
{
|
||||||
|
BuildLineMapping(
|
||||||
|
documentAbsoluteIndex: 7,
|
||||||
|
documentLineIndex: 0,
|
||||||
|
documentCharacterIndex: 7,
|
||||||
|
generatedAbsoluteIndex: 397,
|
||||||
|
generatedLineIndex: 11,
|
||||||
|
generatedCharacterIndex: 28,
|
||||||
|
contentLength: 7),
|
||||||
|
BuildLineMapping(
|
||||||
|
documentAbsoluteIndex: 24,
|
||||||
|
documentLineIndex: 1,
|
||||||
|
documentCharacterIndex: 8,
|
||||||
|
generatedAbsoluteIndex: 760,
|
||||||
|
generatedLineIndex: 25,
|
||||||
|
generatedCharacterIndex: 8,
|
||||||
|
contentLength: 20),
|
||||||
|
BuildLineMapping(
|
||||||
|
documentAbsoluteIndex: 54,
|
||||||
|
documentLineIndex: 2,
|
||||||
|
documentCharacterIndex: 8,
|
||||||
|
generatedAbsoluteIndex: 990,
|
||||||
|
generatedLineIndex: 33,
|
||||||
|
generatedCharacterIndex: 8,
|
||||||
|
contentLength: 23),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Act and Assert
|
||||||
|
RunDesignTimeTest(host, "InjectWithModel", expectedLineMappings);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -346,59 +339,58 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var fileProvider = new TestFileProvider();
|
var fileProvider = new TestFileProvider();
|
||||||
using (var host = new MvcRazorHostWithNormalizedNewLine(new DefaultChunkTreeCache(fileProvider))
|
var host = new MvcRazorHostWithNormalizedNewLine(new DefaultChunkTreeCache(fileProvider))
|
||||||
{
|
{
|
||||||
DesignTimeMode = true
|
DesignTimeMode = true
|
||||||
})
|
};
|
||||||
{
|
|
||||||
host.NamespaceImports.Clear();
|
|
||||||
var expectedLineMappings = new[]
|
|
||||||
{
|
|
||||||
BuildLineMapping(
|
|
||||||
documentAbsoluteIndex: 7,
|
|
||||||
documentLineIndex: 0,
|
|
||||||
documentCharacterIndex: 7,
|
|
||||||
generatedAbsoluteIndex: 405,
|
|
||||||
generatedLineIndex: 11,
|
|
||||||
generatedCharacterIndex: 28,
|
|
||||||
contentLength: 7),
|
|
||||||
BuildLineMapping(
|
|
||||||
documentAbsoluteIndex: 24,
|
|
||||||
documentLineIndex: 1,
|
|
||||||
documentCharacterIndex: 8,
|
|
||||||
generatedAbsoluteIndex: 776,
|
|
||||||
generatedLineIndex: 25,
|
|
||||||
generatedCharacterIndex: 8,
|
|
||||||
contentLength: 20),
|
|
||||||
BuildLineMapping(
|
|
||||||
documentAbsoluteIndex: 58,
|
|
||||||
documentLineIndex: 2,
|
|
||||||
documentCharacterIndex: 8,
|
|
||||||
generatedAbsoluteIndex: 1010,
|
|
||||||
generatedLineIndex: 33,
|
|
||||||
generatedCharacterIndex: 8,
|
|
||||||
contentLength: 23),
|
|
||||||
BuildLineMapping(
|
|
||||||
documentAbsoluteIndex: 93,
|
|
||||||
documentLineIndex: 3,
|
|
||||||
documentCharacterIndex: 8,
|
|
||||||
generatedAbsoluteIndex: 1247,
|
|
||||||
generatedLineIndex: 41,
|
|
||||||
generatedCharacterIndex: 8,
|
|
||||||
contentLength: 21),
|
|
||||||
BuildLineMapping(
|
|
||||||
documentAbsoluteIndex: 129,
|
|
||||||
documentLineIndex: 4,
|
|
||||||
documentCharacterIndex: 8,
|
|
||||||
generatedAbsoluteIndex: 1482,
|
|
||||||
generatedLineIndex: 49,
|
|
||||||
generatedCharacterIndex: 8,
|
|
||||||
contentLength: 24),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Act and Assert
|
host.NamespaceImports.Clear();
|
||||||
RunDesignTimeTest(host, "InjectWithSemicolon", expectedLineMappings);
|
var expectedLineMappings = new[]
|
||||||
}
|
{
|
||||||
|
BuildLineMapping(
|
||||||
|
documentAbsoluteIndex: 7,
|
||||||
|
documentLineIndex: 0,
|
||||||
|
documentCharacterIndex: 7,
|
||||||
|
generatedAbsoluteIndex: 405,
|
||||||
|
generatedLineIndex: 11,
|
||||||
|
generatedCharacterIndex: 28,
|
||||||
|
contentLength: 7),
|
||||||
|
BuildLineMapping(
|
||||||
|
documentAbsoluteIndex: 24,
|
||||||
|
documentLineIndex: 1,
|
||||||
|
documentCharacterIndex: 8,
|
||||||
|
generatedAbsoluteIndex: 776,
|
||||||
|
generatedLineIndex: 25,
|
||||||
|
generatedCharacterIndex: 8,
|
||||||
|
contentLength: 20),
|
||||||
|
BuildLineMapping(
|
||||||
|
documentAbsoluteIndex: 58,
|
||||||
|
documentLineIndex: 2,
|
||||||
|
documentCharacterIndex: 8,
|
||||||
|
generatedAbsoluteIndex: 1010,
|
||||||
|
generatedLineIndex: 33,
|
||||||
|
generatedCharacterIndex: 8,
|
||||||
|
contentLength: 23),
|
||||||
|
BuildLineMapping(
|
||||||
|
documentAbsoluteIndex: 93,
|
||||||
|
documentLineIndex: 3,
|
||||||
|
documentCharacterIndex: 8,
|
||||||
|
generatedAbsoluteIndex: 1247,
|
||||||
|
generatedLineIndex: 41,
|
||||||
|
generatedCharacterIndex: 8,
|
||||||
|
contentLength: 21),
|
||||||
|
BuildLineMapping(
|
||||||
|
documentAbsoluteIndex: 129,
|
||||||
|
documentLineIndex: 4,
|
||||||
|
documentCharacterIndex: 8,
|
||||||
|
generatedAbsoluteIndex: 1482,
|
||||||
|
generatedLineIndex: 49,
|
||||||
|
generatedCharacterIndex: 8,
|
||||||
|
contentLength: 24),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Act and Assert
|
||||||
|
RunDesignTimeTest(host, "InjectWithSemicolon", expectedLineMappings);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -406,27 +398,25 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var fileProvider = new TestFileProvider();
|
var fileProvider = new TestFileProvider();
|
||||||
using (var host = new MvcRazorHostWithNormalizedNewLine(new DefaultChunkTreeCache(fileProvider))
|
var host = new MvcRazorHostWithNormalizedNewLine(new DefaultChunkTreeCache(fileProvider))
|
||||||
{
|
{
|
||||||
DesignTimeMode = true
|
DesignTimeMode = true
|
||||||
})
|
};
|
||||||
|
host.NamespaceImports.Clear();
|
||||||
|
var expectedLineMappings = new[]
|
||||||
{
|
{
|
||||||
host.NamespaceImports.Clear();
|
BuildLineMapping(
|
||||||
var expectedLineMappings = new[]
|
documentAbsoluteIndex: 7,
|
||||||
{
|
documentLineIndex: 0,
|
||||||
BuildLineMapping(
|
documentCharacterIndex: 7,
|
||||||
documentAbsoluteIndex: 7,
|
generatedAbsoluteIndex: 400,
|
||||||
documentLineIndex: 0,
|
generatedLineIndex: 11,
|
||||||
documentCharacterIndex: 7,
|
generatedCharacterIndex: 28,
|
||||||
generatedAbsoluteIndex: 400,
|
contentLength: 30),
|
||||||
generatedLineIndex: 11,
|
};
|
||||||
generatedCharacterIndex: 28,
|
|
||||||
contentLength: 30),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Act and Assert
|
// Act and Assert
|
||||||
RunDesignTimeTest(host, "Model", expectedLineMappings);
|
RunDesignTimeTest(host, "Model", expectedLineMappings);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -434,33 +424,32 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var fileProvider = new TestFileProvider();
|
var fileProvider = new TestFileProvider();
|
||||||
using (var host = new MvcRazorHostWithNormalizedNewLine(new DefaultChunkTreeCache(fileProvider))
|
var host = new MvcRazorHostWithNormalizedNewLine(new DefaultChunkTreeCache(fileProvider))
|
||||||
{
|
{
|
||||||
DesignTimeMode = true
|
DesignTimeMode = true
|
||||||
})
|
};
|
||||||
|
|
||||||
|
host.NamespaceImports.Clear();
|
||||||
|
var inputFile = "TestFiles/Input/MultipleModels.cshtml";
|
||||||
|
var outputFile = "TestFiles/Output/DesignTime/MultipleModels.cs";
|
||||||
|
var expectedCode = ResourceFile.ReadResource(_assembly, outputFile, sourceFile: false);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
GeneratorResults results;
|
||||||
|
using (var stream = ResourceFile.GetResourceStream(_assembly, inputFile, sourceFile: true))
|
||||||
{
|
{
|
||||||
host.NamespaceImports.Clear();
|
results = host.GenerateCode(inputFile, stream);
|
||||||
var inputFile = "TestFiles/Input/MultipleModels.cshtml";
|
|
||||||
var outputFile = "TestFiles/Output/DesignTime/MultipleModels.cs";
|
|
||||||
var expectedCode = ResourceFile.ReadResource(_assembly, outputFile, sourceFile: false);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
GeneratorResults results;
|
|
||||||
using (var stream = ResourceFile.GetResourceStream(_assembly, inputFile, sourceFile: true))
|
|
||||||
{
|
|
||||||
results = host.GenerateCode(inputFile, stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.False(results.Success);
|
|
||||||
var parserError = Assert.Single(results.ParserErrors);
|
|
||||||
Assert.Equal("Only one 'model' statement is allowed in a file.", parserError.Message);
|
|
||||||
#if GENERATE_BASELINES
|
|
||||||
ResourceFile.UpdateFile(_assembly, outputFile, expectedCode, results.GeneratedCode);
|
|
||||||
#else
|
|
||||||
Assert.Equal(expectedCode, results.GeneratedCode, ignoreLineEndingDifferences: true);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.False(results.Success);
|
||||||
|
var parserError = Assert.Single(results.ParserErrors);
|
||||||
|
Assert.Equal("Only one 'model' statement is allowed in a file.", parserError.Message);
|
||||||
|
#if GENERATE_BASELINES
|
||||||
|
ResourceFile.UpdateFile(_assembly, outputFile, expectedCode, results.GeneratedCode);
|
||||||
|
#else
|
||||||
|
Assert.Equal(expectedCode, results.GeneratedCode, ignoreLineEndingDifferences: true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void RunRuntimeTest(
|
private static void RunRuntimeTest(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue