Sample plugin cleanup (#3857)
This commit is contained in:
Родитель
9c282369f9
Коммит
90527d9f2d
|
@ -57,6 +57,6 @@ namespace Microsoft.Generator.CSharp
|
|||
}
|
||||
|
||||
// TODO - make this more additive instead of replace https://github.com/microsoft/typespec/issues/3827
|
||||
protected internal virtual OutputLibraryVisitor[] GetOutputLibraryVisitors() => [];
|
||||
protected internal virtual IEnumerable<OutputLibraryVisitor> GetOutputLibraryVisitors() => [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.Generator.CSharp;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Generator.CSharp.ClientModel;
|
||||
namespace SamplePlugin
|
||||
{
|
||||
public class SamplePluginOutputLibrary : ScmOutputLibrary
|
||||
{
|
||||
protected override OutputLibraryVisitor[] GetOutputLibraryVisitors() => [new SamplePluginOutputLibraryVisitor()];
|
||||
protected override IEnumerable<SamplePluginOutputLibraryVisitor> GetOutputLibraryVisitors() => [new SamplePluginOutputLibraryVisitor()];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,39 +1,19 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.ClientModel;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Composition;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.Generator.CSharp;
|
||||
using Microsoft.Generator.CSharp.ClientModel;
|
||||
using Microsoft.Generator.CSharp.Primitives;
|
||||
using Microsoft.Generator.CSharp.Providers;
|
||||
|
||||
namespace SamplePlugin
|
||||
{
|
||||
[Export(typeof(CodeModelPlugin))]
|
||||
[ExportMetadata("PluginName", nameof(SampleCodeModelPlugin))]
|
||||
public class SampleCodeModelPlugin : ClientModelPlugin
|
||||
[method: ImportingConstructor]
|
||||
public class SampleCodeModelPlugin(GeneratorContext context) : ClientModelPlugin(context)
|
||||
{
|
||||
private static SampleCodeModelPlugin? _instance;
|
||||
internal static SampleCodeModelPlugin Instance => _instance ?? throw new InvalidOperationException("SampleCodeModelPlugin is not loaded.");
|
||||
|
||||
public override TypeProviderWriter GetWriter(TypeProvider provider) => new(provider);
|
||||
|
||||
public override SamplePluginTypeFactory TypeFactory { get; }
|
||||
|
||||
public override IReadOnlyList<MetadataReference> AdditionalMetadataReferences => [MetadataReference.CreateFromFile(typeof(ClientResult).Assembly.Location)];
|
||||
public override SamplePluginTypeFactory TypeFactory { get; } = new SamplePluginTypeFactory();
|
||||
|
||||
public override OutputLibrary OutputLibrary { get; } = new SamplePluginOutputLibrary();
|
||||
|
||||
[ImportingConstructor]
|
||||
public SampleCodeModelPlugin(GeneratorContext context)
|
||||
: base(context)
|
||||
{
|
||||
TypeFactory = new SamplePluginTypeFactory();
|
||||
_instance = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче