未验证 提交 703ed728 编写于 作者: M msftbot[bot] 提交者: GitHub

Merge pull request #42619 from mavasani/PortUseNullPropogation

Move UseNullPropagation analyzer/fixers/tests to shared layer
......@@ -47,6 +47,7 @@
<Compile Include="$(MSBuildThisFileDirectory)UseImplicitOrExplicitType\CSharpTypeStyleDiagnosticAnalyzerBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseImplicitOrExplicitType\CSharpUseExplicitTypeDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseImplicitOrExplicitType\CSharpUseImplicitTypeDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseNullPropagation\CSharpUseNullPropagationDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseObjectInitializer\CSharpUseObjectInitializerDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.Analyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.cs" />
......
......@@ -5,6 +5,8 @@
#nullable enable
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.LanguageServices;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
......@@ -31,8 +33,8 @@ protected override bool ShouldAnalyze(ParseOptions options)
protected override ISyntaxFacts GetSyntaxFacts()
=> CSharpSyntaxFacts.Instance;
protected override ISemanticFactsService GetSemanticFactsService()
=> CSharpSemanticFactsService.Instance;
protected override bool IsInExpressionTree(SemanticModel semanticModel, SyntaxNode node, INamedTypeSymbol? expressionTypeOpt, CancellationToken cancellationToken)
=> node.IsInExpressionTree(semanticModel, expressionTypeOpt, cancellationToken);
protected override bool TryAnalyzePatternCondition(
ISyntaxFacts syntaxFacts, SyntaxNode conditionNode,
......
......@@ -31,6 +31,7 @@
<Compile Include="$(MSBuildThisFileDirectory)UseExpressionBody\UseExpressionBodyCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseImplicitOrExplicitType\UseImplicitTypeCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseNullPropagation\CSharpUseNullPropagationCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseObjectInitializer\CSharpUseObjectInitializerCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseObjectInitializer\UseInitializerHelpers.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UsePatternMatching\CSharpAsAndNullCheckCodeFixProvider.cs" />
......
......@@ -49,6 +49,7 @@
<Compile Include="$(MSBuildThisFileDirectory)UseImplicitOrExplicitType\UseExplicitTypeTests_FixAllTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseImplicitOrExplicitType\UseImplicitTypeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseImplicitOrExplicitType\UseImplicitTypeTests_FixAllTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseNullPropagation\UseNullPropagationTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseObjectInitializer\UseObjectInitializerTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UsePatternMatching\CSharpAsAndNullCheckTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UsePatternMatching\CSharpAsAndNullCheckTests_FixAllTests.cs" />
......
......@@ -47,6 +47,7 @@
<Compile Include="$(MSBuildThisFileDirectory)UseCollectionInitializer\AbstractObjectCreationExpressionAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseCollectionInitializer\AbstractUseCollectionInitializerDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseCollectionInitializer\ObjectCreationExpressionAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseNullPropagation\AbstractUseNullPropagationDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseObjectInitializer\AbstractUseObjectInitializerDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseObjectInitializer\ObjectCreationExpressionAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseThrowExpression\AbstractUseThrowExpressionDiagnosticAnalyzer.cs" />
......
......@@ -244,4 +244,7 @@
<data name="Changes_to_expression_trees_may_result_in_behavior_changes_at_runtime" xml:space="preserve">
<value>Changes to expression trees may result in behavior changes at runtime</value>
</data>
<data name="Use_null_propagation" xml:space="preserve">
<value>Use null propagation</value>
</data>
</root>
\ No newline at end of file
......@@ -10,6 +10,11 @@
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.LanguageServices;
using System.Threading;
#if CODE_STYLE
using Microsoft.CodeAnalysis.Internal.Options;
#endif
namespace Microsoft.CodeAnalysis.UseNullPropagation
{
......@@ -39,7 +44,7 @@ internal abstract class AbstractUseNullPropagationDiagnosticAnalyzer<
protected AbstractUseNullPropagationDiagnosticAnalyzer()
: base(IDEDiagnosticIds.UseNullPropagationDiagnosticId,
CodeStyleOptions.PreferNullPropagation,
new LocalizableResourceString(nameof(FeaturesResources.Use_null_propagation), FeaturesResources.ResourceManager, typeof(FeaturesResources)),
new LocalizableResourceString(nameof(AnalyzersResources.Use_null_propagation), AnalyzersResources.ResourceManager, typeof(AnalyzersResources)),
new LocalizableResourceString(nameof(AnalyzersResources.Null_check_can_be_simplified), AnalyzersResources.ResourceManager, typeof(AnalyzersResources)))
{
}
......@@ -50,7 +55,7 @@ public override DiagnosticAnalyzerCategory GetAnalyzerCategory()
protected abstract bool ShouldAnalyze(ParseOptions options);
protected abstract ISyntaxFacts GetSyntaxFacts();
protected abstract ISemanticFactsService GetSemanticFactsService();
protected abstract bool IsInExpressionTree(SemanticModel semanticModel, SyntaxNode node, INamedTypeSymbol? expressionTypeOpt, CancellationToken cancellationToken);
protected abstract bool TryAnalyzePatternCondition(
ISyntaxFacts syntaxFacts, SyntaxNode conditionNode,
......@@ -157,8 +162,7 @@ protected override void InitializeWorker(AnalysisContext context)
// converting to c?.nullable doesn't affect the type
}
var semanticFacts = GetSemanticFactsService();
if (semanticFacts.IsInExpressionTree(semanticModel, conditionNode, expressionTypeOpt, context.CancellationToken))
if (IsInExpressionTree(semanticModel, conditionNode, expressionTypeOpt, context.CancellationToken))
{
return;
}
......
......@@ -207,6 +207,11 @@
<target state="new">Use coalesce expression</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="new">Use null propagation</target>
<note />
</trans-unit>
<trans-unit id="Use_throw_expression">
<source>Use 'throw' expression</source>
<target state="new">Use 'throw' expression</target>
......
......@@ -207,6 +207,11 @@
<target state="new">Use coalesce expression</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="new">Use null propagation</target>
<note />
</trans-unit>
<trans-unit id="Use_throw_expression">
<source>Use 'throw' expression</source>
<target state="new">Use 'throw' expression</target>
......
......@@ -207,6 +207,11 @@
<target state="new">Use coalesce expression</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="new">Use null propagation</target>
<note />
</trans-unit>
<trans-unit id="Use_throw_expression">
<source>Use 'throw' expression</source>
<target state="new">Use 'throw' expression</target>
......
......@@ -207,6 +207,11 @@
<target state="new">Use coalesce expression</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="new">Use null propagation</target>
<note />
</trans-unit>
<trans-unit id="Use_throw_expression">
<source>Use 'throw' expression</source>
<target state="new">Use 'throw' expression</target>
......
......@@ -207,6 +207,11 @@
<target state="new">Use coalesce expression</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="new">Use null propagation</target>
<note />
</trans-unit>
<trans-unit id="Use_throw_expression">
<source>Use 'throw' expression</source>
<target state="new">Use 'throw' expression</target>
......
......@@ -207,6 +207,11 @@
<target state="new">Use coalesce expression</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="new">Use null propagation</target>
<note />
</trans-unit>
<trans-unit id="Use_throw_expression">
<source>Use 'throw' expression</source>
<target state="new">Use 'throw' expression</target>
......
......@@ -207,6 +207,11 @@
<target state="new">Use coalesce expression</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="new">Use null propagation</target>
<note />
</trans-unit>
<trans-unit id="Use_throw_expression">
<source>Use 'throw' expression</source>
<target state="new">Use 'throw' expression</target>
......
......@@ -207,6 +207,11 @@
<target state="new">Use coalesce expression</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="new">Use null propagation</target>
<note />
</trans-unit>
<trans-unit id="Use_throw_expression">
<source>Use 'throw' expression</source>
<target state="new">Use 'throw' expression</target>
......
......@@ -207,6 +207,11 @@
<target state="new">Use coalesce expression</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="new">Use null propagation</target>
<note />
</trans-unit>
<trans-unit id="Use_throw_expression">
<source>Use 'throw' expression</source>
<target state="new">Use 'throw' expression</target>
......
......@@ -207,6 +207,11 @@
<target state="new">Use coalesce expression</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="new">Use null propagation</target>
<note />
</trans-unit>
<trans-unit id="Use_throw_expression">
<source>Use 'throw' expression</source>
<target state="new">Use 'throw' expression</target>
......
......@@ -207,6 +207,11 @@
<target state="new">Use coalesce expression</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="new">Use null propagation</target>
<note />
</trans-unit>
<trans-unit id="Use_throw_expression">
<source>Use 'throw' expression</source>
<target state="new">Use 'throw' expression</target>
......
......@@ -207,6 +207,11 @@
<target state="new">Use coalesce expression</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="new">Use null propagation</target>
<note />
</trans-unit>
<trans-unit id="Use_throw_expression">
<source>Use 'throw' expression</source>
<target state="new">Use 'throw' expression</target>
......
......@@ -207,6 +207,11 @@
<target state="new">Use coalesce expression</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="new">Use null propagation</target>
<note />
</trans-unit>
<trans-unit id="Use_throw_expression">
<source>Use 'throw' expression</source>
<target state="new">Use 'throw' expression</target>
......
......@@ -29,6 +29,7 @@
<Compile Include="$(MSBuildThisFileDirectory)UseCoalesceExpression\UseCoalesceExpressionCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseCoalesceExpression\UseCoalesceExpressionForNullableCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseCollectionInitializer\AbstractUseCollectionInitializerCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseNullPropagation\AbstractUseNullPropagationCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseObjectInitializer\AbstractUseObjectInitializerCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseThrowExpression\UseThrowExpressionCodeFixProvider.cs" />
</ItemGroup>
......
......@@ -65,7 +65,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
{
var syntaxFacts = document.GetRequiredLanguageService<ISyntaxFactsService>();
var semanticModel = await document.GetRequiredSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var generator = editor.Generator;
var generator = document.GetRequiredLanguageService<SyntaxGeneratorInternal>();
var root = editor.OriginalRoot;
foreach (var diagnostic in diagnostics)
......@@ -78,7 +78,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
var whenPartIsNullable = diagnostic.Properties.ContainsKey(UseNullPropagationConstants.WhenPartIsNullable);
editor.ReplaceNode(conditionalExpression,
(c, g) =>
(c, _) =>
{
syntaxFacts.GetPartsOfConditionalExpression(
c, out var currentCondition, out var currentWhenTrue, out var currentWhenFalse);
......@@ -95,7 +95,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
}
var newNode = CreateConditionalAccessExpression(
syntaxFacts, g, whenPartIsNullable, currentWhenPartToCheck, match, c);
syntaxFacts, generator, whenPartIsNullable, currentWhenPartToCheck, match, c);
newNode = newNode.WithTriviaFrom(c);
return newNode;
......@@ -104,7 +104,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
}
private SyntaxNode CreateConditionalAccessExpression(
ISyntaxFactsService syntaxFacts, SyntaxGenerator generator, bool whenPartIsNullable,
ISyntaxFactsService syntaxFacts, SyntaxGeneratorInternal generator, bool whenPartIsNullable,
SyntaxNode whenPart, SyntaxNode match, SyntaxNode currentConditional)
{
if (whenPartIsNullable)
......@@ -134,7 +134,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
}
private SyntaxNode CreateConditionalAccessExpression(
ISyntaxFactsService syntaxFacts, SyntaxGenerator generator,
ISyntaxFactsService syntaxFacts, SyntaxGeneratorInternal generator,
SyntaxNode whenPart, SyntaxNode match, SyntaxNode matchParent, SyntaxNode currentConditional)
{
if (matchParent is TMemberAccessExpression memberAccess)
......@@ -157,10 +157,10 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
return currentConditional;
}
private class MyCodeAction : CodeAction.DocumentChangeAction
private class MyCodeAction : CustomCodeActions.DocumentChangeAction
{
public MyCodeAction(Func<CancellationToken, Task<Document>> createChangedDocument)
: base(FeaturesResources.Use_null_propagation, createChangedDocument)
: base(AnalyzersResources.Use_null_propagation, createChangedDocument)
{
}
}
......
......@@ -2,6 +2,7 @@
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports System.Threading
Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.LanguageServices
Imports Microsoft.CodeAnalysis.UseNullPropagation
......@@ -29,8 +30,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UseNullPropagation
Return VisualBasicSyntaxFacts.Instance
End Function
Protected Overrides Function GetSemanticFactsService() As ISemanticFactsService
Return VisualBasicSemanticFactsService.Instance
Protected Overrides Function IsInExpressionTree(semanticModel As SemanticModel, node As SyntaxNode, expressionTypeOpt As INamedTypeSymbol, cancellationToken As CancellationToken) As Boolean
Return node.IsInExpressionTree(semanticModel, expressionTypeOpt, cancellationToken)
End Function
Protected Overrides Function TryAnalyzePatternCondition(syntaxFacts As ISyntaxFacts, conditionNode As SyntaxNode, ByRef conditionPartToCheck As SyntaxNode, ByRef isEquals As Boolean) As Boolean
......
......@@ -28,6 +28,7 @@
<Compile Include="$(MSBuildThisFileDirectory)UseCoalesceExpression\VisualBasicUseCoalesceExpressionDiagnosticAnalyzer.vb" />
<Compile Include="$(MSBuildThisFileDirectory)UseCoalesceExpression\VisualBasicUseCoalesceExpressionForNullableDiagnosticAnalyzer.vb" />
<Compile Include="$(MSBuildThisFileDirectory)UseCollectionInitializer\VisualBasicUseCollectionInitializerDiagnosticAnalyzer.vb" />
<Compile Include="$(MSBuildThisFileDirectory)UseNullPropagation\VisualBasicUseNullPropagationDiagnosticAnalyzer.vb" />
<Compile Include="$(MSBuildThisFileDirectory)UseObjectInitializer\VisualBasicUseObjectInitializerDiagnosticAnalyzer.vb" />
</ItemGroup>
</Project>
\ No newline at end of file
......@@ -24,6 +24,7 @@
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnusedMembers\VisualBasicRemoveUnusedMembersCodeFixProvider.vb" />
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnusedParametersAndValues\VisualBasicRemoveUnusedValuesCodeFixProvider.vb" />
<Compile Include="$(MSBuildThisFileDirectory)UseCollectionInitializer\VisualBasicUseCollectionInitializerCodeFixProvider.vb" />
<Compile Include="$(MSBuildThisFileDirectory)UseNullPropagation\VisualBasicUseNullPropagationCodeFixProvider.vb" />
<Compile Include="$(MSBuildThisFileDirectory)UseObjectInitializer\UseInitializerHelpers.vb" />
<Compile Include="$(MSBuildThisFileDirectory)UseObjectInitializer\VisualBasicUseObjectInitializerCodeFixProvider.vb" />
</ItemGroup>
......
......@@ -30,6 +30,7 @@
<Compile Include="$(MSBuildThisFileDirectory)UseCoalesceExpression\UseCoalesceExpressionForNullableTests.vb" />
<Compile Include="$(MSBuildThisFileDirectory)UseCoalesceExpression\UseCoalesceExpressionTests.vb" />
<Compile Include="$(MSBuildThisFileDirectory)UseCollectionInitializer\UseCollectionInitializerTests.vb" />
<Compile Include="$(MSBuildThisFileDirectory)UseNullPropagation\UseNullPropagationTests.vb" />
<Compile Include="$(MSBuildThisFileDirectory)UseObjectInitializer\UseObjectInitializerTests.vb" />
</ItemGroup>
</Project>
\ No newline at end of file
......@@ -1018,9 +1018,6 @@ This version used in: {2}</value>
<data name="Pascal_Case" xml:space="preserve">
<value>Pascal Case</value>
</data>
<data name="Use_null_propagation" xml:space="preserve">
<value>Use null propagation</value>
</data>
<data name="Variable_declaration_can_be_inlined" xml:space="preserve">
<value>Variable declaration can be inlined</value>
</data>
......
......@@ -2070,11 +2070,6 @@ Tato verze se používá zde: {2}.</target>
<target state="translated">PascalCase</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="translated">Použít šíření hodnot null</target>
<note />
</trans-unit>
<trans-unit id="Variable_declaration_can_be_inlined">
<source>Variable declaration can be inlined</source>
<target state="translated">Deklaraci proměnné je možné vložit do řádku.</target>
......
......@@ -2070,11 +2070,6 @@ Diese Version wird verwendet in: {2}</target>
<target state="translated">Pascal-Schreibweise</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="translated">NULL-Weitergabe verwenden</target>
<note />
</trans-unit>
<trans-unit id="Variable_declaration_can_be_inlined">
<source>Variable declaration can be inlined</source>
<target state="translated">Variablendeklaration kann inline erfolgen.</target>
......
......@@ -2070,11 +2070,6 @@ Esta versión se utiliza en: {2}</target>
<target state="translated">Pascal Case</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="translated">Usar propagación de null</target>
<note />
</trans-unit>
<trans-unit id="Variable_declaration_can_be_inlined">
<source>Variable declaration can be inlined</source>
<target state="translated">La declaración de variables se puede insertar</target>
......
......@@ -2070,11 +2070,6 @@ Version utilisée dans : {2}</target>
<target state="translated">Casse Pascal</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="translated">Utiliser la propagation nulle</target>
<note />
</trans-unit>
<trans-unit id="Variable_declaration_can_be_inlined">
<source>Variable declaration can be inlined</source>
<target state="translated">La déclaration de variable peut être inlined</target>
......
......@@ -2070,11 +2070,6 @@ Questa versione è usata {2}</target>
<target state="translated">Notazione Pascal</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="translated">Usa la propagazione di valori Null</target>
<note />
</trans-unit>
<trans-unit id="Variable_declaration_can_be_inlined">
<source>Variable declaration can be inlined</source>
<target state="translated">La dichiarazione di variabile può essere impostata come inline</target>
......
......@@ -2070,11 +2070,6 @@ This version used in: {2}</source>
<target state="translated">パスカル ケース</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="translated">null 値の反映を使用します</target>
<note />
</trans-unit>
<trans-unit id="Variable_declaration_can_be_inlined">
<source>Variable declaration can be inlined</source>
<target state="translated">変数の宣言をインライン化できます</target>
......
......@@ -2070,11 +2070,6 @@ This version used in: {2}</source>
<target state="translated">파스칼식 대/소문자</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="translated">Null 전파 사용</target>
<note />
</trans-unit>
<trans-unit id="Variable_declaration_can_be_inlined">
<source>Variable declaration can be inlined</source>
<target state="translated">변수 선언은 인라인될 수 있습니다.</target>
......
......@@ -2070,11 +2070,6 @@ Ta wersja jest używana wersja: {2}</target>
<target state="translated">PascalCase</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="translated">Użyj propagacji wartości null</target>
<note />
</trans-unit>
<trans-unit id="Variable_declaration_can_be_inlined">
<source>Variable declaration can be inlined</source>
<target state="translated">Deklaracja zmiennej może być śródwierszowa</target>
......
......@@ -2070,11 +2070,6 @@ Essa versão é usada no: {2}</target>
<target state="translated">Pascal Case</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="translated">Usar tratamento simplificado de nulo</target>
<note />
</trans-unit>
<trans-unit id="Variable_declaration_can_be_inlined">
<source>Variable declaration can be inlined</source>
<target state="translated">A declaração de variável pode ser embutida</target>
......
......@@ -2070,11 +2070,6 @@ This version used in: {2}</source>
<target state="translated">ВсеЧастиСПрописнойБуквы</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="translated">Используйте распространение значения NULL</target>
<note />
</trans-unit>
<trans-unit id="Variable_declaration_can_be_inlined">
<source>Variable declaration can be inlined</source>
<target state="translated">Объявление переменной может быть встроенным.</target>
......
......@@ -2070,11 +2070,6 @@ Bu sürüm şurada kullanılır: {2}</target>
<target state="translated">Baş Harfleri Büyük Olmak Üzere Bitişik</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="translated">Null yayılması kullan</target>
<note />
</trans-unit>
<trans-unit id="Variable_declaration_can_be_inlined">
<source>Variable declaration can be inlined</source>
<target state="translated">Değişken bildirimi satır içine alınabilir</target>
......
......@@ -2070,11 +2070,6 @@ This version used in: {2}</source>
<target state="translated">帕斯卡拼写法</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="translated">使用 null 传播</target>
<note />
</trans-unit>
<trans-unit id="Variable_declaration_can_be_inlined">
<source>Variable declaration can be inlined</source>
<target state="translated">可以内联变量声明</target>
......
......@@ -2070,11 +2070,6 @@ This version used in: {2}</source>
<target state="translated">Pascal 命名法的大小寫</target>
<note />
</trans-unit>
<trans-unit id="Use_null_propagation">
<source>Use null propagation</source>
<target state="translated">使用 null 傳播</target>
<note />
</trans-unit>
<trans-unit id="Variable_declaration_can_be_inlined">
<source>Variable declaration can be inlined</source>
<target state="translated">變數宣告可內置</target>
......
......@@ -3060,10 +3060,10 @@ internal override SyntaxNode MemberAccessExpressionWorker(SyntaxNode expression,
}
public override SyntaxNode ConditionalAccessExpression(SyntaxNode expression, SyntaxNode whenNotNull)
=> SyntaxFactory.ConditionalAccessExpression((ExpressionSyntax)expression, (ExpressionSyntax)whenNotNull);
=> SyntaxGeneratorInternal.ConditionalAccessExpression(expression, whenNotNull);
public override SyntaxNode MemberBindingExpression(SyntaxNode name)
=> SyntaxFactory.MemberBindingExpression((SimpleNameSyntax)name);
=> SyntaxGeneratorInternal.MemberBindingExpression(name);
public override SyntaxNode ElementBindingExpression(IEnumerable<SyntaxNode> arguments)
=> SyntaxFactory.ElementBindingExpression(
......
......@@ -44,5 +44,11 @@ internal static VariableDeclarationSyntax VariableDeclaration(SyntaxNode type, S
internal override SyntaxToken Identifier(string identifier)
=> SyntaxFactory.Identifier(identifier);
internal override SyntaxNode ConditionalAccessExpression(SyntaxNode expression, SyntaxNode whenNotNull)
=> SyntaxFactory.ConditionalAccessExpression((ExpressionSyntax)expression, (ExpressionSyntax)whenNotNull);
internal override SyntaxNode MemberBindingExpression(SyntaxNode name)
=> SyntaxFactory.MemberBindingExpression((SimpleNameSyntax)name);
}
}
......@@ -32,5 +32,9 @@ internal SyntaxNode LocalDeclarationStatement(SyntaxToken name, SyntaxNode initi
internal abstract SyntaxNode EqualsValueClause(SyntaxToken operatorToken, SyntaxNode value);
internal abstract SyntaxToken Identifier(string identifier);
internal abstract SyntaxNode ConditionalAccessExpression(SyntaxNode expression, SyntaxNode whenNotNull);
internal abstract SyntaxNode MemberBindingExpression(SyntaxNode name);
}
}
......@@ -44,5 +44,15 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGeneration
Friend Overrides Function Identifier(text As String) As SyntaxToken
Return SyntaxFactory.Identifier(text)
End Function
Friend Overrides Function ConditionalAccessExpression(expression As SyntaxNode, whenNotNull As SyntaxNode) As SyntaxNode
Return SyntaxFactory.ConditionalAccessExpression(
DirectCast(expression, ExpressionSyntax),
DirectCast(whenNotNull, ExpressionSyntax))
End Function
Friend Overrides Function MemberBindingExpression(name As SyntaxNode) As SyntaxNode
Return SyntaxFactory.SimpleMemberAccessExpression(DirectCast(name, SimpleNameSyntax))
End Function
End Class
End Namespace
......@@ -297,13 +297,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGeneration
End Function
Public Overrides Function ConditionalAccessExpression(expression As SyntaxNode, whenNotNull As SyntaxNode) As SyntaxNode
Return SyntaxFactory.ConditionalAccessExpression(
DirectCast(expression, ExpressionSyntax),
DirectCast(whenNotNull, ExpressionSyntax))
Return SyntaxGeneratorInternal.ConditionalAccessExpression(expression, whenNotNull)
End Function
Public Overrides Function MemberBindingExpression(name As SyntaxNode) As SyntaxNode
Return SyntaxFactory.SimpleMemberAccessExpression(DirectCast(name, SimpleNameSyntax))
Return SyntaxGeneratorInternal.MemberBindingExpression(name)
End Function
Public Overrides Function ElementBindingExpression(arguments As IEnumerable(Of SyntaxNode)) As SyntaxNode
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册