未验证 提交 eece9b92 编写于 作者: M Manish Vasani 提交者: GitHub

Merge branch 'master' into PortSimplifyInterpolation

......@@ -36,6 +36,7 @@
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnreachableCode\CSharpRemoveUnreachableCodeDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnreachableCode\RemoveUnreachableCodeHelpers.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SimplifyInterpolation\CSharpSimplifyInterpolationDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseAutoProperty\CSharpUseAutoPropertyAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseCoalesceExpression\CSharpUseCoalesceExpressionDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseCoalesceExpression\CSharpUseCoalesceExpressionForNullableDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseCompoundAssignment\CSharpUseCompoundAssignmentDiagnosticAnalyzer.cs" />
......
......@@ -22,6 +22,7 @@
<Compile Include="$(MSBuildThisFileDirectory)OrderModifiers\OrderModifiersTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnreachableCode\RemoveUnreachableCodeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SimplifyInterpolation\SimplifyInterpolationTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseAutoProperty\UseAutoPropertyTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseCoalesceExpression\UseCoalesceExpressionForNullableTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseCoalesceExpression\UseCoalesceExpressionTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseCompoundAssignment\UseCompoundAssignmentTests.cs" />
......
......@@ -18,7 +18,7 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.UseAutoProperty
public class UseAutoPropertyTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest
{
internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace)
=> (new CSharpUseAutoPropertyAnalyzer(), new CSharpUseAutoPropertyCodeFixProvider());
=> (new CSharpUseAutoPropertyAnalyzer(), GetCSharpUseAutoPropertyCodeFixProvider());
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseAutoProperty)]
public async Task TestSingleGetterFromField()
......
......@@ -49,6 +49,7 @@
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SimplifyInterpolation\AbstractSimplifyInterpolationDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SimplifyInterpolation\Helpers.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseAutoProperty\AbstractUseAutoPropertyAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseCoalesceExpression\AbstractUseCoalesceExpressionDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseCoalesceExpression\AbstractUseCoalesceExpressionForNullableDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseCollectionInitializer\AbstractObjectCreationExpressionAnalyzer.cs" />
......
......@@ -283,6 +283,9 @@
<data name="Simplify_interpolation" xml:space="preserve">
<value>Simplify interpolation</value>
</data>
<data name="Use_auto_property" xml:space="preserve">
<value>Use auto property</value>
</data>
<data name="Format_string_contains_invalid_placeholder" xml:space="preserve">
<value>Format string contains invalid placeholder</value>
</data>
......
......@@ -20,8 +20,8 @@ internal abstract class AbstractUseAutoPropertyAnalyzer<
where TExpression : SyntaxNode
{
private static readonly LocalizableString s_title =
new LocalizableResourceString(nameof(FeaturesResources.Use_auto_property),
FeaturesResources.ResourceManager, typeof(FeaturesResources));
new LocalizableResourceString(nameof(AnalyzersResources.Use_auto_property),
AnalyzersResources.ResourceManager, typeof(AnalyzersResources));
protected AbstractUseAutoPropertyAnalyzer()
: base(IDEDiagnosticIds.UseAutoPropertyDiagnosticId, CodeStyleOptions2.PreferAutoProperties, s_title, s_title)
......
......@@ -267,6 +267,11 @@
<target state="new">Use 'System.HashCode'</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="new">Use auto property</target>
<note />
</trans-unit>
<trans-unit id="Use_coalesce_expression">
<source>Use coalesce expression</source>
<target state="new">Use coalesce expression</target>
......
......@@ -267,6 +267,11 @@
<target state="new">Use 'System.HashCode'</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="new">Use auto property</target>
<note />
</trans-unit>
<trans-unit id="Use_coalesce_expression">
<source>Use coalesce expression</source>
<target state="new">Use coalesce expression</target>
......
......@@ -267,6 +267,11 @@
<target state="new">Use 'System.HashCode'</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="new">Use auto property</target>
<note />
</trans-unit>
<trans-unit id="Use_coalesce_expression">
<source>Use coalesce expression</source>
<target state="new">Use coalesce expression</target>
......
......@@ -267,6 +267,11 @@
<target state="new">Use 'System.HashCode'</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="new">Use auto property</target>
<note />
</trans-unit>
<trans-unit id="Use_coalesce_expression">
<source>Use coalesce expression</source>
<target state="new">Use coalesce expression</target>
......
......@@ -267,6 +267,11 @@
<target state="new">Use 'System.HashCode'</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="new">Use auto property</target>
<note />
</trans-unit>
<trans-unit id="Use_coalesce_expression">
<source>Use coalesce expression</source>
<target state="new">Use coalesce expression</target>
......
......@@ -267,6 +267,11 @@
<target state="new">Use 'System.HashCode'</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="new">Use auto property</target>
<note />
</trans-unit>
<trans-unit id="Use_coalesce_expression">
<source>Use coalesce expression</source>
<target state="new">Use coalesce expression</target>
......
......@@ -267,6 +267,11 @@
<target state="new">Use 'System.HashCode'</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="new">Use auto property</target>
<note />
</trans-unit>
<trans-unit id="Use_coalesce_expression">
<source>Use coalesce expression</source>
<target state="new">Use coalesce expression</target>
......
......@@ -267,6 +267,11 @@
<target state="new">Use 'System.HashCode'</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="new">Use auto property</target>
<note />
</trans-unit>
<trans-unit id="Use_coalesce_expression">
<source>Use coalesce expression</source>
<target state="new">Use coalesce expression</target>
......
......@@ -267,6 +267,11 @@
<target state="new">Use 'System.HashCode'</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="new">Use auto property</target>
<note />
</trans-unit>
<trans-unit id="Use_coalesce_expression">
<source>Use coalesce expression</source>
<target state="new">Use coalesce expression</target>
......
......@@ -267,6 +267,11 @@
<target state="new">Use 'System.HashCode'</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="new">Use auto property</target>
<note />
</trans-unit>
<trans-unit id="Use_coalesce_expression">
<source>Use coalesce expression</source>
<target state="new">Use coalesce expression</target>
......
......@@ -267,6 +267,11 @@
<target state="new">Use 'System.HashCode'</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="new">Use auto property</target>
<note />
</trans-unit>
<trans-unit id="Use_coalesce_expression">
<source>Use coalesce expression</source>
<target state="new">Use coalesce expression</target>
......
......@@ -267,6 +267,11 @@
<target state="new">Use 'System.HashCode'</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="new">Use auto property</target>
<note />
</trans-unit>
<trans-unit id="Use_coalesce_expression">
<source>Use coalesce expression</source>
<target state="new">Use coalesce expression</target>
......
......@@ -267,6 +267,11 @@
<target state="new">Use 'System.HashCode'</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="new">Use auto property</target>
<note />
</trans-unit>
<trans-unit id="Use_coalesce_expression">
<source>Use coalesce expression</source>
<target state="new">Use coalesce expression</target>
......
......@@ -203,7 +203,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UseAutoProperty
If node.Kind() = SyntaxKind.IdentifierName Then
Dim symbolInfo = semanticModel.GetSymbolInfo(node)
If field.Equals(symbolInfo.Symbol) Then
If VisualBasicSemanticFactsService.Instance.IsWrittenTo(semanticModel, node, cancellationToken) Then
If DirectCast(node, ExpressionSyntax).IsWrittenTo(semanticModel, cancellationToken) Then
Return True
End If
End If
......
......@@ -29,6 +29,8 @@
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnusedMembers\VisualBasicRemoveUnusedMembersDiagnosticAnalyzer.vb" />
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnusedParametersAndValues\VisualBasicRemoveUnusedParametersAndValuesDiagnosticAnalyzer.vb" />
<Compile Include="$(MSBuildThisFileDirectory)SimplifyInterpolation\VisualBasicSimplifyInterpolationDiagnosticAnalyzer.vb" />
<Compile Include="$(MSBuildThisFileDirectory)UseAutoProperty\Utilities.vb" />
<Compile Include="$(MSBuildThisFileDirectory)UseAutoProperty\VisualBasicUseAutoPropertyAnalyzer.vb" />
<Compile Include="$(MSBuildThisFileDirectory)UseCoalesceExpression\VisualBasicUseCoalesceExpressionDiagnosticAnalyzer.vb" />
<Compile Include="$(MSBuildThisFileDirectory)UseCoalesceExpression\VisualBasicUseCoalesceExpressionForNullableDiagnosticAnalyzer.vb" />
<Compile Include="$(MSBuildThisFileDirectory)UseCollectionInitializer\VisualBasicUseCollectionInitializerDiagnosticAnalyzer.vb" />
......
......@@ -13,7 +13,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.UseAutoProperty
Inherits AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest
Friend Overrides Function CreateDiagnosticProviderAndFixer(workspace As Workspace) As (DiagnosticAnalyzer, CodeFixProvider)
Return (New VisualBasicUseAutoPropertyAnalyzer(), New VisualBasicUseAutoPropertyCodeFixProvider())
Return (New VisualBasicUseAutoPropertyAnalyzer(), GetVisualBasicUseAutoPropertyCodeFixProvider())
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseAutoProperty)>
......
......@@ -31,6 +31,7 @@
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnusedParametersAndValues\RemoveUnusedValueExpressionStatementTests.vb" />
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnusedParametersAndValues\RemoveUnusedValuesTestsBase.vb" />
<Compile Include="$(MSBuildThisFileDirectory)SimplifyInterpolation\SimplifyInterpolationTests.vb" />
<Compile Include="$(MSBuildThisFileDirectory)UseAutoProperty\UseAutoPropertyTests.vb" />
<Compile Include="$(MSBuildThisFileDirectory)UseCoalesceExpression\UseCoalesceExpressionForNullableTests.vb" />
<Compile Include="$(MSBuildThisFileDirectory)UseCoalesceExpression\UseCoalesceExpressionTests.vb" />
<Compile Include="$(MSBuildThisFileDirectory)UseCollectionInitializer\UseCollectionInitializerTests.vb" />
......
......@@ -69,15 +69,15 @@ public override string GetMessage(IFormatProvider formatProvider = null)
public override bool Equals(Diagnostic obj)
{
var other = obj as SuppressionDiagnostic;
if (other == null)
if (ReferenceEquals(this, obj))
{
return false;
return true;
}
if (ReferenceEquals(this, other))
var other = obj as SuppressionDiagnostic;
if (other == null)
{
return true;
return false;
}
return Equals(_originalDiagnostic, other._originalDiagnostic) &&
......
......@@ -87,15 +87,15 @@ public override IReadOnlyList<Location> AdditionalLocations
public override bool Equals(Diagnostic? obj)
{
var other = obj as DiagnosticWithProgrammaticSuppression;
if (other == null)
if (ReferenceEquals(this, obj))
{
return false;
return true;
}
if (ReferenceEquals(this, other))
var other = obj as DiagnosticWithProgrammaticSuppression;
if (other == null)
{
return true;
return false;
}
return Equals(_originalUnsuppressedDiagnostic, other._originalUnsuppressedDiagnostic) &&
......
......@@ -173,6 +173,11 @@ public sealed class DiagnosticDescriptor : IEquatable<DiagnosticDescriptor?>
public bool Equals(DiagnosticDescriptor? other)
{
if (ReferenceEquals(this, other))
{
return true;
}
return
other != null &&
this.Category == other.Category &&
......
......@@ -150,7 +150,7 @@ public override bool Equals(object? obj)
public override bool Equals(Diagnostic? obj)
{
if (this == obj)
if (ReferenceEquals(this, obj))
{
return true;
}
......
......@@ -146,6 +146,11 @@ public override IReadOnlyList<Location> AdditionalLocations
public override bool Equals(Diagnostic? obj)
{
if (ReferenceEquals(this, obj))
{
return true;
}
var other = obj as SimpleDiagnostic;
if (other == null)
{
......
......@@ -3,14 +3,16 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.Diagnostics
{
/// <summary>
/// Programmatic suppression of a <see cref="Diagnostic"/> by a <see cref="DiagnosticSuppressor"/>.
/// </summary>
public struct Suppression
public struct Suppression : IEquatable<Suppression>
{
private Suppression(SuppressionDescriptor descriptor, Diagnostic suppressedDiagnostic)
{
......@@ -48,5 +50,34 @@ public static Suppression Create(SuppressionDescriptor descriptor, Diagnostic su
/// Diagnostic suppressed by this suppression.
/// </summary>
public Diagnostic SuppressedDiagnostic { get; }
public static bool operator ==(Suppression left, Suppression right)
{
return left.Equals(right);
}
public static bool operator !=(Suppression left, Suppression right)
{
return !(left == right);
}
public override bool Equals(object obj)
{
return obj is Suppression suppression
&& Equals(suppression);
}
public bool Equals(Suppression other)
{
return EqualityComparer<SuppressionDescriptor>.Default.Equals(Descriptor, other.Descriptor)
&& EqualityComparer<Diagnostic>.Default.Equals(SuppressedDiagnostic, other.SuppressedDiagnostic);
}
public override int GetHashCode()
{
return Hash.Combine(
EqualityComparer<SuppressionDescriptor>.Default.GetHashCode(Descriptor),
EqualityComparer<Diagnostic>.Default.GetHashCode(SuppressedDiagnostic));
}
}
}
Microsoft.CodeAnalysis.CommandLineSourceFile.CommandLineSourceFile(string path, bool isScript, bool isInputRedirected) -> void
Microsoft.CodeAnalysis.CommandLineSourceFile.IsInputRedirected.get -> bool
Microsoft.CodeAnalysis.Diagnostics.Suppression.Equals(Microsoft.CodeAnalysis.Diagnostics.Suppression other) -> bool
Microsoft.CodeAnalysis.GeneratorAttribute
Microsoft.CodeAnalysis.GeneratorAttribute.GeneratorAttribute() -> void
Microsoft.CodeAnalysis.GeneratorDriver
......@@ -26,5 +27,9 @@ Microsoft.CodeAnalysis.SourceGeneratorContext.SyntaxReceiver.get -> Microsoft.Co
Microsoft.CodeAnalysis.SyntaxNode.FirstAncestorOrSelf<TNode, TArg>(System.Func<TNode, TArg, bool> predicate, TArg argument, bool ascendOutOfTrivia = true) -> TNode
Microsoft.CodeAnalysis.SyntaxReceiverCreator
override Microsoft.CodeAnalysis.Diagnostics.AnalyzerFileReference.GetGenerators() -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ISourceGenerator>
override Microsoft.CodeAnalysis.Diagnostics.Suppression.Equals(object obj) -> bool
override Microsoft.CodeAnalysis.Diagnostics.Suppression.GetHashCode() -> int
static Microsoft.CodeAnalysis.Diagnostics.Suppression.operator !=(Microsoft.CodeAnalysis.Diagnostics.Suppression left, Microsoft.CodeAnalysis.Diagnostics.Suppression right) -> bool
static Microsoft.CodeAnalysis.Diagnostics.Suppression.operator ==(Microsoft.CodeAnalysis.Diagnostics.Suppression left, Microsoft.CodeAnalysis.Diagnostics.Suppression right) -> bool
virtual Microsoft.CodeAnalysis.Diagnostics.AnalyzerReference.GetGenerators() -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ISourceGenerator>
const Microsoft.CodeAnalysis.WellKnownDiagnosticTags.CustomObsolete = "CustomObsolete" -> string
......@@ -10,11 +10,13 @@
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.MakeLocalFunctionStatic;
using Microsoft.CodeAnalysis.CSharp.UseAutoProperty;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.UnitTests.Diagnostics;
using Microsoft.CodeAnalysis.VisualBasic.UseAutoProperty;
using Roslyn.Test.Utilities;
using Roslyn.Utilities;
using Xunit;
......@@ -238,6 +240,12 @@ private void AssertNoAnalyzerExceptionDiagnostics(IEnumerable<Diagnostic> diagno
// https://github.com/dotnet/roslyn/issues/43056 blocks porting the fixer to CodeStyle layer.
protected static CodeFixProvider GetMakeLocalFunctionStaticCodeFixProvider() => new MakeLocalFunctionStaticCodeFixProvider();
// https://github.com/dotnet/roslyn/issues/43091 blocks porting the fixer to CodeStyle layer.
protected static CodeFixProvider GetCSharpUseAutoPropertyCodeFixProvider() => new CSharpUseAutoPropertyCodeFixProvider();
// https://github.com/dotnet/roslyn/issues/43091 blocks porting the fixer to CodeStyle layer.
protected static CodeFixProvider GetVisualBasicUseAutoPropertyCodeFixProvider() => new VisualBasicUseAutoPropertyCodeFixProvider();
#endregion
}
}
......@@ -816,9 +816,6 @@ Do you want to continue?</value>
<data name="attribute" xml:space="preserve">
<value>attribute</value>
</data>
<data name="Use_auto_property" xml:space="preserve">
<value>Use auto property</value>
</data>
<data name="Replace_0_and_1_with_property" xml:space="preserve">
<value>Replace '{0}' and '{1}' with property</value>
</data>
......
......@@ -55,7 +55,7 @@ public sealed override Task RegisterCodeFixesAsync(CodeFixContext context)
context.RegisterCodeFix(
new UseAutoPropertyCodeAction(
FeaturesResources.Use_auto_property,
AnalyzersResources.Use_auto_property,
c => ProcessResultAsync(context, diagnostic, c),
priority),
diagnostic);
......@@ -334,7 +334,7 @@ private async Task<SyntaxNode> FormatAsync(SyntaxNode newRoot, Document document
return true;
}
private class UseAutoPropertyCodeAction : CodeAction.SolutionChangeAction
private class UseAutoPropertyCodeAction : CustomCodeActions.SolutionChangeAction
{
public UseAutoPropertyCodeAction(string title, Func<CancellationToken, Task<Solution>> createChangedSolution, CodeActionPriority priority)
: base(title, createChangedSolution, title)
......
......@@ -1673,11 +1673,6 @@ Chcete pokračovat?</target>
<target state="translated">atribut</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="translated">Použít automatickou vlastnost</target>
<note />
</trans-unit>
<trans-unit id="Replace_0_and_1_with_property">
<source>Replace '{0}' and '{1}' with property</source>
<target state="translated">Nahradit {0} a {1} vlastností</target>
......
......@@ -1673,11 +1673,6 @@ Möchten Sie fortfahren?</target>
<target state="translated">Attribut</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="translated">Automatisch generierte Eigenschaft verwenden</target>
<note />
</trans-unit>
<trans-unit id="Replace_0_and_1_with_property">
<source>Replace '{0}' and '{1}' with property</source>
<target state="translated">"{0}" und "{1}" durch Eigenschaft ersetzen</target>
......
......@@ -1673,11 +1673,6 @@ Do you want to continue?</source>
<target state="translated">atributo</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="translated">Usar propiedad automática</target>
<note />
</trans-unit>
<trans-unit id="Replace_0_and_1_with_property">
<source>Replace '{0}' and '{1}' with property</source>
<target state="translated">Reemplazar '{0}' y '{1}' por la propiedad</target>
......
......@@ -1673,11 +1673,6 @@ Voulez-vous continuer ?</target>
<target state="translated">attribut</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="translated">Utiliser auto-property</target>
<note />
</trans-unit>
<trans-unit id="Replace_0_and_1_with_property">
<source>Replace '{0}' and '{1}' with property</source>
<target state="translated">Remplacer '{0}' et '{1}' par une propriété</target>
......
......@@ -1673,11 +1673,6 @@ Continuare?</target>
<target state="translated">attributo</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="translated">Usa la proprietà automatica</target>
<note />
</trans-unit>
<trans-unit id="Replace_0_and_1_with_property">
<source>Replace '{0}' and '{1}' with property</source>
<target state="translated">Sostituisci '{0}' e '{1}' con la proprietà</target>
......
......@@ -1673,11 +1673,6 @@ Do you want to continue?</source>
<target state="translated">属性</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="translated">自動プロパティを使用する</target>
<note />
</trans-unit>
<trans-unit id="Replace_0_and_1_with_property">
<source>Replace '{0}' and '{1}' with property</source>
<target state="translated">{0}' および '{1}' をプロパティと置換する</target>
......
......@@ -1673,11 +1673,6 @@ Do you want to continue?</source>
<target state="translated">특성</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="translated">auto 속성 사용</target>
<note />
</trans-unit>
<trans-unit id="Replace_0_and_1_with_property">
<source>Replace '{0}' and '{1}' with property</source>
<target state="translated">속성으로 '{0}' 및 '{1}' 바꾸기</target>
......
......@@ -1673,11 +1673,6 @@ Czy chcesz kontynuować?</target>
<target state="translated">atrybut</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="translated">Użyj właściwości automatycznej</target>
<note />
</trans-unit>
<trans-unit id="Replace_0_and_1_with_property">
<source>Replace '{0}' and '{1}' with property</source>
<target state="translated">Zastąp elementy „{0}” i „{1}” właściwością</target>
......
......@@ -1673,11 +1673,6 @@ Deseja continuar?</target>
<target state="translated">atributo</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="translated">Usar a propriedade auto</target>
<note />
</trans-unit>
<trans-unit id="Replace_0_and_1_with_property">
<source>Replace '{0}' and '{1}' with property</source>
<target state="translated">Substituir "{0}" e "{1}" por propriedades</target>
......
......@@ -1673,11 +1673,6 @@ Do you want to continue?</source>
<target state="translated">атрибут</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="translated">Использовать свойство auto</target>
<note />
</trans-unit>
<trans-unit id="Replace_0_and_1_with_property">
<source>Replace '{0}' and '{1}' with property</source>
<target state="translated">Заменить "{0}" и "{1}" свойством</target>
......
......@@ -1673,11 +1673,6 @@ Devam etmek istiyor musunuz?</target>
<target state="translated">öznitelik</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="translated">Otomatik özellik kullan</target>
<note />
</trans-unit>
<trans-unit id="Replace_0_and_1_with_property">
<source>Replace '{0}' and '{1}' with property</source>
<target state="translated">{0}' ve '{1}' öğesini özellikle değiştir</target>
......
......@@ -1673,11 +1673,6 @@ Do you want to continue?</source>
<target state="translated">属性</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="translated">使用自动属性</target>
<note />
</trans-unit>
<trans-unit id="Replace_0_and_1_with_property">
<source>Replace '{0}' and '{1}' with property</source>
<target state="translated">使用属性替代“{0}”和“{1}”</target>
......
......@@ -1673,11 +1673,6 @@ Do you want to continue?</source>
<target state="translated">屬性</target>
<note />
</trans-unit>
<trans-unit id="Use_auto_property">
<source>Use auto property</source>
<target state="translated">使用 Auto 屬性</target>
<note />
</trans-unit>
<trans-unit id="Replace_0_and_1_with_property">
<source>Replace '{0}' and '{1}' with property</source>
<target state="translated">以屬性取代 '{0}' 和 '{1}'</target>
......
......@@ -219,5 +219,127 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
Return OperatorPrecedence.PrecedenceNone
End Select
End Function
<Extension()>
Public Function IsInOutContext(expression As ExpressionSyntax) As Boolean
' NOTE(cyrusn): VB has no concept of an out context. Even when a parameter has an
' '<Out>' attribute on it, it's still treated as ref by VB. So we always return false
' here.
Return False
End Function
<Extension()>
Public Function IsInRefContext(expression As ExpressionSyntax, semanticModel As SemanticModel, cancellationToken As CancellationToken) As Boolean
Dim simpleArgument = TryCast(expression?.Parent, SimpleArgumentSyntax)
If simpleArgument Is Nothing Then
Return False
ElseIf simpleArgument.IsNamed Then
Dim info = semanticModel.GetSymbolInfo(simpleArgument.NameColonEquals.Name, cancellationToken)
Dim parameter = TryCast(info.GetAnySymbol(), IParameterSymbol)
Return parameter IsNot Nothing AndAlso parameter.RefKind <> RefKind.None
Else
Dim argumentList = TryCast(simpleArgument.Parent, ArgumentListSyntax)
If argumentList IsNot Nothing Then
Dim parent = argumentList.Parent
Dim index = argumentList.Arguments.IndexOf(simpleArgument)
Dim info = semanticModel.GetSymbolInfo(parent, cancellationToken)
Dim symbol = info.GetAnySymbol()
If TypeOf symbol Is IMethodSymbol Then
Dim method = DirectCast(symbol, IMethodSymbol)
If index < method.Parameters.Length Then
Return method.Parameters(index).RefKind <> RefKind.None
End If
ElseIf TypeOf symbol Is IPropertySymbol Then
Dim prop = DirectCast(symbol, IPropertySymbol)
If index < prop.Parameters.Length Then
Return prop.Parameters(index).RefKind <> RefKind.None
End If
End If
End If
End If
Return False
End Function
<Extension()>
Public Function IsInInContext(expression As ExpressionSyntax) As Boolean
' NOTE: VB does not support in parameters. Always return False here.
Return False
End Function
<Extension()>
Public Function IsOnlyWrittenTo(expression As ExpressionSyntax) As Boolean
If expression.IsRightSideOfDot() Then
expression = TryCast(expression.Parent, ExpressionSyntax)
End If
If expression IsNot Nothing Then
If expression.IsInOutContext() Then
Return True
End If
If expression.IsParentKind(SyntaxKind.SimpleAssignmentStatement) Then
Dim assignmentStatement = DirectCast(expression.Parent, AssignmentStatementSyntax)
If expression Is assignmentStatement.Left Then
Return True
End If
End If
If expression.IsParentKind(SyntaxKind.NameColonEquals) AndAlso
expression.Parent.IsParentKind(SyntaxKind.SimpleArgument) Then
' <C(Prop:=1)>
' this is only a write to Prop
Return True
End If
If expression.IsChildNode(Of NamedFieldInitializerSyntax)(Function(n) n.Name) Then
Return True
End If
Return False
End If
Return False
End Function
<Extension()>
Public Function IsWrittenTo(expression As ExpressionSyntax, semanticModel As SemanticModel, cancellationToken As CancellationToken) As Boolean
If IsOnlyWrittenTo(expression) Then
Return True
End If
If expression.IsRightSideOfDot() Then
expression = TryCast(expression.Parent, ExpressionSyntax)
End If
If expression IsNot Nothing Then
If expression.IsInRefContext(semanticModel, cancellationToken) Then
Return True
End If
If TypeOf expression.Parent Is AssignmentStatementSyntax Then
Dim assignmentStatement = DirectCast(expression.Parent, AssignmentStatementSyntax)
If expression Is assignmentStatement.Left Then
Return True
End If
End If
If expression.IsChildNode(Of NamedFieldInitializerSyntax)(Function(n) n.Name) Then
Return True
End If
Return False
End If
Return False
End Function
End Module
End Namespace
......@@ -213,128 +213,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
DirectCast(expression, ObjectCreationExpressionSyntax).ArgumentList Is Nothing
End Function
<Extension()>
Public Function IsInOutContext(expression As ExpressionSyntax) As Boolean
' NOTE(cyrusn): VB has no concept of an out context. Even when a parameter has an
' '<Out>' attribute on it, it's still treated as ref by VB. So we always return false
' here.
Return False
End Function
<Extension()>
Public Function IsInRefContext(expression As ExpressionSyntax, semanticModel As SemanticModel, cancellationToken As CancellationToken) As Boolean
Dim simpleArgument = TryCast(expression?.Parent, SimpleArgumentSyntax)
If simpleArgument Is Nothing Then
Return False
ElseIf simpleArgument.IsNamed Then
Dim info = semanticModel.GetSymbolInfo(simpleArgument.NameColonEquals.Name, cancellationToken)
Dim parameter = TryCast(info.GetAnySymbol(), IParameterSymbol)
Return parameter IsNot Nothing AndAlso parameter.RefKind <> RefKind.None
Else
Dim argumentList = TryCast(simpleArgument.Parent, ArgumentListSyntax)
If argumentList IsNot Nothing Then
Dim parent = argumentList.Parent
Dim index = argumentList.Arguments.IndexOf(simpleArgument)
Dim info = semanticModel.GetSymbolInfo(parent, cancellationToken)
Dim symbol = info.GetAnySymbol()
If TypeOf symbol Is IMethodSymbol Then
Dim method = DirectCast(symbol, IMethodSymbol)
If index < method.Parameters.Length Then
Return method.Parameters(index).RefKind <> RefKind.None
End If
ElseIf TypeOf symbol Is IPropertySymbol Then
Dim prop = DirectCast(symbol, IPropertySymbol)
If index < prop.Parameters.Length Then
Return prop.Parameters(index).RefKind <> RefKind.None
End If
End If
End If
End If
Return False
End Function
<Extension()>
Public Function IsInInContext(expression As ExpressionSyntax) As Boolean
' NOTE: VB does not support in parameters. Always return False here.
Return False
End Function
<Extension()>
Public Function IsOnlyWrittenTo(expression As ExpressionSyntax) As Boolean
If expression.IsRightSideOfDot() Then
expression = TryCast(expression.Parent, ExpressionSyntax)
End If
If expression IsNot Nothing Then
If expression.IsInOutContext() Then
Return True
End If
If expression.IsParentKind(SyntaxKind.SimpleAssignmentStatement) Then
Dim assignmentStatement = DirectCast(expression.Parent, AssignmentStatementSyntax)
If expression Is assignmentStatement.Left Then
Return True
End If
End If
If expression.IsParentKind(SyntaxKind.NameColonEquals) AndAlso
expression.Parent.IsParentKind(SyntaxKind.SimpleArgument) Then
' <C(Prop:=1)>
' this is only a write to Prop
Return True
End If
If expression.IsChildNode(Of NamedFieldInitializerSyntax)(Function(n) n.Name) Then
Return True
End If
Return False
End If
Return False
End Function
<Extension()>
Public Function IsWrittenTo(expression As ExpressionSyntax, semanticModel As SemanticModel, cancellationToken As CancellationToken) As Boolean
If IsOnlyWrittenTo(expression) Then
Return True
End If
If expression.IsRightSideOfDot() Then
expression = TryCast(expression.Parent, ExpressionSyntax)
End If
If expression IsNot Nothing Then
If expression.IsInRefContext(semanticModel, cancellationToken) Then
Return True
End If
If TypeOf expression.Parent Is AssignmentStatementSyntax Then
Dim assignmentStatement = DirectCast(expression.Parent, AssignmentStatementSyntax)
If expression Is assignmentStatement.Left Then
Return True
End If
End If
If expression.IsChildNode(Of NamedFieldInitializerSyntax)(Function(n) n.Name) Then
Return True
End If
Return False
End If
Return False
End Function
<Extension()>
Public Function IsMeMyBaseOrMyClass(expression As ExpressionSyntax) As Boolean
If expression Is Nothing Then
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册