This commit is contained in:
JoshLove-msft 2024-07-16 17:08:12 -07:00 коммит произвёл GitHub
Родитель 9c282369f9
Коммит 90527d9f2d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 6 добавлений и 26 удалений

Просмотреть файл

@ -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;
}
}
}