提交 40f6ba4c 编写于 作者: S Sam Harwell

Move CodeFixService to the features layer

Closes #27369
上级 d57cddba
......@@ -18,7 +18,6 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Diagnostics.CSharp;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.CodeAnalysis.ErrorLogger;
......@@ -263,7 +262,6 @@ void Method()
var suppressionProviderFactory = new Lazy<IConfigurationFixProvider, CodeChangeProviderMetadata>(() => suppressionProvider,
new CodeChangeProviderMetadata("SuppressionProvider", languages: new[] { LanguageNames.CSharp }));
var fixService = new CodeFixService(
workspace.ExportProvider.GetExportedValue<IThreadingContext>(),
diagnosticService,
SpecializedCollections.EmptyEnumerable<Lazy<IErrorLoggerService>>(),
SpecializedCollections.EmptyEnumerable<Lazy<CodeFixProvider, CodeChangeProviderMetadata>>(),
......
......@@ -924,9 +924,6 @@ Do you want to proceed?</value>
<data name="Expander_image_element" xml:space="preserve">
<value>Expander</value>
</data>
<data name="Removal_of_document_not_supported" xml:space="preserve">
<value>Removal of document not supported</value>
</data>
<data name="Split_comment" xml:space="preserve">
<value>Split comment</value>
</data>
......@@ -939,12 +936,6 @@ Do you want to proceed?</value>
<data name="Inline_Hints" xml:space="preserve">
<value>Inline Hints</value>
</data>
<data name="Error_creating_instance_of_CodeFixProvider_0" xml:space="preserve">
<value>Error creating instance of CodeFixProvider '{0}'</value>
</data>
<data name="Error_creating_instance_of_CodeFixProvider" xml:space="preserve">
<value>Error creating instance of CodeFixProvider</value>
</data>
<data name="User_Types_Records" xml:space="preserve">
<value>User Types - Records</value>
</data>
......
......@@ -37,16 +37,6 @@
<target state="translated">Chcete přesto pokračovat? Výsledkem může být poškozený kód.</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="translated">Při vytváření instance CodeFixProvider došlo k chybě.</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="translated">Při vytváření instance CodeFixProvider {0} došlo k chybě.</target>
<note />
</trans-unit>
<trans-unit id="Expander_display_text">
<source>items from unimported namespaces</source>
<target state="translated">položky z neimportovaných oborů názvů</target>
......@@ -122,11 +112,6 @@
<target state="translated">Interpunkce</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="translated">Odebrání dokumentu se nepodporuje.</target>
<note />
</trans-unit>
<trans-unit id="Rename_file_name_doesnt_match">
<source>Rename _file (type does not match file name)</source>
<target state="translated">Přejmenovat _soubor (typ neodpovídá názvu souboru)</target>
......
......@@ -37,16 +37,6 @@
<target state="translated">Möchten Sie dennoch fortfahren? Möglicherweise wird fehlerhafter Code generiert.</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="translated">Fehler beim Erstellen der CodeFixProvider-Instanz</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="translated">Fehler beim Erstellen der CodeFixProvider-Instanz "{0}".</target>
<note />
</trans-unit>
<trans-unit id="Expander_display_text">
<source>items from unimported namespaces</source>
<target state="translated">Elemente aus nicht importierten Namespaces</target>
......@@ -122,11 +112,6 @@
<target state="translated">Interpunktion</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="translated">Das Entfernen des Dokuments wird nicht unterstützt.</target>
<note />
</trans-unit>
<trans-unit id="Rename_file_name_doesnt_match">
<source>Rename _file (type does not match file name)</source>
<target state="translated">_Datei umbenennen (Typ entspricht nicht dem Dateinamen)</target>
......
......@@ -37,16 +37,6 @@
<target state="translated">¿Desea continuar? Esto puede producir código roto.</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="translated">Error al crear la instancia de CodeFixProvider</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="translated">Error al crear la instancia de CodeFixProvider "{0}"</target>
<note />
</trans-unit>
<trans-unit id="Expander_display_text">
<source>items from unimported namespaces</source>
<target state="translated">elementos de espacios de nombres no importados</target>
......@@ -122,11 +112,6 @@
<target state="translated">Puntuación</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="translated">No se admite la eliminación del documento</target>
<note />
</trans-unit>
<trans-unit id="Rename_file_name_doesnt_match">
<source>Rename _file (type does not match file name)</source>
<target state="translated">Ca_mbiar nombre de archivo (el tipo no coincide con el nombre de archivo)</target>
......
......@@ -37,16 +37,6 @@
<target state="translated">Voulez-vous continuer ? Le code sera interrompu.</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="translated">Erreur lors de la création de l'instance de CodeFixProvider</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="translated">Erreur lors de la création de l'instance de CodeFixProvider '{0}'</target>
<note />
</trans-unit>
<trans-unit id="Expander_display_text">
<source>items from unimported namespaces</source>
<target state="translated">éléments provenant d'espaces de noms non importés</target>
......@@ -122,11 +112,6 @@
<target state="translated">Ponctuation</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="translated">Suppression du document non prise en charge</target>
<note />
</trans-unit>
<trans-unit id="Rename_file_name_doesnt_match">
<source>Rename _file (type does not match file name)</source>
<target state="translated">Renommer le _fichier (le type ne correspond pas au nom du fichier)</target>
......
......@@ -37,16 +37,6 @@
<target state="translated">Procedere comunque? Il codice ottenuto potrebbe essere danneggiato.</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="translated">Si è verificato un errore durante la creazione dell'istanza di CodeFixProvider</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="translated">Si è verificato un errore durante la creazione dell'istanza di CodeFixProvider '{0}'</target>
<note />
</trans-unit>
<trans-unit id="Expander_display_text">
<source>items from unimported namespaces</source>
<target state="translated">elementi da spazi dei nomi non importati</target>
......@@ -122,11 +112,6 @@
<target state="translated">Punteggiatura</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="translated">La rimozione del documento non è supportata</target>
<note />
</trans-unit>
<trans-unit id="Rename_file_name_doesnt_match">
<source>Rename _file (type does not match file name)</source>
<target state="translated">Rinomina _file (il tipo non corrisponde al nome file)</target>
......
......@@ -37,16 +37,6 @@
<target state="translated">続行しますか。破損状態のコードが生成される可能性があります。</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="translated">CodeFixProvider のインスタンスの作成でエラーが発生しました</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="translated">CodeFixProvider '{0}' のインスタンスの作成でエラーが発生しました</target>
<note />
</trans-unit>
<trans-unit id="Expander_display_text">
<source>items from unimported namespaces</source>
<target state="translated">インポートされていない名前空間の項目</target>
......@@ -122,11 +112,6 @@
<target state="translated">句読点</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="translated">ドキュメントの削除はサポートされていません</target>
<note />
</trans-unit>
<trans-unit id="Rename_file_name_doesnt_match">
<source>Rename _file (type does not match file name)</source>
<target state="translated">ファイル名の変更 (種類がファイル名と一致しません)(_F)</target>
......
......@@ -37,16 +37,6 @@
<target state="translated">계속하시겠습니까? 계속하면 손상된 코드가 생성될 수 있습니다.</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="translated">CodeFixProvider 인스턴스를 만드는 동안 오류가 발생했습니다.</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="translated">CodeFixProvider '{0}' 인스턴스를 만드는 동안 오류가 발생했습니다.</target>
<note />
</trans-unit>
<trans-unit id="Expander_display_text">
<source>items from unimported namespaces</source>
<target state="translated">가져오지 않은 네임스페이스의 항목</target>
......@@ -122,11 +112,6 @@
<target state="translated">문장 부호</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="translated">지원되지 않는 문서 제거</target>
<note />
</trans-unit>
<trans-unit id="Rename_file_name_doesnt_match">
<source>Rename _file (type does not match file name)</source>
<target state="translated">파일 이름 바꾸기(형식이 파일 이름과 일치하지 않음)(_F)</target>
......
......@@ -37,16 +37,6 @@
<target state="translated">Czy nadal chcesz kontynuować? Może to spowodować uszkodzenie kodu.</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="translated">Błąd podczas tworzenia wystąpienia elementu CodeFixProvider</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="translated">Błąd podczas tworzenia wystąpienia elementu CodeFixProvider „{0}”</target>
<note />
</trans-unit>
<trans-unit id="Expander_display_text">
<source>items from unimported namespaces</source>
<target state="translated">elementy z nieimportowanych przestrzeni nazw</target>
......@@ -122,11 +112,6 @@
<target state="translated">Interpunkcja</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="translated">Usunięcie dokumentu nie jest obsługiwane</target>
<note />
</trans-unit>
<trans-unit id="Rename_file_name_doesnt_match">
<source>Rename _file (type does not match file name)</source>
<target state="translated">Zmień nazwę _pliku (typ nie zgadza się z nazwą pliku)</target>
......
......@@ -37,16 +37,6 @@
<target state="translated">Ainda quer continuar? Isso pode produzir código desfeito.</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="translated">Erro ao criar a instância de CodeFixProvider</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="translated">Erro ao criar instância de CodeFixProvider '{0}'</target>
<note />
</trans-unit>
<trans-unit id="Expander_display_text">
<source>items from unimported namespaces</source>
<target state="translated">itens de namespaces não importados</target>
......@@ -122,11 +112,6 @@
<target state="translated">Pontuação</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="translated">Não há suporte para a remoção do documento</target>
<note />
</trans-unit>
<trans-unit id="Rename_file_name_doesnt_match">
<source>Rename _file (type does not match file name)</source>
<target state="translated">Renomear _arquivo (o tipo não corresponde ao nome do arquivo)</target>
......
......@@ -37,16 +37,6 @@
<target state="translated">Вы действительно хотите продолжить? Это может привести к появлению нерабочего кода.</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="translated">Ошибка при создании экземпляра CodeFixProvider.</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="translated">Ошибка при создании экземпляра CodeFixProvider "{0}".</target>
<note />
</trans-unit>
<trans-unit id="Expander_display_text">
<source>items from unimported namespaces</source>
<target state="translated">элементы из неимпортированных пространств имен</target>
......@@ -122,11 +112,6 @@
<target state="translated">Пунктуация</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="translated">Удаление документа не поддерживается</target>
<note />
</trans-unit>
<trans-unit id="Rename_file_name_doesnt_match">
<source>Rename _file (type does not match file name)</source>
<target state="translated">Переименовать фай_л (тип не соответствует имени файла)</target>
......
......@@ -37,16 +37,6 @@
<target state="translated">Yine de devam etmek istiyor musunuz? Bu işlem sonucunda bozuk kod oluşturulabilir.</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="translated">CodeFixProvider örneği oluşturulurken hata oluştu</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="translated">'{0}' CodeFixProvider örneği oluşturulurken hata oluştu</target>
<note />
</trans-unit>
<trans-unit id="Expander_display_text">
<source>items from unimported namespaces</source>
<target state="translated">içeri aktarılmayan ad alanlarındaki öğeler</target>
......@@ -122,11 +112,6 @@
<target state="translated">Noktalama İşareti</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="translated">Belgenin kaldırılması desteklenmiyor</target>
<note />
</trans-unit>
<trans-unit id="Rename_file_name_doesnt_match">
<source>Rename _file (type does not match file name)</source>
<target state="translated">_Dosyayı yeniden adlandır (tür, dosya adıyla eşleşmiyor)</target>
......
......@@ -37,16 +37,6 @@
<target state="translated">是否仍要继续? 这可能会导致代码损坏。</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="translated">创建 CodeFixProvider 实例时出错</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="translated">创建 CodeFixProvider“{0}”的实例时出错</target>
<note />
</trans-unit>
<trans-unit id="Expander_display_text">
<source>items from unimported namespaces</source>
<target state="translated">未导入命名空间中的项</target>
......@@ -122,11 +112,6 @@
<target state="translated">标点</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="translated">不支持删除文档</target>
<note />
</trans-unit>
<trans-unit id="Rename_file_name_doesnt_match">
<source>Rename _file (type does not match file name)</source>
<target state="translated">重命名文件(类型与文件名不匹配)(_F)</target>
......
......@@ -37,16 +37,6 @@
<target state="translated">仍要繼續嗎? 這可能產生中斷的程式碼。</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="translated">建立 CodeFixProvider 的執行個體時發生錯誤</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="translated">建立 CodeFixProvider '{0}' 的執行個體時發生錯誤</target>
<note />
</trans-unit>
<trans-unit id="Expander_display_text">
<source>items from unimported namespaces</source>
<target state="translated">來自未匯入命名空間的項目</target>
......@@ -122,11 +112,6 @@
<target state="translated">標點符號</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="translated">不支援移除文件</target>
<note />
</trans-unit>
<trans-unit id="Rename_file_name_doesnt_match">
<source>Rename _file (type does not match file name)</source>
<target state="translated">重新命名檔案 (類型不符合檔案名稱)(_F)</target>
......
......@@ -11,7 +11,6 @@
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.CodeAnalysis.ErrorLogger;
......@@ -51,7 +50,6 @@ public async Task TestGetFirstDiagnosticWithFixAsync()
var logger = SpecializedCollections.SingletonEnumerable(new Lazy<IErrorLoggerService>(() => workspace.Services.GetRequiredService<IErrorLoggerService>()));
var fixService = new CodeFixService(
workspace.ExportProvider.GetExportedValue<IThreadingContext>(),
diagnosticService, logger, fixers, SpecializedCollections.EmptyEnumerable<Lazy<IConfigurationFixProvider, CodeChangeProviderMetadata>>());
var incrementalAnalyzer = (IIncrementalAnalyzerProvider)diagnosticService;
......@@ -261,7 +259,6 @@ private static async Task GetFirstDiagnosticWithFixWithExceptionValidationAsync(
: SpecializedCollections.EmptyEnumerable<Lazy<IConfigurationFixProvider, CodeChangeProviderMetadata>>();
var fixService = new CodeFixService(
workspace.ExportProvider.GetExportedValue<IThreadingContext>(),
diagnosticService,
logger,
fixers,
......@@ -571,7 +568,6 @@ public async Task TestNuGetAndVsixCodeFixersWithMultipleFixableDiagnosticIdsAsyn
var logger = SpecializedCollections.SingletonEnumerable(new Lazy<IErrorLoggerService>(() => workspace.Services.GetRequiredService<IErrorLoggerService>()));
var fixService = new CodeFixService(
workspace.ExportProvider.GetExportedValue<IThreadingContext>(),
diagnosticService, logger, vsixFixers, SpecializedCollections.EmptyEnumerable<Lazy<IConfigurationFixProvider, CodeChangeProviderMetadata>>());
var incrementalAnalyzer = (IIncrementalAnalyzerProvider)diagnosticService;
......
......@@ -11,7 +11,6 @@ Imports Microsoft.CodeAnalysis.CodeActions
Imports Microsoft.CodeAnalysis.CodeFixes
Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests
Imports Microsoft.CodeAnalysis.Editor.Shared.Utilities
Imports Microsoft.CodeAnalysis.Editor.UnitTests
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
......@@ -59,7 +58,6 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.CodeFixes.UnitTests
Dim analyzer = diagnosticService.CreateIncrementalAnalyzer(workspace)
Dim logger = SpecializedCollections.SingletonEnumerable(New Lazy(Of IErrorLoggerService)(Function() workspace.Services.GetService(Of IErrorLoggerService)))
Dim codefixService = New CodeFixService(
workspace.ExportProvider.GetExportedValue(Of IThreadingContext),
diagnosticService,
logger,
{New Lazy(Of CodeFixProvider, Mef.CodeChangeProviderMetadata)(
......@@ -128,7 +126,6 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.CodeFixes.UnitTests
Dim analyzer = diagnosticService.CreateIncrementalAnalyzer(workspace)
Dim logger = SpecializedCollections.SingletonEnumerable(New Lazy(Of IErrorLoggerService)(Function() workspace.Services.GetService(Of IErrorLoggerService)))
Dim codefixService = New CodeFixService(
workspace.ExportProvider.GetExportedValue(Of IThreadingContext),
diagnosticService,
logger,
{New Lazy(Of CodeFixProvider, Mef.CodeChangeProviderMetadata)(
......
......@@ -25,16 +25,13 @@ namespace Microsoft.CodeAnalysis.CSharp.CodeCleanup
[ExportLanguageService(typeof(ICodeCleanupService), LanguageNames.CSharp), Shared]
internal class CSharpCodeCleanupService : ICodeCleanupService
{
private readonly ICodeFixService _codeFixServiceOpt;
private readonly ICodeFixService _codeFixService;
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public CSharpCodeCleanupService(
// will remove the AllowDefault once CodeFixService is moved to Features
// https://github.com/dotnet/roslyn/issues/27369
[Import(AllowDefault = true)] ICodeFixService codeFixService)
public CSharpCodeCleanupService(ICodeFixService codeFixService)
{
_codeFixServiceOpt = codeFixService;
_codeFixService = codeFixService;
}
/// <summary>
......@@ -111,11 +108,8 @@ internal class CSharpCodeCleanupService : ICodeCleanupService
progressTracker.AddItems(1);
}
if (_codeFixServiceOpt != null)
{
document = await ApplyCodeFixesAsync(
document, enabledDiagnostics.Diagnostics, progressTracker, cancellationToken).ConfigureAwait(false);
}
document = await ApplyCodeFixesAsync(
document, enabledDiagnostics.Diagnostics, progressTracker, cancellationToken).ConfigureAwait(false);
// do the remove usings after code fix, as code fix might remove some code which can results in unused usings.
if (organizeUsings)
......@@ -194,7 +188,7 @@ internal class CSharpCodeCleanupService : ICodeCleanupService
{
using (Logger.LogBlock(FunctionId.CodeCleanup_ApplyCodeFixesAsync, diagnosticId, cancellationToken))
{
document = await _codeFixServiceOpt.ApplyCodeFixesForSpecificDiagnosticIdAsync(
document = await _codeFixService.ApplyCodeFixesForSpecificDiagnosticIdAsync(
document, diagnosticId, progressTracker, cancellationToken).ConfigureAwait(false);
}
}
......
......@@ -23,17 +23,15 @@
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.Utilities;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Threading;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CodeFixes
{
using Editor.Shared.Utilities;
using DiagnosticId = String;
using LanguageKind = String;
[Export(typeof(ICodeFixService)), Shared]
internal partial class CodeFixService : ForegroundThreadAffinitizedObject, ICodeFixService
internal partial class CodeFixService : ICodeFixService
{
private static readonly Comparison<DiagnosticData> s_diagnosticDataComparisonById =
new((d1, d2) => DiagnosticId.CompareOrdinal(d1.Id, d2.Id));
......@@ -61,12 +59,10 @@ internal partial class CodeFixService : ForegroundThreadAffinitizedObject, ICode
[ImportingConstructor]
[SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
public CodeFixService(
IThreadingContext threadingContext,
IDiagnosticAnalyzerService diagnosticAnalyzerService,
[ImportMany] IEnumerable<Lazy<IErrorLoggerService>> loggers,
[ImportMany] IEnumerable<Lazy<CodeFixProvider, CodeChangeProviderMetadata>> fixers,
[ImportMany] IEnumerable<Lazy<IConfigurationFixProvider, CodeChangeProviderMetadata>> configurationProviders)
: base(threadingContext, assertIsForeground: false)
{
_errorLoggers = loggers;
_diagnosticService = diagnosticAnalyzerService;
......@@ -263,7 +259,7 @@ public async Task<Document> ApplyCodeFixesForSpecificDiagnosticIdAsync(Document
var solution = await fixAllService.GetFixAllChangedSolutionAsync(
new FixAllContext(fixCollection.FixAllState, progressTracker, cancellationToken)).ConfigureAwait(false);
return solution.GetDocument(document.Id) ?? throw new NotSupportedException(EditorFeaturesResources.Removal_of_document_not_supported);
return solution.GetDocument(document.Id) ?? throw new NotSupportedException(FeaturesResources.Removal_of_document_not_supported);
}
private bool TryGetWorkspaceFixersMap(Document document, [NotNullWhen(true)] out Lazy<ImmutableDictionary<DiagnosticId, ImmutableArray<CodeFixProvider>>>? fixerMap)
......@@ -307,8 +303,8 @@ private bool TryGetWorkspaceFixersPriorityMap(Document document, [NotNullWhen(tr
{
var errorReportingService = workspace.Services.GetRequiredService<IErrorReportingService>();
var message = lazyFixer.Metadata.Name != null
? string.Format(EditorFeaturesResources.Error_creating_instance_of_CodeFixProvider_0, lazyFixer.Metadata.Name)
: EditorFeaturesResources.Error_creating_instance_of_CodeFixProvider;
? string.Format(FeaturesResources.Error_creating_instance_of_CodeFixProvider_0, lazyFixer.Metadata.Name)
: FeaturesResources.Error_creating_instance_of_CodeFixProvider;
errorReportingService.ShowGlobalErrorInfo(
message,
......
......@@ -2813,4 +2813,13 @@ Zero-width positive lookbehind assertions are typically used at the beginning of
<data name="The_assembly_0_containing_type_1_references_NET_Framework" xml:space="preserve">
<value>The assembly '{0}' containing type '{1}' references .NET Framework, which is not supported.</value>
</data>
<data name="Error_creating_instance_of_CodeFixProvider" xml:space="preserve">
<value>Error creating instance of CodeFixProvider</value>
</data>
<data name="Error_creating_instance_of_CodeFixProvider_0" xml:space="preserve">
<value>Error creating instance of CodeFixProvider '{0}'</value>
</data>
<data name="Removal_of_document_not_supported" xml:space="preserve">
<value>Removal of document not supported</value>
</data>
</root>
\ No newline at end of file
......@@ -335,6 +335,16 @@ Ujistěte se, že specifikátor tt použijete pro jazyky, pro které je nezbytn
<target state="translated">Při čtení souboru {0} došlo k chybě: {1}</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="new">Error creating instance of CodeFixProvider</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="new">Error creating instance of CodeFixProvider '{0}'</target>
<note />
</trans-unit>
<trans-unit id="Example">
<source>Example:</source>
<target state="translated">Příklad:</target>
......@@ -1830,6 +1840,11 @@ Pozitivní kontrolní výrazy zpětného vyhledávání s nulovou délkou se obv
<target state="translated">Podpisy souvisejících metod nalezené v metadatech se nebudou aktualizovat.</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="new">Removal of document not supported</target>
<note />
</trans-unit>
<trans-unit id="Remove_async_modifier">
<source>Remove 'async' modifier</source>
<target state="translated">Odebrat modifikátor async</target>
......
......@@ -335,6 +335,16 @@ Stellen Sie sicher, dass Sie den Bezeichner "tt" für Sprachen verwenden, für d
<target state="translated">Fehler beim Lesen der Datei "{0}": {1}</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="new">Error creating instance of CodeFixProvider</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="new">Error creating instance of CodeFixProvider '{0}'</target>
<note />
</trans-unit>
<trans-unit id="Example">
<source>Example:</source>
<target state="translated">Beispiel:</target>
......@@ -1830,6 +1840,11 @@ Positive Lookbehindassertionen mit Nullbreite werden normalerweise am Anfang reg
<target state="translated">In Metadaten gefundene ähnliche Methodensignaturen werden nicht aktualisiert.</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="new">Removal of document not supported</target>
<note />
</trans-unit>
<trans-unit id="Remove_async_modifier">
<source>Remove 'async' modifier</source>
<target state="translated">async-Modifizierer entfernen</target>
......
......@@ -335,6 +335,16 @@ Asegúrese de usar el especificador "tt" para los idiomas para los que es necesa
<target state="translated">Error al leer el archivo "{0}": {1}</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="new">Error creating instance of CodeFixProvider</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="new">Error creating instance of CodeFixProvider '{0}'</target>
<note />
</trans-unit>
<trans-unit id="Example">
<source>Example:</source>
<target state="translated">Ejemplo:</target>
......@@ -1830,6 +1840,11 @@ Las aserciones de búsqueda retrasada (lookbehind) positivas de ancho cero se us
<target state="translated">Las signaturas de método relacionadas encontradas en los metadatos no se actualizarán.</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="new">Removal of document not supported</target>
<note />
</trans-unit>
<trans-unit id="Remove_async_modifier">
<source>Remove 'async' modifier</source>
<target state="translated">Quitar el modificador "async"</target>
......
......@@ -335,6 +335,16 @@ Veillez à utiliser le spécificateur "tt" pour les langues où il est nécessai
<target state="translated">Erreur durant la lecture du fichier '{0}' : {1}</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="new">Error creating instance of CodeFixProvider</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="new">Error creating instance of CodeFixProvider '{0}'</target>
<note />
</trans-unit>
<trans-unit id="Example">
<source>Example:</source>
<target state="translated">Exemple :</target>
......@@ -1830,6 +1840,11 @@ Les assertions arrière positives de largeur nulle sont généralement utilisée
<target state="translated">Les signatures de méthode associées dans les métadonnées ne sont pas mises à jour.</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="new">Removal of document not supported</target>
<note />
</trans-unit>
<trans-unit id="Remove_async_modifier">
<source>Remove 'async' modifier</source>
<target state="translated">Supprimer le modificateur 'async'</target>
......
......@@ -335,6 +335,16 @@ Assicurarsi di usare l'identificatore "tt" per le lingue per le quali è necessa
<target state="translated">Si è verificato un errore durante la lettura del file '{0}': {1}</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="new">Error creating instance of CodeFixProvider</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="new">Error creating instance of CodeFixProvider '{0}'</target>
<note />
</trans-unit>
<trans-unit id="Example">
<source>Example:</source>
<target state="translated">Esempio:</target>
......@@ -1830,6 +1840,11 @@ Le asserzioni lookbehind positive di larghezza zero vengono usate in genere all'
<target state="translated">Le firme del metodo correlate trovate nei metadati non verranno aggiornate.</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="new">Removal of document not supported</target>
<note />
</trans-unit>
<trans-unit id="Remove_async_modifier">
<source>Remove 'async' modifier</source>
<target state="translated">Rimuovi il modificatore 'async'</target>
......
......@@ -335,6 +335,16 @@ Make sure to use the "tt" specifier for languages for which it's necessary to ma
<target state="translated">ファイル {0}' の読み取り中にエラーが発生しました: {1}</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="new">Error creating instance of CodeFixProvider</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="new">Error creating instance of CodeFixProvider '{0}'</target>
<note />
</trans-unit>
<trans-unit id="Example">
<source>Example:</source>
<target state="translated">例:</target>
......@@ -1830,6 +1840,11 @@ Zero-width positive lookbehind assertions are typically used at the beginning of
<target state="translated">メタデータ内に検出される関連するメソッド シグネチャは更新されません。</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="new">Removal of document not supported</target>
<note />
</trans-unit>
<trans-unit id="Remove_async_modifier">
<source>Remove 'async' modifier</source>
<target state="translated">'async' 修飾子を削除してください</target>
......
......@@ -335,6 +335,16 @@ Make sure to use the "tt" specifier for languages for which it's necessary to ma
<target state="translated">'{0}' 파일을 읽는 동안 오류가 발생했습니다. {1}</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="new">Error creating instance of CodeFixProvider</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="new">Error creating instance of CodeFixProvider '{0}'</target>
<note />
</trans-unit>
<trans-unit id="Example">
<source>Example:</source>
<target state="translated">예:</target>
......@@ -1830,6 +1840,11 @@ Zero-width positive lookbehind assertions are typically used at the beginning of
<target state="translated">메타데이터에서 찾은 관련 메서드 시그니처가 업데이트되지 않습니다.</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="new">Removal of document not supported</target>
<note />
</trans-unit>
<trans-unit id="Remove_async_modifier">
<source>Remove 'async' modifier</source>
<target state="translated">'async' 한정자 제거</target>
......
......@@ -335,6 +335,16 @@ Pamiętaj, aby nie używać specyfikatora „tt” dla wszystkich języków, w k
<target state="translated">Błąd podczas odczytywania pliku „{0}”: {1}</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="new">Error creating instance of CodeFixProvider</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="new">Error creating instance of CodeFixProvider '{0}'</target>
<note />
</trans-unit>
<trans-unit id="Example">
<source>Example:</source>
<target state="translated">Przykład:</target>
......@@ -1830,6 +1840,11 @@ Pozytywne asercje wsteczne o zerowej szerokości są zwykle używane na początk
<target state="translated">Sygnatury powiązanych metod znalezione w metadanych nie zostaną zaktualizowane.</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="new">Removal of document not supported</target>
<note />
</trans-unit>
<trans-unit id="Remove_async_modifier">
<source>Remove 'async' modifier</source>
<target state="translated">Usuń modyfikator „async”</target>
......
......@@ -335,6 +335,16 @@ Verifique se o especificador "tt" foi usado para idiomas para os quais é necess
<target state="translated">Erro ao ler o arquivo '{0}': {1}</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="new">Error creating instance of CodeFixProvider</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="new">Error creating instance of CodeFixProvider '{0}'</target>
<note />
</trans-unit>
<trans-unit id="Example">
<source>Example:</source>
<target state="translated">Exemplo:</target>
......@@ -1830,6 +1840,11 @@ As declarações de lookbehind positivas de largura zero normalmente são usadas
<target state="translated">As assinaturas de método relacionadas encontradas nos metadados não serão atualizadas.</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="new">Removal of document not supported</target>
<note />
</trans-unit>
<trans-unit id="Remove_async_modifier">
<source>Remove 'async' modifier</source>
<target state="translated">Remover o modificador 'async'</target>
......
......@@ -335,6 +335,16 @@ Make sure to use the "tt" specifier for languages for which it's necessary to ma
<target state="translated">Ошибка при чтении файла "{0}": {1}</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="new">Error creating instance of CodeFixProvider</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="new">Error creating instance of CodeFixProvider '{0}'</target>
<note />
</trans-unit>
<trans-unit id="Example">
<source>Example:</source>
<target state="translated">Пример:</target>
......@@ -1830,6 +1840,11 @@ Zero-width positive lookbehind assertions are typically used at the beginning of
<target state="translated">Связанные сигнатуры методов, найденные в метаданных, не будут обновлены.</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="new">Removal of document not supported</target>
<note />
</trans-unit>
<trans-unit id="Remove_async_modifier">
<source>Remove 'async' modifier</source>
<target state="translated">Удалить модификатор "async"</target>
......
......@@ -335,6 +335,16 @@ AM ve PM arasındaki farkın korunmasının gerekli olduğu diller için "tt" be
<target state="translated">'{0}' dosyası okunurken hata: {1}</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="new">Error creating instance of CodeFixProvider</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="new">Error creating instance of CodeFixProvider '{0}'</target>
<note />
</trans-unit>
<trans-unit id="Example">
<source>Example:</source>
<target state="translated">Örnek:</target>
......@@ -1830,6 +1840,11 @@ Sıfır genişlikli pozitif geri yönlü onaylamalar genellikle normal ifadeleri
<target state="translated">Meta verilerde bulunan ilgili metot imzaları güncelleştirilmez.</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="new">Removal of document not supported</target>
<note />
</trans-unit>
<trans-unit id="Remove_async_modifier">
<source>Remove 'async' modifier</source>
<target state="translated">'async' değiştiricisini kaldırın</target>
......
......@@ -335,6 +335,16 @@ Make sure to use the "tt" specifier for languages for which it's necessary to ma
<target state="translated">读取文件“{0}”时出错: {1}</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="new">Error creating instance of CodeFixProvider</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="new">Error creating instance of CodeFixProvider '{0}'</target>
<note />
</trans-unit>
<trans-unit id="Example">
<source>Example:</source>
<target state="translated">示例:</target>
......@@ -1830,6 +1840,11 @@ Zero-width positive lookbehind assertions are typically used at the beginning of
<target state="translated">不更新在元数据中发现的相关方法签名。</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="new">Removal of document not supported</target>
<note />
</trans-unit>
<trans-unit id="Remove_async_modifier">
<source>Remove 'async' modifier</source>
<target state="translated">删除 "async" 修饰符</target>
......
......@@ -335,6 +335,16 @@ Make sure to use the "tt" specifier for languages for which it's necessary to ma
<target state="translated">讀取檔案 '{0}' 時發生錯誤: {1}</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider">
<source>Error creating instance of CodeFixProvider</source>
<target state="new">Error creating instance of CodeFixProvider</target>
<note />
</trans-unit>
<trans-unit id="Error_creating_instance_of_CodeFixProvider_0">
<source>Error creating instance of CodeFixProvider '{0}'</source>
<target state="new">Error creating instance of CodeFixProvider '{0}'</target>
<note />
</trans-unit>
<trans-unit id="Example">
<source>Example:</source>
<target state="translated">範例:</target>
......@@ -1830,6 +1840,11 @@ Zero-width positive lookbehind assertions are typically used at the beginning of
<target state="translated">將不會更新中繼資料中所找到的相關方法簽章。</target>
<note />
</trans-unit>
<trans-unit id="Removal_of_document_not_supported">
<source>Removal of document not supported</source>
<target state="new">Removal of document not supported</target>
<note />
</trans-unit>
<trans-unit id="Remove_async_modifier">
<source>Remove 'async' modifier</source>
<target state="translated">移除 'async' 修飾元</target>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册