/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/VisualBasic/VisualBasicUpgradeMSBuildWorkspaceAnalyzer.vb
34 строки
1 KB
Cyrus Najmabadi
Organize VB imports
27 июн 2025, 21:53
27 июн 2025, 21:53
e9c47fd
Код
Авторство
О чём код?
' 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. Imports Analyzer.Utilities.Extensions Imports Microsoft.CodeAnalysis.Diagnostics Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Namespace Microsoft.CodeAnalysis.VisualBasic.Analyzers <DiagnosticAnalyzer(LanguageNames.VisualBasic)> Public Class VisualBasicUpgradeMSBuildWorkspaceAnalyzer Inherits UpgradeMSBuildWorkspaceAnalyzer Protected Overrides Sub RegisterIdentifierAnalysis(context As CompilationStartAnalysisContext) context.RegisterSyntaxNodeAction(AddressOf AnalyzeIdentifier, SyntaxKind.IdentifierName) End Sub Private Sub AnalyzeIdentifier(context As SyntaxNodeAnalysisContext) Dim identifierName = TryCast(context.Node, IdentifierNameSyntax) If identifierName Is Nothing Then Return End If If Not CaseInsensitiveComparison.Equals(identifierName.Identifier.ToString(), MSBuildWorkspace) Then Return End If Dim symbolInfo = context.SemanticModel.GetSymbolInfo(identifierName, context.CancellationToken) If symbolInfo.Symbol Is Nothing Then context.ReportDiagnostic(identifierName.CreateDiagnostic(UpgradeMSBuildWorkspaceDiagnosticRule)) End If End Sub End Class End Namespace