private void AnalyzeForConfigureFalse(SyntaxNodeAnalysisContext context) { if (GeneratedCodeRecognition.IsFromGeneratedCode(context)) { return; } var node = (AwaitExpressionSyntax)context.Node; if (node.Expression != null) { var type = ModelExtensions.GetTypeInfo(context.SemanticModel, node.Expression).Type; if (type.ContainingNamespace.ToString() == "System.Threading.Tasks" && type.Name == "Task") { context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.UseConfigureAwait, node.GetLocation())); } } }
public RenameItemDialog(ISymbol symbol, RenameRefactoring rename) { this.Build(); string title; if (symbol is ITypeSymbol) { var t = (ITypeSymbol)symbol; if (t.TypeKind == TypeKind.TypeParameter) { title = GettextCatalog.GetString("Rename Type Parameter"); entry.Text = t.Name; } else { var typeDefinition = t; if (typeDefinition.ContainingType == null) { // not supported for inner types this.renameFileFlag.Visible = true; this.renameFileFlag.Active = t.Locations.First().SourceTree.FilePath.Contains(typeDefinition.Name); } else { this.renameFileFlag.Active = false; } if (typeDefinition.TypeKind == TypeKind.Interface) { title = GettextCatalog.GetString("Rename Interface"); } else if (typeDefinition.TypeKind == TypeKind.Delegate) { title = GettextCatalog.GetString("Rename Delegate"); } else if (typeDefinition.TypeKind == TypeKind.Enum) { title = GettextCatalog.GetString("Rename Enum"); } else if (typeDefinition.TypeKind == TypeKind.Struct) { title = GettextCatalog.GetString("Rename Struct"); } else { title = GettextCatalog.GetString("Rename Class"); } } // this.fileName = type.GetDefinition ().Region.FileName; } else if (symbol.Kind == SymbolKind.Field) { title = GettextCatalog.GetString("Rename Field"); } else if (symbol.Kind == SymbolKind.Property) { title = GettextCatalog.GetString("Rename Property"); } else if (symbol.Kind == SymbolKind.Event) { title = GettextCatalog.GetString("Rename Event"); } else if (symbol.Kind == SymbolKind.Method) { var m = (IMethodSymbol)symbol; if (m.MethodKind == MethodKind.Constructor || m.MethodKind == MethodKind.StaticConstructor || m.MethodKind == MethodKind.Destructor) { title = GettextCatalog.GetString("Rename Class"); } else { title = GettextCatalog.GetString("Rename Method"); includeOverloadsCheckbox.Visible = m.ContainingType.GetMembers(m.Name).Length > 1; } } else if (symbol.Kind == SymbolKind.Parameter) { title = GettextCatalog.GetString("Rename Parameter"); } else if (symbol.Kind == SymbolKind.Local) { title = GettextCatalog.GetString("Rename Variable"); } else if (symbol.Kind == SymbolKind.TypeParameter) { title = GettextCatalog.GetString("Rename Type Parameter"); } else if (symbol.Kind == SymbolKind.Namespace) { title = GettextCatalog.GetString("Rename Namespace"); } else if (symbol.Kind == SymbolKind.Label) { title = GettextCatalog.GetString("Rename Label"); } else { title = GettextCatalog.GetString("Rename Item"); } Init(title, symbol.Name, async prop => { return(await rename.PerformChangesAsync(symbol, prop)); }); renameFileFlag.Visible = false; foreach (var loc in symbol.Locations) { if (loc.IsInSource) { if (loc.SourceTree == null || !System.IO.File.Exists(loc.SourceTree.FilePath) || GeneratedCodeRecognition.IsFileNameForGeneratedCode(loc.SourceTree.FilePath)) { continue; } var oldName = System.IO.Path.GetFileNameWithoutExtension(loc.SourceTree.FilePath); if (RenameRefactoring.IsCompatibleForRenaming(oldName, symbol.Name)) { renameFileFlag.Visible = true; break; } } } }