提交 e7d7a542 编写于 作者: J Jason Malinowski

Enable go to definition for source generated files

This allows go to definition (and similar features) to open the outputs
from a source generator as a "virtual" file. The file updates as
changes happen in near-real-time.

This commit is ignoring for now the problem of how we want to represent
source generated files as Documents in the Workspace; this isn't a big
deal bit a helper method (TryGetGeneratorAndHint) is added to easily
check if a SyntaxTree came from a generator, and if so gives you the
information you need to locate the generated file in a later run of
the generator. The majority of this pull request doesn't really change
once we have that working, so this isn't throw-away work. It does mean
though that we don't have a good way to link the generated file back
up to the generating project, so you only get a Miscellanous Files
experience in the generated document for now.

This is also doing a somewhat icky hack where we still have to put an
empty file onto disk, and fill it in once the file is open. The
challenge being that Visual Studio really doesn't give us any way
to have a moniker that isn't a file that passes through the system
at this point.
上级 da2aabf8
## Features Opening New Windows
1. Locate a use of a generated symbol in the project, and invoke Go to Definition.
- [ ] It works.
2. Locate a use of a generated symbol in the project, and invoke Go to Implementation.
- [ ] It works.
3. Locate a use of a generated symbol in the project, and invoke Find References.
- [ ] References to the generated symbol in regular code are located.
- [ ] References to the generated symbol in generated code are located.
## Features That Are Blocked
1. Locate a use of a generated method in a project, and invoke Rename with Ctrl+R Ctrl+R.
- [ ] It should be blocked.
2. Locate a use of a generated method in a project, change the name at the use site.
- [ ] **[NOT WORKING YET]** Rename tracking should not trigger.
## Navigating within a Generated Document
1. Invoke Go to Definition on a generated symbol to open a source generated file.
- [ ] **[NOT WORKING YET]** The navigation bar on the top of the file shows the project that contains the generated source
2. Invoke Find References on the symbol we navigated to.
- [ ] **[NOT WORKING YET]** The original reference should appear in find references.
3. Click on some symbol used more than once in a generated file.
- [ ] Highlight references should highlight all uses in the file.
## Window > New Window Support
1. Invoke Go to Definition to open a source-generated file. Then do Window > New Window to ensure that the new window is set up correctly.
- [ ] It's read only.
- [ ] The title and caption are correct.
2. Remove the source generator from the project.
- [ ] Confirm the first window correctly gets an info bar showing the file is no longer valid.
- [ ] Confirm the second window correctly gets an info bar showing the file is no longer valid.
......@@ -169,6 +169,17 @@ public static IReadOnlyCollection<T> ToCollection<T>(this IEnumerable<T> sequenc
return source.Cast<T?>().LastOrDefault();
}
public static T? SingleOrNull<T>(this IEnumerable<T> source, Func<T, bool> predicate)
where T : struct
{
if (source == null)
{
throw new ArgumentNullException(nameof(source));
}
return source.Cast<T?>().SingleOrDefault(v => predicate(v!.Value));
}
public static bool IsSingle<T>(this IEnumerable<T> list)
{
using var enumerator = list.GetEnumerator();
......
......@@ -17,6 +17,7 @@
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Utilities;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.Editor.FindUsages
......@@ -146,6 +147,22 @@ internal static class DefinitionItemExtensions
sourceLocations.Add(documentLocation);
}
else
{
// Was this a source generated tree? If so, we don't have a document representaion (yet) so
// we'll create a metadata symbol which will later be handled by the symbol navigation service
// that way. Once we represent generated source trees as propery documents, we'll update the code above
// to correctly make this item.
var project = solution.GetOriginatingProject(definition);
var generatorRunResult = await project.GetGeneratorDriverRunResultAsync(cancellationToken).ConfigureAwait(false);
if (generatorRunResult.TryGetGeneratorAndHint(location.SourceTree, out _, out _))
{
return DefinitionItem.CreateMetadataDefinition(
tags, displayParts, nameDisplayParts, solution,
definition, properties, displayIfNoReferences);
}
}
}
}
}
......
......@@ -22,6 +22,7 @@
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.Utilities;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.LanguageServices.Implementation.Library;
......@@ -39,6 +40,7 @@ internal partial class VisualStudioSymbolNavigationService : ForegroundThreadAff
private readonly IServiceProvider _serviceProvider;
private readonly IVsEditorAdaptersFactoryService _editorAdaptersFactory;
private readonly IMetadataAsSourceFileService _metadataAsSourceFileService;
private readonly SourceGeneratedFileManager _sourceGeneratedFileManager;
public VisualStudioSymbolNavigationService(
SVsServiceProvider serviceProvider,
......@@ -50,6 +52,7 @@ internal partial class VisualStudioSymbolNavigationService : ForegroundThreadAff
var componentModel = _serviceProvider.GetService<SComponentModel, IComponentModel>();
_editorAdaptersFactory = componentModel.GetService<IVsEditorAdaptersFactoryService>();
_metadataAsSourceFileService = componentModel.GetService<IMetadataAsSourceFileService>();
_sourceGeneratedFileManager = componentModel.GetService<SourceGeneratedFileManager>();
}
public bool TryNavigateToSymbol(ISymbol symbol, Project project, OptionSet options, CancellationToken cancellationToken)
......@@ -76,6 +79,17 @@ public bool TryNavigateToSymbol(ISymbol symbol, Project project, OptionSet optio
var navigationService = editorWorkspace.Services.GetRequiredService<IDocumentNavigationService>();
return navigationService.TryNavigateToSpan(editorWorkspace, targetDocument.Id, sourceLocation.SourceSpan, options);
}
else
{
// This may be a file from a source generator; if so let's go to it instead
var generatorRunResult = project.GetGeneratorDriverRunResultAsync(cancellationToken).WaitAndGetResult(cancellationToken);
if (generatorRunResult.TryGetGeneratorAndHint(sourceLocation.SourceTree!, out var generator, out var hintName))
{
_sourceGeneratedFileManager.NavigateToSourceGeneratedFile(project, generator, hintName, sourceLocation.SourceSpan);
return true;
}
}
}
// We don't have a source document, so show the Metadata as Source view in a preview tab.
......
......@@ -1538,4 +1538,20 @@ I agree to all of the foregoing:</value>
<data name="Extract_Base_Class" xml:space="preserve">
<value>Extract Base Class</value>
</data>
<data name="This_file_is_autogenerated_by_0_and_cannot_be_edited" xml:space="preserve">
<value>This file is auto-generated by the generator '{0}' and cannot be edited.</value>
</data>
<data name="generated_by_0_suffix" xml:space="preserve">
<value>[generated by {0}]</value>
<comment>{0} is the name of a generator.</comment>
</data>
<data name="generated_suffix" xml:space="preserve">
<value>[generated]</value>
</data>
<data name="The_generator_0_that_generated_this_file_has_been_removed_from_the_project" xml:space="preserve">
<value>The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</value>
</data>
<data name="The_generator_0_that_generated_this_file_has_stopped_generating_this_file" xml:space="preserve">
<value>The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</value>
</data>
</root>
\ No newline at end of file
......@@ -777,6 +777,21 @@
<target state="translated">Cílový obor názvů:</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_been_removed_from_the_project">
<source>The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_stopped_generating_this_file">
<source>The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="This_file_is_autogenerated_by_0_and_cannot_be_edited">
<source>This file is auto-generated by the generator '{0}' and cannot be edited.</source>
<target state="new">This file is auto-generated by the generator '{0}' and cannot be edited.</target>
<note />
</trans-unit>
<trans-unit id="This_is_an_invalid_namespace">
<source>This is an invalid namespace</source>
<target state="translated">Toto je neplatný obor názvů.</target>
......@@ -1017,6 +1032,16 @@
<target state="translated">{0} se změní na veřejný.</target>
<note />
</trans-unit>
<trans-unit id="generated_by_0_suffix">
<source>[generated by {0}]</source>
<target state="new">[generated by {0}]</target>
<note>{0} is the name of a generator.</note>
</trans-unit>
<trans-unit id="generated_suffix">
<source>[generated]</source>
<target state="new">[generated]</target>
<note />
</trans-unit>
<trans-unit id="given_workspace_doesn_t_support_undo">
<source>given workspace doesn't support undo</source>
<target state="translated">Daný pracovní prostor nepodporuje vrácení akce zpátky.</target>
......
......@@ -777,6 +777,21 @@
<target state="translated">Zielnamespace:</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_been_removed_from_the_project">
<source>The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_stopped_generating_this_file">
<source>The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="This_file_is_autogenerated_by_0_and_cannot_be_edited">
<source>This file is auto-generated by the generator '{0}' and cannot be edited.</source>
<target state="new">This file is auto-generated by the generator '{0}' and cannot be edited.</target>
<note />
</trans-unit>
<trans-unit id="This_is_an_invalid_namespace">
<source>This is an invalid namespace</source>
<target state="translated">Dies ist ein ungültiger Namespace.</target>
......@@ -1017,6 +1032,16 @@
<target state="translated">"{0}" wird in öffentlichen Wert geändert.</target>
<note />
</trans-unit>
<trans-unit id="generated_by_0_suffix">
<source>[generated by {0}]</source>
<target state="new">[generated by {0}]</target>
<note>{0} is the name of a generator.</note>
</trans-unit>
<trans-unit id="generated_suffix">
<source>[generated]</source>
<target state="new">[generated]</target>
<note />
</trans-unit>
<trans-unit id="given_workspace_doesn_t_support_undo">
<source>given workspace doesn't support undo</source>
<target state="translated">Der angegebene Arbeitsbereich unterstützt die Funktion "Rückgängig" nicht.</target>
......
......@@ -777,6 +777,21 @@
<target state="translated">Espacio de nombres de destino:</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_been_removed_from_the_project">
<source>The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_stopped_generating_this_file">
<source>The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="This_file_is_autogenerated_by_0_and_cannot_be_edited">
<source>This file is auto-generated by the generator '{0}' and cannot be edited.</source>
<target state="new">This file is auto-generated by the generator '{0}' and cannot be edited.</target>
<note />
</trans-unit>
<trans-unit id="This_is_an_invalid_namespace">
<source>This is an invalid namespace</source>
<target state="translated">Este espacio de nombres no es válido</target>
......@@ -1017,6 +1032,16 @@
<target state="translated">"{0}" se cambiará a público.</target>
<note />
</trans-unit>
<trans-unit id="generated_by_0_suffix">
<source>[generated by {0}]</source>
<target state="new">[generated by {0}]</target>
<note>{0} is the name of a generator.</note>
</trans-unit>
<trans-unit id="generated_suffix">
<source>[generated]</source>
<target state="new">[generated]</target>
<note />
</trans-unit>
<trans-unit id="given_workspace_doesn_t_support_undo">
<source>given workspace doesn't support undo</source>
<target state="translated">el área de trabajo determinada no permite deshacer</target>
......
......@@ -777,6 +777,21 @@
<target state="translated">Espace de noms cible :</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_been_removed_from_the_project">
<source>The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_stopped_generating_this_file">
<source>The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="This_file_is_autogenerated_by_0_and_cannot_be_edited">
<source>This file is auto-generated by the generator '{0}' and cannot be edited.</source>
<target state="new">This file is auto-generated by the generator '{0}' and cannot be edited.</target>
<note />
</trans-unit>
<trans-unit id="This_is_an_invalid_namespace">
<source>This is an invalid namespace</source>
<target state="translated">Ceci est un espace de noms non valide</target>
......@@ -1017,6 +1032,16 @@
<target state="translated">'{0}' va être changé en valeur publique.</target>
<note />
</trans-unit>
<trans-unit id="generated_by_0_suffix">
<source>[generated by {0}]</source>
<target state="new">[generated by {0}]</target>
<note>{0} is the name of a generator.</note>
</trans-unit>
<trans-unit id="generated_suffix">
<source>[generated]</source>
<target state="new">[generated]</target>
<note />
</trans-unit>
<trans-unit id="given_workspace_doesn_t_support_undo">
<source>given workspace doesn't support undo</source>
<target state="translated">l'espace de travail donné ne prend pas en charge la fonction Annuler</target>
......
......@@ -777,6 +777,21 @@
<target state="translated">Spazio dei nomi di destinazione:</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_been_removed_from_the_project">
<source>The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_stopped_generating_this_file">
<source>The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="This_file_is_autogenerated_by_0_and_cannot_be_edited">
<source>This file is auto-generated by the generator '{0}' and cannot be edited.</source>
<target state="new">This file is auto-generated by the generator '{0}' and cannot be edited.</target>
<note />
</trans-unit>
<trans-unit id="This_is_an_invalid_namespace">
<source>This is an invalid namespace</source>
<target state="translated">Questo è uno spazio dei nomi non valido</target>
......@@ -1017,6 +1032,16 @@
<target state="translated">'{0}' verrà modificato in pubblico.</target>
<note />
</trans-unit>
<trans-unit id="generated_by_0_suffix">
<source>[generated by {0}]</source>
<target state="new">[generated by {0}]</target>
<note>{0} is the name of a generator.</note>
</trans-unit>
<trans-unit id="generated_suffix">
<source>[generated]</source>
<target state="new">[generated]</target>
<note />
</trans-unit>
<trans-unit id="given_workspace_doesn_t_support_undo">
<source>given workspace doesn't support undo</source>
<target state="translated">l'area di lavoro specificata non supporta l'annullamento di operazioni</target>
......
......@@ -777,6 +777,21 @@
<target state="translated">ターゲット名前空間:</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_been_removed_from_the_project">
<source>The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_stopped_generating_this_file">
<source>The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="This_file_is_autogenerated_by_0_and_cannot_be_edited">
<source>This file is auto-generated by the generator '{0}' and cannot be edited.</source>
<target state="new">This file is auto-generated by the generator '{0}' and cannot be edited.</target>
<note />
</trans-unit>
<trans-unit id="This_is_an_invalid_namespace">
<source>This is an invalid namespace</source>
<target state="translated">これは無効な名前空間です</target>
......@@ -1017,6 +1032,16 @@
<target state="translated">'{0}' はパブリックに変更されます。</target>
<note />
</trans-unit>
<trans-unit id="generated_by_0_suffix">
<source>[generated by {0}]</source>
<target state="new">[generated by {0}]</target>
<note>{0} is the name of a generator.</note>
</trans-unit>
<trans-unit id="generated_suffix">
<source>[generated]</source>
<target state="new">[generated]</target>
<note />
</trans-unit>
<trans-unit id="given_workspace_doesn_t_support_undo">
<source>given workspace doesn't support undo</source>
<target state="translated">指定されたワークスペースは元に戻す操作をサポートしていません</target>
......
......@@ -777,6 +777,21 @@
<target state="translated">대상 네임스페이스:</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_been_removed_from_the_project">
<source>The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_stopped_generating_this_file">
<source>The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="This_file_is_autogenerated_by_0_and_cannot_be_edited">
<source>This file is auto-generated by the generator '{0}' and cannot be edited.</source>
<target state="new">This file is auto-generated by the generator '{0}' and cannot be edited.</target>
<note />
</trans-unit>
<trans-unit id="This_is_an_invalid_namespace">
<source>This is an invalid namespace</source>
<target state="translated">잘못된 네임스페이스입니다.</target>
......@@ -1017,6 +1032,16 @@
<target state="translated">'{0}'이(가) 공용으로 변경됩니다.</target>
<note />
</trans-unit>
<trans-unit id="generated_by_0_suffix">
<source>[generated by {0}]</source>
<target state="new">[generated by {0}]</target>
<note>{0} is the name of a generator.</note>
</trans-unit>
<trans-unit id="generated_suffix">
<source>[generated]</source>
<target state="new">[generated]</target>
<note />
</trans-unit>
<trans-unit id="given_workspace_doesn_t_support_undo">
<source>given workspace doesn't support undo</source>
<target state="translated">지정한 작업 영역에서 실행을 취소할 수 없습니다.</target>
......
......@@ -777,6 +777,21 @@
<target state="translated">Docelowa przestrzeń nazw:</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_been_removed_from_the_project">
<source>The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_stopped_generating_this_file">
<source>The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="This_file_is_autogenerated_by_0_and_cannot_be_edited">
<source>This file is auto-generated by the generator '{0}' and cannot be edited.</source>
<target state="new">This file is auto-generated by the generator '{0}' and cannot be edited.</target>
<note />
</trans-unit>
<trans-unit id="This_is_an_invalid_namespace">
<source>This is an invalid namespace</source>
<target state="translated">To jest nieprawidłowa przestrzeń nazw</target>
......@@ -1017,6 +1032,16 @@
<target state="translated">Element „{0}” zostanie zmieniony na publiczny.</target>
<note />
</trans-unit>
<trans-unit id="generated_by_0_suffix">
<source>[generated by {0}]</source>
<target state="new">[generated by {0}]</target>
<note>{0} is the name of a generator.</note>
</trans-unit>
<trans-unit id="generated_suffix">
<source>[generated]</source>
<target state="new">[generated]</target>
<note />
</trans-unit>
<trans-unit id="given_workspace_doesn_t_support_undo">
<source>given workspace doesn't support undo</source>
<target state="translated">dany obszar roboczy nie obsługuje operacji cofania</target>
......
......@@ -777,6 +777,21 @@
<target state="translated">Namespace de Destino:</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_been_removed_from_the_project">
<source>The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_stopped_generating_this_file">
<source>The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="This_file_is_autogenerated_by_0_and_cannot_be_edited">
<source>This file is auto-generated by the generator '{0}' and cannot be edited.</source>
<target state="new">This file is auto-generated by the generator '{0}' and cannot be edited.</target>
<note />
</trans-unit>
<trans-unit id="This_is_an_invalid_namespace">
<source>This is an invalid namespace</source>
<target state="translated">Este é um namespace inválido</target>
......@@ -1017,6 +1032,16 @@
<target state="translated">'{0}' será alterado para público.</target>
<note />
</trans-unit>
<trans-unit id="generated_by_0_suffix">
<source>[generated by {0}]</source>
<target state="new">[generated by {0}]</target>
<note>{0} is the name of a generator.</note>
</trans-unit>
<trans-unit id="generated_suffix">
<source>[generated]</source>
<target state="new">[generated]</target>
<note />
</trans-unit>
<trans-unit id="given_workspace_doesn_t_support_undo">
<source>given workspace doesn't support undo</source>
<target state="translated">o workspace fornecido não dá suporte a desfazer</target>
......
......@@ -777,6 +777,21 @@
<target state="translated">Целевое пространство имен:</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_been_removed_from_the_project">
<source>The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_stopped_generating_this_file">
<source>The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="This_file_is_autogenerated_by_0_and_cannot_be_edited">
<source>This file is auto-generated by the generator '{0}' and cannot be edited.</source>
<target state="new">This file is auto-generated by the generator '{0}' and cannot be edited.</target>
<note />
</trans-unit>
<trans-unit id="This_is_an_invalid_namespace">
<source>This is an invalid namespace</source>
<target state="translated">Это недопустимое пространство имен.</target>
......@@ -1017,6 +1032,16 @@
<target state="translated">Элемент "{0}" будет изменен на открытый.</target>
<note />
</trans-unit>
<trans-unit id="generated_by_0_suffix">
<source>[generated by {0}]</source>
<target state="new">[generated by {0}]</target>
<note>{0} is the name of a generator.</note>
</trans-unit>
<trans-unit id="generated_suffix">
<source>[generated]</source>
<target state="new">[generated]</target>
<note />
</trans-unit>
<trans-unit id="given_workspace_doesn_t_support_undo">
<source>given workspace doesn't support undo</source>
<target state="translated">заданная рабочая область не поддерживает отмену.</target>
......
......@@ -777,6 +777,21 @@
<target state="translated">Hedef Ad Alanı:</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_been_removed_from_the_project">
<source>The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_stopped_generating_this_file">
<source>The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="This_file_is_autogenerated_by_0_and_cannot_be_edited">
<source>This file is auto-generated by the generator '{0}' and cannot be edited.</source>
<target state="new">This file is auto-generated by the generator '{0}' and cannot be edited.</target>
<note />
</trans-unit>
<trans-unit id="This_is_an_invalid_namespace">
<source>This is an invalid namespace</source>
<target state="translated">Bu geçersiz bir ad alanı</target>
......@@ -1017,6 +1032,16 @@
<target state="translated">'{0}' ortak olacak şekilde değiştirildi.</target>
<note />
</trans-unit>
<trans-unit id="generated_by_0_suffix">
<source>[generated by {0}]</source>
<target state="new">[generated by {0}]</target>
<note>{0} is the name of a generator.</note>
</trans-unit>
<trans-unit id="generated_suffix">
<source>[generated]</source>
<target state="new">[generated]</target>
<note />
</trans-unit>
<trans-unit id="given_workspace_doesn_t_support_undo">
<source>given workspace doesn't support undo</source>
<target state="translated">sağlanan çalışma alanı, geri almayı desteklemiyor</target>
......
......@@ -777,6 +777,21 @@
<target state="translated">目标命名空间:</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_been_removed_from_the_project">
<source>The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_stopped_generating_this_file">
<source>The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="This_file_is_autogenerated_by_0_and_cannot_be_edited">
<source>This file is auto-generated by the generator '{0}' and cannot be edited.</source>
<target state="new">This file is auto-generated by the generator '{0}' and cannot be edited.</target>
<note />
</trans-unit>
<trans-unit id="This_is_an_invalid_namespace">
<source>This is an invalid namespace</source>
<target state="translated">这是一个无效的命名空间</target>
......@@ -1017,6 +1032,16 @@
<target state="translated">“{0}”将更改为“公共”。</target>
<note />
</trans-unit>
<trans-unit id="generated_by_0_suffix">
<source>[generated by {0}]</source>
<target state="new">[generated by {0}]</target>
<note>{0} is the name of a generator.</note>
</trans-unit>
<trans-unit id="generated_suffix">
<source>[generated]</source>
<target state="new">[generated]</target>
<note />
</trans-unit>
<trans-unit id="given_workspace_doesn_t_support_undo">
<source>given workspace doesn't support undo</source>
<target state="translated">给定的工作区不支持撤消</target>
......
......@@ -777,6 +777,21 @@
<target state="translated">目標命名空間:</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_been_removed_from_the_project">
<source>The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has been removed from the project; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="The_generator_0_that_generated_this_file_has_stopped_generating_this_file">
<source>The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</source>
<target state="new">The generator '{0}' that generated this file has stopped generating this file; this file is no longer being included in your project.</target>
<note />
</trans-unit>
<trans-unit id="This_file_is_autogenerated_by_0_and_cannot_be_edited">
<source>This file is auto-generated by the generator '{0}' and cannot be edited.</source>
<target state="new">This file is auto-generated by the generator '{0}' and cannot be edited.</target>
<note />
</trans-unit>
<trans-unit id="This_is_an_invalid_namespace">
<source>This is an invalid namespace</source>
<target state="translated">這是無效的命名空間</target>
......@@ -1017,6 +1032,16 @@
<target state="translated">'{0}' 會變更為公用。</target>
<note />
</trans-unit>
<trans-unit id="generated_by_0_suffix">
<source>[generated by {0}]</source>
<target state="new">[generated by {0}]</target>
<note>{0} is the name of a generator.</note>
</trans-unit>
<trans-unit id="generated_suffix">
<source>[generated]</source>
<target state="new">[generated]</target>
<note />
</trans-unit>
<trans-unit id="given_workspace_doesn_t_support_undo">
<source>given workspace doesn't support undo</source>
<target state="translated">指定的工作區不支援復原</target>
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable enable
using System.Diagnostics.CodeAnalysis;
namespace Microsoft.CodeAnalysis.Utilities
{
internal static class GeneratorDriverRunResultExtensions
{
public static bool TryGetGeneratorAndHint(
this GeneratorDriverRunResult? generatorRunResult,
SyntaxTree tree,
[NotNullWhen(true)] out ISourceGenerator? generator,
[NotNullWhen(true)] out string? generatedSourceHintName)
{
if (generatorRunResult != null)
{
foreach (var generatorResult in generatorRunResult.Results)
{
foreach (var generatedSource in generatorResult.GeneratedSources)
{
if (generatedSource.SyntaxTree == tree)
{
generator = generatorResult.Generator;
generatedSourceHintName = generatedSource.HintName;
return true;
}
}
}
}
generator = null;
generatedSourceHintName = null;
return false;
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册