From fcf6ea03a9b24f9bf535f70fa8d62c37ebbb94e5 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Mon, 19 Feb 2018 14:03:41 -0800 Subject: [PATCH] Add IDE extensibility for project engine --- ...portCustomProjectEngineFactoryAttribute.cs | 28 +++++++++++++++++++ .../ICustomProjectEngineFactoryMetadata.cs | 12 ++++++++ .../IProjectEngineFactory.cs | 13 +++++++++ 3 files changed, 53 insertions(+) create mode 100644 src/Microsoft.CodeAnalysis.Razor.Workspaces/ExportCustomProjectEngineFactoryAttribute.cs create mode 100644 src/Microsoft.CodeAnalysis.Razor.Workspaces/ICustomProjectEngineFactoryMetadata.cs create mode 100644 src/Microsoft.CodeAnalysis.Razor.Workspaces/IProjectEngineFactory.cs diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ExportCustomProjectEngineFactoryAttribute.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ExportCustomProjectEngineFactoryAttribute.cs new file mode 100644 index 0000000000..923cb0a66e --- /dev/null +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ExportCustomProjectEngineFactoryAttribute.cs @@ -0,0 +1,28 @@ +// 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.Composition; + +namespace Microsoft.CodeAnalysis.Razor +{ + [MetadataAttribute] + [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] + public class ExportCustomProjectEngineFactoryAttribute : ExportAttribute, ICustomProjectEngineFactoryMetadata + { + public ExportCustomProjectEngineFactoryAttribute(string configurationName) + : base(typeof(IProjectEngineFactory)) + { + if (configurationName == null) + { + throw new ArgumentNullException(nameof(configurationName)); + } + + ConfigurationName = configurationName; + } + + public string ConfigurationName { get; } + + public bool SupportsSerialization { get; set; } + } +} diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ICustomProjectEngineFactoryMetadata.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ICustomProjectEngineFactoryMetadata.cs new file mode 100644 index 0000000000..3f93a6e605 --- /dev/null +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ICustomProjectEngineFactoryMetadata.cs @@ -0,0 +1,12 @@ +// 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. + +namespace Microsoft.CodeAnalysis.Razor +{ + public interface ICustomProjectEngineFactoryMetadata + { + string ConfigurationName { get; } + + bool SupportsSerialization { get; } + } +} diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/IProjectEngineFactory.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/IProjectEngineFactory.cs new file mode 100644 index 0000000000..903c47842b --- /dev/null +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/IProjectEngineFactory.cs @@ -0,0 +1,13 @@ +// 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.AspNetCore.Razor.Language; + +namespace Microsoft.CodeAnalysis.Razor +{ + public interface IProjectEngineFactory + { + RazorProjectEngine Create(RazorConfiguration configuration, RazorProjectFileSystem fileSystem, Action configure); + } +}