Remove files that should stay in aspnetcore-tooling
Also address some lingering feedback
This commit is contained in:
parent
7b56497d5e
commit
68fea5b9c2
|
|
@ -149,7 +149,7 @@ stages:
|
||||||
$(_InternalRuntimeDownloadArgs)
|
$(_InternalRuntimeDownloadArgs)
|
||||||
displayName: Build x86
|
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
|
||||||
- script: .\src\SiteExtensions\build.cmd
|
- script: .\src\SiteExtensions\build.cmd
|
||||||
-ci
|
-ci
|
||||||
-nobl
|
-nobl
|
||||||
|
|
|
||||||
|
|
@ -10,32 +10,13 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Razor.Extensions\Microsoft.AspNetCore.Mvc.Razor.Extensions.csproj" />
|
<Reference Include="Microsoft.AspNetCore.Mvc.Razor.Extensions" />
|
||||||
<ProjectReference Include="..\..\src\Microsoft.CodeAnalysis.Razor.Workspaces\Microsoft.CodeAnalysis.Razor.Workspaces.csproj" />
|
<Reference Include="BenchmarkDotNet" />
|
||||||
|
<Reference Include="Newtonsoft.Json" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\..\src\Microsoft.VisualStudio.LanguageServices.Razor\Serialization\*.cs">
|
<Compile Include="$(SharedSourceRoot)BenchmarkRunner\*.cs" />
|
||||||
<Link>Serialization\%(FileName)%(Extension)</Link>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="..\..\test\Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common\TestServices.cs">
|
|
||||||
<Link>TestServices\%(FileName)%(Extension)</Link>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="..\..\test\Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common\TestWorkspace.cs">
|
|
||||||
<Link>TestServices\%(FileName)%(Extension)</Link>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="..\..\test\Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common\TestLanguageServices.cs">
|
|
||||||
<Link>TestServices\%(FileName)%(Extension)</Link>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="..\..\test\Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common\TestWorkspaceServices.cs">
|
|
||||||
<Link>TestServices\%(FileName)%(Extension)</Link>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="BenchmarkDotNet" Version="$(BenchmarkDotNetPackageVersion)" />
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.BenchmarkRunner.Sources" Version="$(MicrosoftAspNetCoreBenchmarkRunnerSourcesPackageVersion)" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -1,53 +0,0 @@
|
||||||
// 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.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using BenchmarkDotNet.Attributes;
|
|
||||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Razor.Performance
|
|
||||||
{
|
|
||||||
public class BackgroundCodeGenerationBenchmark : ProjectSnapshotManagerBenchmarkBase
|
|
||||||
{
|
|
||||||
[IterationSetup]
|
|
||||||
public void Setup()
|
|
||||||
{
|
|
||||||
SnapshotManager = CreateProjectSnapshotManager();
|
|
||||||
SnapshotManager.ProjectAdded(HostProject);
|
|
||||||
SnapshotManager.Changed += SnapshotManager_Changed;
|
|
||||||
}
|
|
||||||
|
|
||||||
[IterationCleanup]
|
|
||||||
public void Cleanup()
|
|
||||||
{
|
|
||||||
SnapshotManager.Changed -= SnapshotManager_Changed;
|
|
||||||
|
|
||||||
Tasks.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<Task> Tasks { get; } = new List<Task>();
|
|
||||||
|
|
||||||
private DefaultProjectSnapshotManager SnapshotManager { get; set; }
|
|
||||||
|
|
||||||
[Benchmark(Description = "Generates the code for 100 files", OperationsPerInvoke = 100)]
|
|
||||||
public async Task BackgroundCodeGeneration_Generate100Files()
|
|
||||||
{
|
|
||||||
for (var i = 0; i < Documents.Length; i++)
|
|
||||||
{
|
|
||||||
SnapshotManager.DocumentAdded(HostProject, Documents[i], TextLoaders[i % 4]);
|
|
||||||
}
|
|
||||||
|
|
||||||
await Task.WhenAll(Tasks);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SnapshotManager_Changed(object sender, ProjectChangeEventArgs e)
|
|
||||||
{
|
|
||||||
// The real work happens here.
|
|
||||||
var project = SnapshotManager.GetLoadedProject(e.ProjectFilePath);
|
|
||||||
var document = project.GetDocument(e.DocumentFilePath);
|
|
||||||
|
|
||||||
Tasks.Add(document.GetGeneratedOutputAsync());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
// 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 BenchmarkDotNet.Attributes;
|
|
||||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Razor.Performance
|
|
||||||
{
|
|
||||||
public class ProjectLoadBenchmark : ProjectSnapshotManagerBenchmarkBase
|
|
||||||
{
|
|
||||||
[IterationSetup]
|
|
||||||
public void Setup()
|
|
||||||
{
|
|
||||||
SnapshotManager = CreateProjectSnapshotManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
private DefaultProjectSnapshotManager SnapshotManager { get; set; }
|
|
||||||
|
|
||||||
[Benchmark(Description = "Initializes a project and 100 files", OperationsPerInvoke = 100)]
|
|
||||||
public void ProjectLoad_AddProjectAnd100Files()
|
|
||||||
{
|
|
||||||
SnapshotManager.ProjectAdded(HostProject);
|
|
||||||
|
|
||||||
for (var i= 0; i < Documents.Length; i++)
|
|
||||||
{
|
|
||||||
SnapshotManager.DocumentAdded(HostProject, Documents[i], TextLoaders[i % 4]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,155 +0,0 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Mvc.Razor.Extensions;
|
|
||||||
using Microsoft.AspNetCore.Razor.Language;
|
|
||||||
using Microsoft.CodeAnalysis;
|
|
||||||
using Microsoft.CodeAnalysis.Host;
|
|
||||||
using Microsoft.CodeAnalysis.Razor;
|
|
||||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
|
||||||
using Microsoft.CodeAnalysis.Razor.Serialization;
|
|
||||||
using Microsoft.CodeAnalysis.Text;
|
|
||||||
using Microsoft.VisualStudio.LanguageServices.Razor.Serialization;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Razor.Performance
|
|
||||||
{
|
|
||||||
public class ProjectSnapshotManagerBenchmarkBase
|
|
||||||
{
|
|
||||||
public ProjectSnapshotManagerBenchmarkBase()
|
|
||||||
{
|
|
||||||
var current = new DirectoryInfo(AppContext.BaseDirectory);
|
|
||||||
while (current != null && !File.Exists(Path.Combine(current.FullName, "Razor.sln")))
|
|
||||||
{
|
|
||||||
current = current.Parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
var root = current;
|
|
||||||
var projectRoot = Path.Combine(root.FullName, "test", "testapps", "LargeProject");
|
|
||||||
|
|
||||||
HostProject = new HostProject(Path.Combine(projectRoot, "LargeProject.csproj"), FallbackRazorConfiguration.MVC_2_1, rootNamespace: null);
|
|
||||||
|
|
||||||
TextLoaders = new TextLoader[4];
|
|
||||||
for (var i = 0; i < 4; i++)
|
|
||||||
{
|
|
||||||
var filePath = Path.Combine(projectRoot, "Views", "Home", $"View00{i % 4}.cshtml");
|
|
||||||
var text = SourceText.From(filePath, encoding: null);
|
|
||||||
TextLoaders[i] = TextLoader.From(TextAndVersion.Create(text, VersionStamp.Create()));
|
|
||||||
}
|
|
||||||
|
|
||||||
Documents = new HostDocument[100];
|
|
||||||
for (var i = 0; i < Documents.Length; i++)
|
|
||||||
{
|
|
||||||
var filePath = Path.Combine(projectRoot, "Views", "Home", $"View00{i % 4}.cshtml");
|
|
||||||
Documents[i] = new HostDocument(filePath, $"/Views/Home/View00{i}.cshtml", FileKinds.Legacy);
|
|
||||||
}
|
|
||||||
|
|
||||||
var tagHelpers = Path.Combine(root.FullName, "benchmarks", "Microsoft.AspNetCore.Razor.Performance", "taghelpers.json");
|
|
||||||
TagHelperResolver = new StaticTagHelperResolver(ReadTagHelpers(tagHelpers));
|
|
||||||
}
|
|
||||||
|
|
||||||
internal HostProject HostProject { get; }
|
|
||||||
|
|
||||||
internal HostDocument[] Documents { get; }
|
|
||||||
|
|
||||||
internal TextLoader[] TextLoaders { get; }
|
|
||||||
|
|
||||||
internal TagHelperResolver TagHelperResolver { get; }
|
|
||||||
|
|
||||||
internal DefaultProjectSnapshotManager CreateProjectSnapshotManager()
|
|
||||||
{
|
|
||||||
var services = TestServices.Create(
|
|
||||||
new IWorkspaceService[]
|
|
||||||
{
|
|
||||||
TagHelperResolver,
|
|
||||||
new StaticProjectSnapshotProjectEngineFactory(),
|
|
||||||
},
|
|
||||||
new ILanguageService[]
|
|
||||||
{
|
|
||||||
});
|
|
||||||
|
|
||||||
return new DefaultProjectSnapshotManager(
|
|
||||||
new TestForegroundDispatcher(),
|
|
||||||
new TestErrorReporter(),
|
|
||||||
Array.Empty<ProjectSnapshotChangeTrigger>(),
|
|
||||||
new AdhocWorkspace(services));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IReadOnlyList<TagHelperDescriptor> ReadTagHelpers(string filePath)
|
|
||||||
{
|
|
||||||
var serializer = new JsonSerializer();
|
|
||||||
serializer.Converters.Add(new RazorDiagnosticJsonConverter());
|
|
||||||
serializer.Converters.Add(new TagHelperDescriptorJsonConverter());
|
|
||||||
|
|
||||||
using (var reader = new JsonTextReader(File.OpenText(filePath)))
|
|
||||||
{
|
|
||||||
return serializer.Deserialize<IReadOnlyList<TagHelperDescriptor>>(reader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TestForegroundDispatcher : ForegroundDispatcher
|
|
||||||
{
|
|
||||||
public override bool IsForegroundThread => true;
|
|
||||||
|
|
||||||
public override TaskScheduler ForegroundScheduler => TaskScheduler.Default;
|
|
||||||
|
|
||||||
public override TaskScheduler BackgroundScheduler => TaskScheduler.Default;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TestErrorReporter : ErrorReporter
|
|
||||||
{
|
|
||||||
public override void ReportError(Exception exception)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void ReportError(Exception exception, ProjectSnapshot project)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void ReportError(Exception exception, Project workspaceProject)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class StaticTagHelperResolver : TagHelperResolver
|
|
||||||
{
|
|
||||||
private readonly IReadOnlyList<TagHelperDescriptor> _tagHelpers;
|
|
||||||
|
|
||||||
public StaticTagHelperResolver(IReadOnlyList<TagHelperDescriptor> tagHelpers)
|
|
||||||
{
|
|
||||||
this._tagHelpers = tagHelpers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Task<TagHelperResolutionResult> GetTagHelpersAsync(Project project, ProjectSnapshot projectSnapshot, CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
return Task.FromResult(new TagHelperResolutionResult(_tagHelpers, Array.Empty<RazorDiagnostic>()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class StaticProjectSnapshotProjectEngineFactory : ProjectSnapshotProjectEngineFactory
|
|
||||||
{
|
|
||||||
public override IProjectEngineFactory FindFactory(ProjectSnapshot project)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IProjectEngineFactory FindSerializableFactory(ProjectSnapshot project)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override RazorProjectEngine Create(RazorConfiguration configuration, RazorProjectFileSystem fileSystem, Action<RazorProjectEngineBuilder> configure)
|
|
||||||
{
|
|
||||||
return RazorProjectEngine.Create(configuration, fileSystem, b =>
|
|
||||||
{
|
|
||||||
RazorExtensions.Register(b);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
using BenchmarkDotNet.Attributes;
|
|
||||||
using Microsoft.AspNetCore.Razor.Language;
|
|
||||||
using Microsoft.CodeAnalysis.Razor.Serialization;
|
|
||||||
using Microsoft.VisualStudio.LanguageServices.Razor.Serialization;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Razor.Performance
|
|
||||||
{
|
|
||||||
public class TagHelperSerializationBenchmark
|
|
||||||
{
|
|
||||||
private readonly byte[] _tagHelperBuffer;
|
|
||||||
|
|
||||||
public TagHelperSerializationBenchmark()
|
|
||||||
{
|
|
||||||
var current = new DirectoryInfo(AppContext.BaseDirectory);
|
|
||||||
while (current != null && !File.Exists(Path.Combine(current.FullName, "taghelpers.json")))
|
|
||||||
{
|
|
||||||
current = current.Parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
var tagHelperFilePath = Path.Combine(current.FullName, "taghelpers.json");
|
|
||||||
_tagHelperBuffer = File.ReadAllBytes(tagHelperFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Benchmark(Description = "Razor TagHelper Serialization")]
|
|
||||||
public void TagHelper_Serialization_RoundTrip()
|
|
||||||
{
|
|
||||||
var serializer = new JsonSerializer();
|
|
||||||
serializer.Converters.Add(new RazorDiagnosticJsonConverter());
|
|
||||||
serializer.Converters.Add(new TagHelperDescriptorJsonConverter());
|
|
||||||
|
|
||||||
// Deserialize from json file.
|
|
||||||
IReadOnlyList<TagHelperDescriptor> tagHelpers;
|
|
||||||
using (var stream = new MemoryStream(_tagHelperBuffer))
|
|
||||||
using (var reader = new JsonTextReader(new StreamReader(stream)))
|
|
||||||
{
|
|
||||||
tagHelpers = serializer.Deserialize<IReadOnlyList<TagHelperDescriptor>>(reader);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Serialize back to json.
|
|
||||||
using (var stream = new MemoryStream())
|
|
||||||
using (var writer = new StreamWriter(stream, Encoding.UTF8, bufferSize: 4096))
|
|
||||||
{
|
|
||||||
serializer.Serialize(writer, tagHelpers);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
<Project>
|
|
||||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.props))\Directory.Build.props" />
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<DisablePubternalApiCheck>true</DisablePubternalApiCheck>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
|
||||||
<DisablePubternalApiCheck>true</DisablePubternalApiCheck>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue