From 76852a285b9f0249062f861ecdb37cb01fec6a87 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sat, 14 Jul 2018 14:04:16 -0700 Subject: [PATCH] Add code fixer to add [Obsolete] attribute on code that gets an 'obsolete' warning. --- ...harpAddObsoleteAttributeCodeFixProvider.cs | 26 +++++ .../CSharpFeaturesResources.Designer.cs | 9 ++ .../Portable/CSharpFeaturesResources.resx | 3 + .../xlf/CSharpFeaturesResources.cs.xlf | 5 + .../xlf/CSharpFeaturesResources.de.xlf | 5 + .../xlf/CSharpFeaturesResources.es.xlf | 5 + .../xlf/CSharpFeaturesResources.fr.xlf | 5 + .../xlf/CSharpFeaturesResources.it.xlf | 5 + .../xlf/CSharpFeaturesResources.ja.xlf | 5 + .../xlf/CSharpFeaturesResources.ko.xlf | 5 + .../xlf/CSharpFeaturesResources.pl.xlf | 5 + .../xlf/CSharpFeaturesResources.pt-BR.xlf | 5 + .../xlf/CSharpFeaturesResources.ru.xlf | 5 + .../xlf/CSharpFeaturesResources.tr.xlf | 5 + .../xlf/CSharpFeaturesResources.zh-Hans.xlf | 5 + .../xlf/CSharpFeaturesResources.zh-Hant.xlf | 5 + ...ractAddObsoleteAttributeCodeFixProvider.cs | 101 ++++++++++++++++++ ...asicAddObsoleteAttributeCodeFixProvider.vb | 23 ++++ .../Portable/VBFeaturesResources.Designer.vb | 9 ++ .../Portable/VBFeaturesResources.resx | 3 + .../Portable/xlf/VBFeaturesResources.cs.xlf | 5 + .../Portable/xlf/VBFeaturesResources.de.xlf | 5 + .../Portable/xlf/VBFeaturesResources.es.xlf | 5 + .../Portable/xlf/VBFeaturesResources.fr.xlf | 5 + .../Portable/xlf/VBFeaturesResources.it.xlf | 5 + .../Portable/xlf/VBFeaturesResources.ja.xlf | 5 + .../Portable/xlf/VBFeaturesResources.ko.xlf | 5 + .../Portable/xlf/VBFeaturesResources.pl.xlf | 5 + .../xlf/VBFeaturesResources.pt-BR.xlf | 5 + .../Portable/xlf/VBFeaturesResources.ru.xlf | 5 + .../Portable/xlf/VBFeaturesResources.tr.xlf | 5 + .../xlf/VBFeaturesResources.zh-Hans.xlf | 5 + .../xlf/VBFeaturesResources.zh-Hant.xlf | 5 + .../VisualBasicSyntaxFactsService.vb | 4 + 34 files changed, 308 insertions(+) create mode 100644 src/Features/CSharp/Portable/AddObsoleteAttribute/CSharpAddObsoleteAttributeCodeFixProvider.cs create mode 100644 src/Features/Core/Portable/AddObsoleteAttribute/AbstractAddObsoleteAttributeCodeFixProvider.cs create mode 100644 src/Features/VisualBasic/Portable/AddObsoleteAttribute/VisualBasicAddObsoleteAttributeCodeFixProvider.vb diff --git a/src/Features/CSharp/Portable/AddObsoleteAttribute/CSharpAddObsoleteAttributeCodeFixProvider.cs b/src/Features/CSharp/Portable/AddObsoleteAttribute/CSharpAddObsoleteAttributeCodeFixProvider.cs new file mode 100644 index 00000000000..8c4effa2269 --- /dev/null +++ b/src/Features/CSharp/Portable/AddObsoleteAttribute/CSharpAddObsoleteAttributeCodeFixProvider.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Immutable; +using System.Composition; +using Microsoft.CodeAnalysis.AddObsoleteAttribute; +using Microsoft.CodeAnalysis.CodeFixes; + +namespace Microsoft.CodeAnalysis.CSharp.AddObsoleteAttribute +{ + [ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(CSharpAddObsoleteAttributeCodeFixProvider)), Shared] + internal class CSharpAddObsoleteAttributeCodeFixProvider + : AbstractAddObsoleteAttributeCodeFixProvider + { + public override ImmutableArray FixableDiagnosticIds { get; } = + ImmutableArray.Create( + "CS0612", // 'C' is obsolete + "CS0618", // 'C' is obsolete (msg) + "CS0672" // Member 'D.F()' overrides obsolete member 'C.F()' + ); + + public CSharpAddObsoleteAttributeCodeFixProvider() + : base(CSharpSyntaxFactsService.Instance, CSharpFeaturesResources.Add_Obsolete) + { + } + } +} diff --git a/src/Features/CSharp/Portable/CSharpFeaturesResources.Designer.cs b/src/Features/CSharp/Portable/CSharpFeaturesResources.Designer.cs index c1965c3a5f4..8846193df81 100644 --- a/src/Features/CSharp/Portable/CSharpFeaturesResources.Designer.cs +++ b/src/Features/CSharp/Portable/CSharpFeaturesResources.Designer.cs @@ -70,6 +70,15 @@ internal class CSharpFeaturesResources { } } + /// + /// Looks up a localized string similar to Add [Obsolete]. + /// + internal static string Add_Obsolete { + get { + return ResourceManager.GetString("Add_Obsolete", resourceCulture); + } + } + /// /// Looks up a localized string similar to Add parentheses. /// diff --git a/src/Features/CSharp/Portable/CSharpFeaturesResources.resx b/src/Features/CSharp/Portable/CSharpFeaturesResources.resx index da4cd782e0c..b1d02e0ed4d 100644 --- a/src/Features/CSharp/Portable/CSharpFeaturesResources.resx +++ b/src/Features/CSharp/Portable/CSharpFeaturesResources.resx @@ -524,4 +524,7 @@ 'if' statement can be simplified + + Add [Obsolete] + \ No newline at end of file diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf index 073c001ca78..e285c161454 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf @@ -2,6 +2,11 @@ + + Add [Obsolete] + Add [Obsolete] + + Inline temporary variable Dočasná vložená proměnná diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf index 9ed519bcbc7..52f58f21512 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf @@ -2,6 +2,11 @@ + + Add [Obsolete] + Add [Obsolete] + + Inline temporary variable Inline temporär variabel diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf index f7e3035f556..8994ea29176 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf @@ -2,6 +2,11 @@ + + Add [Obsolete] + Add [Obsolete] + + Inline temporary variable Variable temporal en línea diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf index 09d6a4fd552..46ab2a348d3 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf @@ -2,6 +2,11 @@ + + Add [Obsolete] + Add [Obsolete] + + Inline temporary variable Variable temporaire inline diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf index 87930c60ddf..145dbbb2733 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf @@ -2,6 +2,11 @@ + + Add [Obsolete] + Add [Obsolete] + + Inline temporary variable Variabile temporanea inline diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf index b8e69cbd264..fc609cba333 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf @@ -2,6 +2,11 @@ + + Add [Obsolete] + Add [Obsolete] + + Inline temporary variable インラインの一時変数 diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf index 0e941a7171f..6e2c1a55037 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf @@ -2,6 +2,11 @@ + + Add [Obsolete] + Add [Obsolete] + + Inline temporary variable 인라인 임시 변수 diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf index c897bb14960..4f52c1066d7 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf @@ -2,6 +2,11 @@ + + Add [Obsolete] + Add [Obsolete] + + Inline temporary variable Wstawiona zmienna tymczasowa diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf index 5984c95348f..7d421f7d737 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf @@ -2,6 +2,11 @@ + + Add [Obsolete] + Add [Obsolete] + + Inline temporary variable Variável temporária embutida diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf index bb8eb956d59..af714fc7af7 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf @@ -2,6 +2,11 @@ + + Add [Obsolete] + Add [Obsolete] + + Inline temporary variable Встроенная временная переменная diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf index 7ab410f499d..c9f29cc0d3e 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf @@ -2,6 +2,11 @@ + + Add [Obsolete] + Add [Obsolete] + + Inline temporary variable Satır içi geçici değişken diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf index 7bb7a6f5173..b145803b72f 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf @@ -2,6 +2,11 @@ + + Add [Obsolete] + Add [Obsolete] + + Inline temporary variable 内联临时变量 diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf index c603520956b..f289748ae72 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf @@ -2,6 +2,11 @@ + + Add [Obsolete] + Add [Obsolete] + + Inline temporary variable 內嵌暫存變數 diff --git a/src/Features/Core/Portable/AddObsoleteAttribute/AbstractAddObsoleteAttributeCodeFixProvider.cs b/src/Features/Core/Portable/AddObsoleteAttribute/AbstractAddObsoleteAttributeCodeFixProvider.cs new file mode 100644 index 00000000000..4a8882dc16e --- /dev/null +++ b/src/Features/Core/Portable/AddObsoleteAttribute/AbstractAddObsoleteAttributeCodeFixProvider.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Immutable; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.CodeActions; +using Microsoft.CodeAnalysis.CodeFixes; +using Microsoft.CodeAnalysis.Editing; +using Microsoft.CodeAnalysis.LanguageServices; +using Microsoft.CodeAnalysis.Shared.Extensions; +using Roslyn.Utilities; + +namespace Microsoft.CodeAnalysis.AddObsoleteAttribute +{ + internal abstract class AbstractAddObsoleteAttributeCodeFixProvider + : SyntaxEditorBasedCodeFixProvider + { + private readonly ISyntaxFactsService _syntaxFacts; + private readonly string _title; + + protected AbstractAddObsoleteAttributeCodeFixProvider( + ISyntaxFactsService syntaxFacts, + string title) + { + _syntaxFacts = syntaxFacts; + _title = title; + } + + public override async Task RegisterCodeFixesAsync(CodeFixContext context) + { + var cancellationToken = context.CancellationToken; + var document = context.Document; + + var attribute = await GetObsoleteAttributeAsync(document, cancellationToken).ConfigureAwait(false); + if (attribute == null) + { + return; + } + + var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); + + var diagnotic = context.Diagnostics[0]; + var node = diagnotic.Location.FindNode(cancellationToken); + + var container = GetContainer(root, node); + + if (container == null) + { + return; + } + + context.RegisterCodeFix( + new MyCodeAction( + _title, + c => FixAsync(document, diagnotic, c)), + context.Diagnostics); + } + + private static async Task GetObsoleteAttributeAsync(Document document, CancellationToken cancellationToken) + { + var compilation = await document.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); + var attribute = compilation.GetTypeByMetadataName(typeof(ObsoleteAttribute).FullName); + return attribute; + } + + private SyntaxNode GetContainer(SyntaxNode root, SyntaxNode node) + { + return _syntaxFacts.GetContainingMemberDeclaration(root, node.SpanStart) ?? + _syntaxFacts.GetContainingTypeDeclaration(root, node.SpanStart); + } + + protected override async Task FixAllAsync( + Document document, ImmutableArray diagnostics, + SyntaxEditor editor, CancellationToken cancellationToken) + { + var obsoleteAttribute = await GetObsoleteAttributeAsync(document, cancellationToken).ConfigureAwait(false); + var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); + + var containers = diagnostics.Select(d => GetContainer(root, d.Location.FindNode(cancellationToken))) + .WhereNotNull() + .ToSet(); + + var generator = editor.Generator; + foreach (var container in containers) + { + editor.AddAttribute(container, + generator.Attribute(editor.Generator.TypeExpression(obsoleteAttribute))); + } + } + + private class MyCodeAction : CodeAction.DocumentChangeAction + { + public MyCodeAction(string title, Func> createChangedDocument) + : base(title, createChangedDocument, title) + { + } + } + } +} diff --git a/src/Features/VisualBasic/Portable/AddObsoleteAttribute/VisualBasicAddObsoleteAttributeCodeFixProvider.vb b/src/Features/VisualBasic/Portable/AddObsoleteAttribute/VisualBasicAddObsoleteAttributeCodeFixProvider.vb new file mode 100644 index 00000000000..783e8b027d8 --- /dev/null +++ b/src/Features/VisualBasic/Portable/AddObsoleteAttribute/VisualBasicAddObsoleteAttributeCodeFixProvider.vb @@ -0,0 +1,23 @@ +' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +Imports System.Collections.Immutable +Imports System.Composition +Imports Microsoft.CodeAnalysis.AddObsoleteAttribute +Imports Microsoft.CodeAnalysis.CodeFixes + +Namespace Microsoft.CodeAnalysis.VisualBasic.AddObsoleteAttribute + + Friend Class VisualBasicAddObsoleteAttributeCodeFixProvider + Inherits AbstractAddObsoleteAttributeCodeFixProvider + + Public Overrides ReadOnly Property FixableDiagnosticIds As ImmutableArray(Of String) = + ImmutableArray.Create( + "BC40000", ' 'C' is obsolete. (msg) + "BC40008" ' 'C' is obsolete. + ) + + Public Sub New() + MyBase.New(VisualBasicSyntaxFactsService.Instance, VBFeaturesResources.Add_Obsolete) + End Sub + End Class +End Namespace diff --git a/src/Features/VisualBasic/Portable/VBFeaturesResources.Designer.vb b/src/Features/VisualBasic/Portable/VBFeaturesResources.Designer.vb index 9096c7b7d3f..2edbf4c6960 100644 --- a/src/Features/VisualBasic/Portable/VBFeaturesResources.Designer.vb +++ b/src/Features/VisualBasic/Portable/VBFeaturesResources.Designer.vb @@ -102,6 +102,15 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.VBFeaturesResources End Get End Property + ''' + ''' Looks up a localized string similar to Add <Obsolete>. + ''' + Friend ReadOnly Property Add_Obsolete() As String + Get + Return ResourceManager.GetString("Add_Obsolete", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to Add Overloads. ''' diff --git a/src/Features/VisualBasic/Portable/VBFeaturesResources.resx b/src/Features/VisualBasic/Portable/VBFeaturesResources.resx index 7a77f0dedc6..60b7f9552c1 100644 --- a/src/Features/VisualBasic/Portable/VBFeaturesResources.resx +++ b/src/Features/VisualBasic/Portable/VBFeaturesResources.resx @@ -1250,4 +1250,7 @@ Sub(<parameterList>) <statement> 'If' statement can be simplified + + Add <Obsolete> + \ No newline at end of file diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.cs.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.cs.xlf index 993553924b9..5b5a16490cb 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.cs.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.cs.xlf @@ -2,6 +2,11 @@ + + Add <Obsolete> + Add <Obsolete> + + 'If' statement can be simplified 'If' statement can be simplified diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.de.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.de.xlf index 1e73c792387..d079bf19aa0 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.de.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.de.xlf @@ -2,6 +2,11 @@ + + Add <Obsolete> + Add <Obsolete> + + 'If' statement can be simplified 'If' statement can be simplified diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.es.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.es.xlf index df7eec423c9..f469af0f468 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.es.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.es.xlf @@ -2,6 +2,11 @@ + + Add <Obsolete> + Add <Obsolete> + + 'If' statement can be simplified 'If' statement can be simplified diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.fr.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.fr.xlf index e912f89ab0b..1b891d35eff 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.fr.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.fr.xlf @@ -2,6 +2,11 @@ + + Add <Obsolete> + Add <Obsolete> + + 'If' statement can be simplified 'If' statement can be simplified diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.it.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.it.xlf index 7908af20998..9da54944135 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.it.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.it.xlf @@ -2,6 +2,11 @@ + + Add <Obsolete> + Add <Obsolete> + + 'If' statement can be simplified 'If' statement can be simplified diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ja.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ja.xlf index 4055848641d..b855a9cb558 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ja.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ja.xlf @@ -2,6 +2,11 @@ + + Add <Obsolete> + Add <Obsolete> + + 'If' statement can be simplified 'If' statement can be simplified diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ko.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ko.xlf index 639847e7a98..11625666920 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ko.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ko.xlf @@ -2,6 +2,11 @@ + + Add <Obsolete> + Add <Obsolete> + + 'If' statement can be simplified 'If' statement can be simplified diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.pl.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.pl.xlf index ae37fbb0764..67bb5bd4697 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.pl.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.pl.xlf @@ -2,6 +2,11 @@ + + Add <Obsolete> + Add <Obsolete> + + 'If' statement can be simplified 'If' statement can be simplified diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.pt-BR.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.pt-BR.xlf index 283e027f5f9..b9e8092e015 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.pt-BR.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.pt-BR.xlf @@ -2,6 +2,11 @@ + + Add <Obsolete> + Add <Obsolete> + + 'If' statement can be simplified 'If' statement can be simplified diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ru.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ru.xlf index 86449b71cb0..2025276083a 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ru.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ru.xlf @@ -2,6 +2,11 @@ + + Add <Obsolete> + Add <Obsolete> + + 'If' statement can be simplified 'If' statement can be simplified diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.tr.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.tr.xlf index be8b506be53..932ac45f93a 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.tr.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.tr.xlf @@ -2,6 +2,11 @@ + + Add <Obsolete> + Add <Obsolete> + + 'If' statement can be simplified 'If' statement can be simplified diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.zh-Hans.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.zh-Hans.xlf index 30f20c17362..86d5f5517a2 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.zh-Hans.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.zh-Hans.xlf @@ -2,6 +2,11 @@ + + Add <Obsolete> + Add <Obsolete> + + 'If' statement can be simplified 'If' statement can be simplified diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.zh-Hant.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.zh-Hant.xlf index 18f65452149..86837799fb9 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.zh-Hant.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.zh-Hant.xlf @@ -2,6 +2,11 @@ + + Add <Obsolete> + Add <Obsolete> + + 'If' statement can be simplified 'If' statement can be simplified diff --git a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxFactsService.vb b/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxFactsService.vb index 1ed9d73d429..aaa5470ad15 100644 --- a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxFactsService.vb +++ b/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxFactsService.vb @@ -809,6 +809,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic Return node End If + If TypeOf node Is MethodBaseSyntax AndAlso Not TypeOf node.Parent Is MethodBlockBaseSyntax Then + Return node + End If + If TypeOf node Is PropertyStatementSyntax AndAlso Not TypeOf node.Parent Is PropertyBlockSyntax Then Return node End If -- GitLab