Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Johluo/migrate more tooling #22294

Merged
merged 20 commits into from
May 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1c99d2e
Reorganize source code in preparation to move into aspnet/AspNetCore
rynowak Nov 29, 2018
7f725e0
Pass filekind through the workspace layer
rynowak Jan 2, 2019
e4a6865
Don't associate Roslyn workspace project with ProjectSnapshot.
NTaylorMullen Jan 15, 2019
045bd10
Merge branch 'release/vs16.0-preview4'
NTaylorMullen Feb 1, 2019
440b049
Merge remote-tracking branch 'origin/release/vs16.0-preview4'
NTaylorMullen Feb 4, 2019
f121101
Merge branch 'release/vs16.0-preview4'
NTaylorMullen Feb 5, 2019
5f57299
Merge branch 'release/vs16.0-preview4'
ajaybhargavb Feb 7, 2019
e2d2beb
Merge branch 'release/vs16.0-preview4'
NTaylorMullen Feb 12, 2019
740b1d3
Move TagHelperResolver to CodeAnalysis.Workspaces
NTaylorMullen Feb 26, 2019
b2b8ca6
Added RazorSyntaxGenerator to the repo (dotnet/aspnetcore-tooling#313)
ajaybhargavb Mar 8, 2019
c7dcbd8
Added missed files to RazorSyntaxGenerator (dotnet/aspnetcore-tooling…
ajaybhargavb Mar 8, 2019
6747e90
Preserve diagnostics when rewriting Red nodes (dotnet/aspnetcore-tool…
ajaybhargavb Mar 11, 2019
ec503be
Flow RootNamespace from MSBuild (dotnet/aspnetcore-tooling#331)
ajaybhargavb Mar 13, 2019
b1aef03
Expand RazorProject.GetItem to take in FileKinds when getting items.
NTaylorMullen Apr 2, 2019
5d1b6db
Add support for source-build (dotnet/aspnetcore-tooling#620)
natemcmaster May 29, 2019
0c84b3a
Serialize project state from VS to project.razor.json (dotnet/aspnetc…
ryanbrandenburg Mar 31, 2020
986d465
Fix PoliCheck failures.
NTaylorMullen Apr 27, 2020
4bdf89b
Fix more policheck failures in MSN.cshtml\n\nCommit migrated from htt…
NTaylorMullen May 4, 2020
7b56497
Merge branch 'master' of ..\aspnetcore-tooling2\
May 27, 2020
68fea5b
Remove files that should stay in aspnetcore-tooling
May 27, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .azure/pipelines/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ stages:
$(_InternalRuntimeDownloadArgs)
displayName: Build x86

# This is in a separate build step with to workaround MAX_PATH limitations - https://github.com/Microsoft/msbuild/issues/53
# This is in a separate build step with -forceCoreMsbuild to workaround MAX_PATH limitations - https://github.com/Microsoft/msbuild/issues/53
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

- script: .\src\SiteExtensions\build.cmd
-ci
-nobl
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[assembly: BenchmarkDotNet.Attributes.AspNetCoreBenchmark]
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.IO;
using BenchmarkDotNet.Attributes;
using Microsoft.AspNetCore.Mvc.Razor.Extensions;
using Microsoft.AspNetCore.Razor.Language;

namespace Microsoft.AspNetCore.Razor.Performance
{
public class CodeGenerationBenchmark
{
public CodeGenerationBenchmark()
{
var current = new DirectoryInfo(AppContext.BaseDirectory);
while (current != null && !File.Exists(Path.Combine(current.FullName, "MSN.cshtml")))
{
current = current.Parent;
}

var root = current;
var fileSystem = RazorProjectFileSystem.Create(root.FullName);

ProjectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, fileSystem, b => RazorExtensions.Register(b)); ;

MSN = fileSystem.GetItem(Path.Combine(root.FullName, "MSN.cshtml"), FileKinds.Legacy);
}

public RazorProjectEngine ProjectEngine { get; }

public RazorProjectItem MSN { get; }

[Benchmark(Description = "Razor Design Time Code Generation of MSN.com")]
public void CodeGeneration_DesignTime_LargeStaticFile()
{
var codeDocument = ProjectEngine.ProcessDesignTime(MSN);
var generated = codeDocument.GetCSharpDocument();

if (generated.Diagnostics.Count != 0)
{
throw new Exception("Error!" + Environment.NewLine + string.Join(Environment.NewLine, generated.Diagnostics));
}
}

[Benchmark(Description = "Razor Runtime Code Generation of MSN.com")]
public void CodeGeneration_Runtime_LargeStaticFile()
{
var codeDocument = ProjectEngine.Process(MSN);
var generated = codeDocument.GetCSharpDocument();

if (generated.Diagnostics.Count != 0)
{
throw new Exception("Error!" + Environment.NewLine + string.Join(Environment.NewLine, generated.Diagnostics));
}
}
}
}
3,983 changes: 3,983 additions & 0 deletions src/Razor/perf/Microsoft.AspNetCore.Razor.Performance/MSN.cshtml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<OutputType>Exe</OutputType>
<ServerGarbageCollection>true</ServerGarbageCollection>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPackable>false</IsPackable>
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
</PropertyGroup>

<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Mvc.Razor.Extensions" />
<Reference Include="BenchmarkDotNet" />
<Reference Include="Newtonsoft.Json" />
</ItemGroup>

<ItemGroup>
<Compile Include="$(SharedSourceRoot)BenchmarkRunner\*.cs" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.IO;
using System.Linq;
using BenchmarkDotNet.Attributes;
using Microsoft.AspNetCore.Mvc.Razor.Extensions;
using Microsoft.AspNetCore.Razor.Language;

namespace Microsoft.AspNetCore.Razor.Performance
{
public class SyntaxTreeGenerationBenchmark
{
public SyntaxTreeGenerationBenchmark()
{
var current = new DirectoryInfo(AppContext.BaseDirectory);
while (current != null && !File.Exists(Path.Combine(current.FullName, "MSN.cshtml")))
{
current = current.Parent;
}

var root = current;
var fileSystem = RazorProjectFileSystem.Create(root.FullName);

ProjectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, fileSystem, b => RazorExtensions.Register(b)); ;

var projectItem = fileSystem.GetItem(Path.Combine(root.FullName, "MSN.cshtml"), FileKinds.Legacy);
MSN = RazorSourceDocument.ReadFrom(projectItem);

var directiveFeature = ProjectEngine.EngineFeatures.OfType<IRazorDirectiveFeature>().FirstOrDefault();
Directives = directiveFeature?.Directives.ToArray() ?? Array.Empty<DirectiveDescriptor>();
}

public RazorProjectEngine ProjectEngine { get; }

public RazorSourceDocument MSN { get; }

public DirectiveDescriptor[] Directives { get; }

[Benchmark(Description = "Razor Design Time Syntax Tree Generation of MSN.com")]
public void SyntaxTreeGeneration_DesignTime_LargeStaticFile()
{
var options = RazorParserOptions.CreateDesignTime(o =>
{
foreach (var directive in Directives)
{
o.Directives.Add(directive);
}
});
var syntaxTree = RazorSyntaxTree.Parse(MSN, options);

if (syntaxTree.Diagnostics.Count != 0)
{
throw new Exception("Error!" + Environment.NewLine + string.Join(Environment.NewLine, syntaxTree.Diagnostics));
}
}

[Benchmark(Description = "Razor Runtime Syntax Tree Generation of MSN.com")]
public void SyntaxTreeGeneration_Runtime_LargeStaticFile()
{
var options = RazorParserOptions.Create(o =>
{
foreach (var directive in Directives)
{
o.Directives.Add(directive);
}
});
var syntaxTree = RazorSyntaxTree.Parse(MSN, options);

if (syntaxTree.Diagnostics.Count != 0)
{
throw new Exception("Error!" + Environment.NewLine + string.Join(Environment.NewLine, syntaxTree.Diagnostics));
}
}
}
}
11 changes: 11 additions & 0 deletions src/Razor/perf/Microsoft.AspNetCore.Razor.Performance/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Compile the solution in Release mode (so binaries are available in release)

To run a specific benchmark add it as parameter.
```
dotnet run -c Release <benchmark_name>
```

If you run without any parameters, you'll be offered the list of all benchmarks and get to choose.
```
dotnet run -c Release
```

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions src/Razor/test/Directory.Build.props

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<DisablePubternalApiCheck>true</DisablePubternalApiCheck>
</PropertyGroup>

</Project>
Loading