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

[VS Code] Register compiler features in MVC 3.0 projects #8061

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ internal abstract class ProjectEngineFactory : IProjectEngineFactory
{
protected abstract string AssemblyName { get; }

public RazorProjectEngine Create(
public abstract RazorProjectEngine Create(
RazorConfiguration configuration,
RazorProjectFileSystem fileSystem,
Action<RazorProjectEngineBuilder> configure)
Action<RazorProjectEngineBuilder> configure);

protected RazorProjectEngine Create(
RazorConfiguration configuration,
RazorProjectFileSystem fileSystem,
Action<RazorProjectEngineBuilder> configure,
bool registerCompilerFeatures)
{
// Rewrite the assembly name into a full name just like this one, but with the name of the MVC design time assembly.
var assemblyFullName = typeof(RazorProjectEngine).Assembly.FullName;
Expand All @@ -31,6 +37,11 @@ public RazorProjectEngine Create(

return RazorProjectEngine.Create(configuration, fileSystem, b =>
{
if (registerCompilerFeatures)
{
CompilerFeatures.Register(b);
}

initializer.Initialize(b);
configure?.Invoke(b);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.

using System;
using Microsoft.AspNetCore.Razor.Language;

namespace Microsoft.AspNetCore.Razor.LanguageServer.Common;

internal class ProjectEngineFactory_1_0 : ProjectEngineFactory
{
protected override string AssemblyName { get; } = "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X";

public override RazorProjectEngine Create(
RazorConfiguration configuration,
RazorProjectFileSystem fileSystem,
Action<RazorProjectEngineBuilder> configure) => Create(configuration, fileSystem, configure, registerCompilerFeatures: false);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.

using Microsoft.AspNetCore.Razor.Language;
using System;

namespace Microsoft.AspNetCore.Razor.LanguageServer.Common;

internal class ProjectEngineFactory_1_1 : ProjectEngineFactory
{
protected override string AssemblyName { get; } = "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X";

public override RazorProjectEngine Create(
RazorConfiguration configuration,
RazorProjectFileSystem fileSystem,
Action<RazorProjectEngineBuilder> configure) => Create(configuration, fileSystem, configure, registerCompilerFeatures: false);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.

using Microsoft.AspNetCore.Razor.Language;
using System;

namespace Microsoft.AspNetCore.Razor.LanguageServer.Common;

internal class ProjectEngineFactory_2_0 : ProjectEngineFactory
{
protected override string AssemblyName { get; } = "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X";

public override RazorProjectEngine Create(
RazorConfiguration configuration,
RazorProjectFileSystem fileSystem,
Action<RazorProjectEngineBuilder> configure) => Create(configuration, fileSystem, configure, registerCompilerFeatures: false);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.

using Microsoft.AspNetCore.Razor.Language;
using System;

namespace Microsoft.AspNetCore.Razor.LanguageServer.Common;

internal class ProjectEngineFactory_2_1 : ProjectEngineFactory
{
protected override string AssemblyName { get; } = "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X";

public override RazorProjectEngine Create(
RazorConfiguration configuration,
RazorProjectFileSystem fileSystem,
Action<RazorProjectEngineBuilder> configure) => Create(configuration, fileSystem, configure, registerCompilerFeatures: false);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.

using Microsoft.AspNetCore.Razor.Language;
using System;

namespace Microsoft.AspNetCore.Razor.LanguageServer.Common;

internal class ProjectEngineFactory_3_0 : ProjectEngineFactory
{
protected override string AssemblyName { get; } = "Microsoft.AspNetCore.Mvc.Razor.Extensions";

public override RazorProjectEngine Create(
RazorConfiguration configuration,
RazorProjectFileSystem fileSystem,
Action<RazorProjectEngineBuilder> configure) => Create(configuration, fileSystem, configure, registerCompilerFeatures: true);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the main part of the change (registerCompilerFeatures: true).

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch, I'll be this was really annoying to track down.

}