internal Symbol(SymbolKind kind, string name, string documentation, Symbol parent) { Kind = kind; Name = name; Documentation = documentation; Parent = parent; }
/// <summary> /// Creates a new symbol information literal. /// /// @param name The name of the symbol. /// @param kind The kind of the symbol. /// @param range The range of the location of the symbol. /// @param uri The resource of the location of symbol, defaults to the current document. /// @param containerName The name of the symbol containg the symbol. /// </summary> public SymbolInformation(string name, SymbolKind kind, Range range, string uri, string containerName) { this.name = name; this.kind = kind; this.location = new Location(uri, range); this.containerName = containerName; }
public InlineCodeToken(TokenType type, string text = null, int index = -1, SymbolKind ownerType = default(SymbolKind), bool isExpandedParamArray = false) { Type = type; _text = text; _index = index; _ownerType = ownerType; _isExpandedParamArray = isExpandedParamArray; }
/// <summary> /// Constructor. /// </summary> /// <param name="symbol">ISymbol</param> /// <param name="dfgNode">DataFlowNode</param> internal SymbolDefinition(ISymbol symbol, DataFlowNode dfgNode) { this.DataFlowNode = dfgNode; this.Symbol = symbol; this.CandidateTypes = new HashSet<ITypeSymbol>(); this.Kind = symbol.Kind; this.Name = $"[{this.DataFlowNode.Id},{this.Kind}]::{this.Symbol.Name}"; }
public Symbol(string symType, string symName, SymbolKind symKind, string declaringClassName) { Type = symType; Name = symName; Kind = symKind; DeclaringClassName = declaringClassName; }
private string GetClass(SymbolKind kind) { if (kind == SymbolKind.TypeParameter) { return " t"; } return ""; }
public Declaration(Position position, string name, SymbolKind kind, AST.Type type) : base(position) { _name = name; _kind = kind; _type = type; _type.Parent = this; }
public SymbolMetadata( string id, string fullName, string[] filePathsOfDeclarations, SymbolKind symbolKind) { Id = id; FullName = fullName; DeclarationFilesPaths = filePathsOfDeclarations; SymbolKind = symbolKind; }
public static object GetErrorReportingName(SymbolKind kind) { switch (kind) { case SymbolKind.Namespace: return MessageID.IDS_SK_NAMESPACE.Localize(); default: // TODO: what is the right way to get these strings? return kind.ToString().ToLower(); } }
/// <summary> /// Creates a type parameter reference. /// For common type parameter references, this method may return a shared instance. /// </summary> public static TypeParameterReference Create(SymbolKind ownerType, int index) { if (index >= 0 && index < 8 && (ownerType == SymbolKind.TypeDefinition || ownerType == SymbolKind.Method)) { TypeParameterReference[] arr = (ownerType == SymbolKind.TypeDefinition) ? classTypeParameterReferences : methodTypeParameterReferences; TypeParameterReference result = LazyInit.VolatileRead(ref arr[index]); if (result == null) { result = LazyInit.GetOrSet(ref arr[index], new TypeParameterReference(ownerType, index)); } return result; } else { return new TypeParameterReference(ownerType, index); } }
public DefaultMemberReference(SymbolKind symbolKind, ITypeReference typeReference, string name, int typeParameterCount = 0, IList<ITypeReference> parameterTypes = null) { if (typeReference == null) throw new ArgumentNullException("typeReference"); if (name == null) throw new ArgumentNullException("name"); if (typeParameterCount != 0 && symbolKind != SymbolKind.Method) throw new ArgumentException("Type parameter count > 0 is only supported for methods."); this.symbolKind = symbolKind; this.typeReference = typeReference; this.name = name; this.typeParameterCount = typeParameterCount; this.parameterTypes = parameterTypes ?? EmptyList<ITypeReference>.Instance; }
internal InvocableSymbol(SymbolKind kind, string name, string documentation, Symbol parent, TypeSymbol returnType, Func<InvocableSymbol, IEnumerable<ParameterSymbol>> lazyParameters = null) : base(kind, name, documentation, parent) { if (returnType == null) throw new ArgumentNullException(nameof(returnType)); _parameters = new List<ParameterSymbol>(); if (lazyParameters != null) foreach (var parameter in lazyParameters(this)) AddParameter(parameter); ReturnType = returnType; }
private static IEnumerable<ValueTuple<ISymbol, int>> EnumerateSymbols( Compilation compilation, ISymbol containingSymbol, SymbolKind kind, string localName, CancellationToken cancellationToken) { int ordinal = 0; foreach (var declaringLocation in containingSymbol.DeclaringSyntaxReferences) { // This operation can potentially fail. If containingSymbol came from // a SpeculativeSemanticModel, containingSymbol.ContainingAssembly.Compilation // may not have been rebuilt to reflect the trees used by the // SpeculativeSemanticModel to produce containingSymbol. In that case, // asking the ContainingAssembly's complation for a SemanticModel based // on trees for containingSymbol with throw an ArgumentException. // Unfortunately, the best way to avoid this (currently) is to see if // we're asking for a model for a tree that's part of the compilation. // (There's no way to get back to a SemanticModel from a symbol). // TODO (rchande): It might be better to call compilation.GetSemanticModel // and catch the ArgumentException. The compilation internally has a // Dictionary<SyntaxTree, ...> that it uses to check if the SyntaxTree // is applicable wheras the public interface requires us to enumerate // the entire IEnumerable of trees in the Compilation. if (!compilation.SyntaxTrees.Contains(declaringLocation.SyntaxTree)) { continue; } var node = declaringLocation.GetSyntax(cancellationToken); if (node.Language == LanguageNames.VisualBasic) { node = node.Parent; } var semanticModel = compilation.GetSemanticModel(node.SyntaxTree); foreach (var token in node.DescendantNodes()) { var symbol = semanticModel.GetDeclaredSymbol(token, cancellationToken); if (symbol != null && symbol.Kind == kind && SymbolKey.Equals(compilation, symbol.Name, localName)) { yield return ValueTuple.Create(symbol, ordinal++); } } } }
public DefaultTypeParameter( ICompilation compilation, SymbolKind ownerType, int index, string name = null, VarianceModifier variance = VarianceModifier.Invariant, IList<IAttribute> attributes = null, DomRegion region = default(DomRegion), bool hasValueTypeConstraint = false, bool hasReferenceTypeConstraint = false, bool hasDefaultConstructorConstraint = false, IList<IType> constraints = null) : base(compilation, ownerType, index, name, variance, attributes, region) { this.hasValueTypeConstraint = hasValueTypeConstraint; this.hasReferenceTypeConstraint = hasReferenceTypeConstraint; this.hasDefaultConstructorConstraint = hasDefaultConstructorConstraint; this.constraints = constraints ?? EmptyList<IType>.Instance; }
static string GetMemberType(SymbolKind symbolKind) { switch (symbolKind) { case SymbolKind.Field: return GettextCatalog.GetString("field"); case SymbolKind.Method: return GettextCatalog.GetString("method"); case SymbolKind.Property: return GettextCatalog.GetString("property"); case SymbolKind.Event: return GettextCatalog.GetString("event"); } return GettextCatalog.GetString("member"); }
private string GetVimKind(SymbolKind entityType) { // v variable //f function or method //m member of a struct or class switch(entityType) { case(SymbolKind.Method): return "f"; case(SymbolKind.Field): return "v"; case(SymbolKind.Property): return "m"; } return " "; }
private bool AreEquivalentWorker(ISymbol x, ISymbol y, SymbolKind k, Dictionary<INamedTypeSymbol, INamedTypeSymbol> equivalentTypesWithDifferingAssemblies) { Contract.Requires(x.Kind == y.Kind && x.Kind == k); switch (k) { case SymbolKind.ArrayType: return ArrayTypesAreEquivalent((IArrayTypeSymbol)x, (IArrayTypeSymbol)y, equivalentTypesWithDifferingAssemblies); case SymbolKind.Assembly: return AssembliesAreEquivalent((IAssemblySymbol)x, (IAssemblySymbol)y); case SymbolKind.DynamicType: return DynamicTypesAreEquivalent((IDynamicTypeSymbol)x, (IDynamicTypeSymbol)y); case SymbolKind.Event: return EventsAreEquivalent((IEventSymbol)x, (IEventSymbol)y, equivalentTypesWithDifferingAssemblies); case SymbolKind.Field: return FieldsAreEquivalent((IFieldSymbol)x, (IFieldSymbol)y, equivalentTypesWithDifferingAssemblies); case SymbolKind.Label: return LabelsAreEquivalent((ILabelSymbol)x, (ILabelSymbol)y); case SymbolKind.Local: return LocalsAreEquivalent((ILocalSymbol)x, (ILocalSymbol)y); case SymbolKind.Method: return MethodsAreEquivalent((IMethodSymbol)x, (IMethodSymbol)y, equivalentTypesWithDifferingAssemblies); case SymbolKind.NetModule: return ModulesAreEquivalent((IModuleSymbol)x, (IModuleSymbol)y); case SymbolKind.NamedType: case SymbolKind.ErrorType: // ErrorType is handled in NamedTypesAreEquivalent return NamedTypesAreEquivalent((INamedTypeSymbol)x, (INamedTypeSymbol)y, equivalentTypesWithDifferingAssemblies); case SymbolKind.Namespace: return NamespacesAreEquivalent((INamespaceSymbol)x, (INamespaceSymbol)y, equivalentTypesWithDifferingAssemblies); case SymbolKind.Parameter: return ParametersAreEquivalent((IParameterSymbol)x, (IParameterSymbol)y, equivalentTypesWithDifferingAssemblies); case SymbolKind.PointerType: return PointerTypesAreEquivalent((IPointerTypeSymbol)x, (IPointerTypeSymbol)y, equivalentTypesWithDifferingAssemblies); case SymbolKind.Property: return PropertiesAreEquivalent((IPropertySymbol)x, (IPropertySymbol)y, equivalentTypesWithDifferingAssemblies); case SymbolKind.RangeVariable: return RangeVariablesAreEquivalent((IRangeVariableSymbol)x, (IRangeVariableSymbol)y); case SymbolKind.TypeParameter: return TypeParametersAreEquivalent((ITypeParameterSymbol)x, (ITypeParameterSymbol)y, equivalentTypesWithDifferingAssemblies); case SymbolKind.Preprocessing: return PreprocessingSymbolsAreEquivalent((IPreprocessingSymbol)x, (IPreprocessingSymbol)y); default: return false; } }
internal static uint SymbolKindToFieldKind(SymbolKind kind) { uint ret = 0; if (kind == SymbolKind.All) ret = (uint ) FIELD_KIND.FIELD_KIND_ALL; else{ if (0 != (kind & SymbolKind.Method)) ret |= (uint ) (FIELD_KIND.FIELD_SYM_MEMBER|FIELD_KIND.FIELD_TYPE_METHOD); if (0 != (kind & SymbolKind.Property)) ret |= (uint ) (FIELD_KIND.FIELD_SYM_MEMBER|FIELD_KIND.FIELD_TYPE_PROP); if (0 != (kind & SymbolKind.Field)) ret |= (uint ) (FIELD_KIND.FIELD_KIND_ALL & ~(FIELD_KIND.FIELD_TYPE_METHOD|FIELD_KIND.FIELD_TYPE_PROP)); if (0 != (kind & SymbolKind.This)) ret |= (uint ) FIELD_KIND.FIELD_SYM_THIS; if (0 != (kind & SymbolKind.Local)) ret |= (uint ) FIELD_KIND.FIELD_SYM_LOCAL; if (0 != (kind & SymbolKind.Parameter)) ret |= (uint ) FIELD_KIND.FIELD_SYM_PARAM; } return ret; }
static ITypeParameter GetTypeParameter(ref ITypeParameter[] typeParameters, SymbolKind symbolKind, int index) { ITypeParameter[] tps = typeParameters; while (index >= tps.Length) { // We don't have a normal type parameter for this index, so we need to extend our array. // Because the array can be used concurrently from multiple threads, we have to use // Interlocked.CompareExchange. ITypeParameter[] newTps = new ITypeParameter[index + 1]; tps.CopyTo(newTps, 0); for (int i = tps.Length; i < newTps.Length; i++) { newTps[i] = new DummyTypeParameter(symbolKind, i); } ITypeParameter[] oldTps = Interlocked.CompareExchange(ref typeParameters, newTps, tps); if (oldTps == tps) { // exchange successful tps = newTps; } else { // exchange not successful tps = oldTps; } } return tps[index]; }
public override void RegisterSymbolStartAction(Action <SymbolStartAnalysisContext> action, SymbolKind symbolKind) { }
private IEnumerable <DocumentSymbol> CreateSymbolsOfEntryDocument(ILocalizableSymbol symbol, Boogie.IToken token, SymbolKind kind) { var children = symbol.Children.SelectMany(Visit); if (!IsPartOfEntryDocument(token)) { return(children); } var documentSymbol = new DocumentSymbol { Name = symbol.Name, Kind = kind, Detail = symbol.GetDetailText(_cancellationToken), Children = children.ToArray() }; if (_symbolTable.TryGetLocationOf(symbol, out var location)) { documentSymbol = documentSymbol with { Range = location.Declaration, SelectionRange = location.Name }; } return(new[] { documentSymbol }); } }
public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) { SyntaxNode root = await context.GetSyntaxRootAsync().ConfigureAwait(false); if (!TryFindToken(root, context.Span.Start, out SyntaxToken token)) { return; } SyntaxKind kind = token.Kind(); foreach (Diagnostic diagnostic in context.Diagnostics) { switch (diagnostic.Id) { case CompilerDiagnosticIdentifiers.OperatorCannotBeAppliedToOperand: { if (kind == SyntaxKind.QuestionToken && token.Parent is ConditionalAccessExpressionSyntax conditionalAccess) { SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false); ITypeSymbol typeSymbol = semanticModel.GetTypeSymbol(conditionalAccess.Expression, context.CancellationToken); if (typeSymbol?.IsErrorType() == false && !typeSymbol.IsNullableType()) { if (typeSymbol.IsValueType) { if (Settings.IsEnabled(diagnostic.Id, CodeFixIdentifiers.RemoveConditionalAccess)) { CodeAction codeAction = CodeAction.Create( "Remove '?' operator", cancellationToken => { var textChange = new TextChange(token.Span, ""); return(context.Document.WithTextChangeAsync(textChange, cancellationToken)); }, GetEquivalenceKey(diagnostic)); context.RegisterCodeFix(codeAction, diagnostic); } } else if (typeSymbol.IsReferenceType) { if (Settings.IsEnabled(diagnostic.Id, CodeFixIdentifiers.AddArgumentList) && conditionalAccess.WhenNotNull is MemberBindingExpressionSyntax memberBindingExpression) { ConditionalAccessExpressionSyntax newNode = conditionalAccess.WithWhenNotNull( InvocationExpression( memberBindingExpression.WithoutTrailingTrivia(), ArgumentList().WithTrailingTrivia(memberBindingExpression.GetTrailingTrivia()))); CodeAction codeAction = CodeAction.Create( "Add argument list", cancellationToken => context.Document.ReplaceNodeAsync(conditionalAccess, newNode, cancellationToken), GetEquivalenceKey(diagnostic)); context.RegisterCodeFix(codeAction, diagnostic); } } } } break; } case CompilerDiagnosticIdentifiers.PartialModifierCanOnlyAppearImmediatelyBeforeClassStructInterfaceOrVoid: { if (!Settings.IsEnabled(diagnostic.Id, CodeFixIdentifiers.OrderModifiers)) { break; } ModifiersCodeFixRegistrator.MoveModifier(context, diagnostic, token.Parent, token); break; } case CompilerDiagnosticIdentifiers.ValueCannotBeUsedAsDefaultParameter: { if (!(token.Parent is ParameterSyntax parameter)) { break; } ExpressionSyntax value = parameter.Default?.Value; if (value == null) { break; } if (value.IsKind(SyntaxKind.NullLiteralExpression)) { if (Settings.IsEnabled(diagnostic.Id, CodeFixIdentifiers.ReplaceNullLiteralExpressionWithDefaultValue)) { SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false); CodeFixRegistrator.ReplaceNullWithDefaultValue(context, diagnostic, value, semanticModel); } } else if (!value.IsKind(SyntaxKind.DefaultExpression, SyntaxKind.DefaultLiteralExpression)) { if (Settings.IsEnabled(diagnostic.Id, CodeFixIdentifiers.ChangeParameterType)) { SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false); ITypeSymbol typeSymbol = semanticModel.GetTypeSymbol(value, context.CancellationToken); if (!typeSymbol.IsKind(SymbolKind.ErrorType)) { CodeFixRegistrator.ChangeType(context, diagnostic, parameter.Type, typeSymbol, semanticModel); } } } break; } case CompilerDiagnosticIdentifiers.ObjectOfTypeConvertibleToTypeIsRequired: { if (!Settings.IsEnabled(diagnostic.Id, CodeFixIdentifiers.ReturnDefaultValue)) { break; } if (token.Kind() != SyntaxKind.ReturnKeyword) { break; } if (!token.IsParentKind(SyntaxKind.ReturnStatement)) { break; } SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false); ISymbol symbol = semanticModel.GetEnclosingSymbol(token.SpanStart, context.CancellationToken); if (symbol == null) { break; } SymbolKind symbolKind = symbol.Kind; ITypeSymbol typeSymbol = null; if (symbolKind == SymbolKind.Method) { var methodSymbol = (IMethodSymbol)symbol; typeSymbol = methodSymbol.ReturnType; if (methodSymbol.IsAsync && (typeSymbol is INamedTypeSymbol namedTypeSymbol)) { ImmutableArray <ITypeSymbol> typeArguments = namedTypeSymbol.TypeArguments; if (typeArguments.Any()) { typeSymbol = typeArguments[0]; } } } else if (symbolKind == SymbolKind.Property) { typeSymbol = ((IPropertySymbol)symbol).Type; } else { Debug.Fail(symbolKind.ToString()); } if (typeSymbol == null) { break; } if (typeSymbol.Kind == SymbolKind.ErrorType) { break; } if (!typeSymbol.SupportsExplicitDeclaration()) { break; } var returnStatement = (ReturnStatementSyntax)token.Parent; CodeAction codeAction = CodeAction.Create( "Return default value", cancellationToken => { ExpressionSyntax expression = typeSymbol.GetDefaultValueSyntax(context.Document.GetDefaultSyntaxOptions()); if (expression.IsKind(SyntaxKind.DefaultExpression) && context.Document.SupportsLanguageFeature(CSharpLanguageFeature.DefaultLiteral)) { expression = CSharpFactory.DefaultLiteralExpression().WithTriviaFrom(expression); } ReturnStatementSyntax newNode = returnStatement.WithExpression(expression); return(context.Document.ReplaceNodeAsync(returnStatement, newNode, cancellationToken)); }, GetEquivalenceKey(diagnostic)); context.RegisterCodeFix(codeAction, diagnostic); break; } case CompilerDiagnosticIdentifiers.TypeExpected: { if (!Settings.IsEnabled(diagnostic.Id, CodeFixIdentifiers.AddMissingType)) { break; } if (token.Kind() != SyntaxKind.CloseParenToken) { break; } if (!(token.Parent is DefaultExpressionSyntax defaultExpression)) { break; } if (!(defaultExpression.Type is IdentifierNameSyntax identifierName)) { break; } if (!identifierName.IsMissing) { break; } SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false); TypeInfo typeInfo = semanticModel.GetTypeInfo(defaultExpression, context.CancellationToken); ITypeSymbol convertedType = typeInfo.ConvertedType; if (convertedType?.SupportsExplicitDeclaration() != true) { break; } CodeAction codeAction = CodeAction.Create( $"Add type '{SymbolDisplay.ToMinimalDisplayString(convertedType, semanticModel, defaultExpression.SpanStart, SymbolDisplayFormats.Default)}'", cancellationToken => { TypeSyntax newNode = convertedType.ToMinimalTypeSyntax(semanticModel, defaultExpression.SpanStart); newNode = newNode .WithTriviaFrom(identifierName) .WithFormatterAnnotation(); return(context.Document.ReplaceNodeAsync(identifierName, newNode, cancellationToken)); }, GetEquivalenceKey(diagnostic)); context.RegisterCodeFix(codeAction, diagnostic); break; } case CompilerDiagnosticIdentifiers.SemicolonAfterMethodOrAccessorBlockIsNotValid: { if (!Settings.IsEnabled(diagnostic.Id, CodeFixIdentifiers.RemoveSemicolon)) { break; } if (token.Kind() != SyntaxKind.SemicolonToken) { break; } switch (token.Parent) { case MethodDeclarationSyntax methodDeclaration: { BlockSyntax body = methodDeclaration.Body; if (body == null) { break; } CodeAction codeAction = CodeAction.Create( "Remove semicolon", cancellationToken => { SyntaxTriviaList trivia = body .GetTrailingTrivia() .EmptyIfWhitespace() .AddRange(token.LeadingTrivia.EmptyIfWhitespace()) .AddRange(token.TrailingTrivia); MethodDeclarationSyntax newNode = methodDeclaration .WithBody(body.WithTrailingTrivia(trivia)) .WithSemicolonToken(default(SyntaxToken)); return(context.Document.ReplaceNodeAsync(methodDeclaration, newNode, cancellationToken)); }, GetEquivalenceKey(diagnostic)); context.RegisterCodeFix(codeAction, diagnostic); break; } case PropertyDeclarationSyntax propertyDeclaration: { AccessorListSyntax accessorList = propertyDeclaration.AccessorList; if (accessorList == null) { break; } CodeAction codeAction = CodeAction.Create( "Remove semicolon", cancellationToken => { SyntaxTriviaList trivia = accessorList .GetTrailingTrivia() .EmptyIfWhitespace() .AddRange(token.LeadingTrivia.EmptyIfWhitespace()) .AddRange(token.TrailingTrivia); PropertyDeclarationSyntax newNode = propertyDeclaration .WithAccessorList(accessorList.WithTrailingTrivia(trivia)) .WithSemicolonToken(default(SyntaxToken)); return(context.Document.ReplaceNodeAsync(propertyDeclaration, newNode, cancellationToken)); }, GetEquivalenceKey(diagnostic)); context.RegisterCodeFix(codeAction, diagnostic); break; } case AccessorDeclarationSyntax accessorDeclaration: { BlockSyntax body = accessorDeclaration.Body; if (body == null) { break; } CodeAction codeAction = CodeAction.Create( "Remove semicolon", cancellationToken => { SyntaxTriviaList trivia = body .GetTrailingTrivia() .EmptyIfWhitespace() .AddRange(token.LeadingTrivia.EmptyIfWhitespace()) .AddRange(token.TrailingTrivia); AccessorDeclarationSyntax newNode = accessorDeclaration .WithBody(body.WithTrailingTrivia(trivia)) .WithSemicolonToken(default(SyntaxToken)); return(context.Document.ReplaceNodeAsync(accessorDeclaration, newNode, cancellationToken)); }, GetEquivalenceKey(diagnostic)); context.RegisterCodeFix(codeAction, diagnostic); break; } } break; } case CompilerDiagnosticIdentifiers.CannotConvertType: { if (!Settings.IsEnabled(diagnostic.Id, CodeFixIdentifiers.ChangeForEachType)) { break; } if (token.Kind() != SyntaxKind.ForEachKeyword) { break; } if (!(token.Parent is ForEachStatementSyntax forEachStatement)) { break; } SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false); ForEachStatementInfo info = semanticModel.GetForEachStatementInfo(forEachStatement); ITypeSymbol typeSymbol = info.ElementType; if (typeSymbol.SupportsExplicitDeclaration()) { CodeFixRegistrator.ChangeType(context, diagnostic, forEachStatement.Type, typeSymbol, semanticModel, CodeFixIdentifiers.ChangeForEachType); } CodeFixRegistrator.ChangeTypeToVar(context, diagnostic, forEachStatement.Type, CodeFixIdentifiers.ChangeTypeToVar); break; } case CompilerDiagnosticIdentifiers.OptionalParametersMustAppearAfterAllRequiredParameters: { if (!Settings.IsEnabled(diagnostic.Id, CodeFixIdentifiers.AddDefaultValueToParameter)) { break; } if (!(token.Parent is BaseParameterListSyntax parameterList)) { break; } SeparatedSyntaxList <ParameterSyntax> parameters = parameterList.Parameters; ParameterSyntax parameter = null; for (int i = 0; i < parameters.Count; i++) { ParameterSyntax p = parameters[i]; if (p.FullSpan.End <= token.SpanStart) { parameter = p; } else { break; } } SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false); IParameterSymbol parameterSymbol = semanticModel.GetDeclaredSymbol(parameter, context.CancellationToken); ITypeSymbol typeSymbol = parameterSymbol.Type; if (typeSymbol.Kind == SymbolKind.ErrorType) { break; } CodeAction codeAction = CodeAction.Create( "Add default value", cancellationToken => { ExpressionSyntax defaultValue = typeSymbol.GetDefaultValueSyntax(context.Document.GetDefaultSyntaxOptions()); ParameterSyntax newParameter = parameter .WithDefault(EqualsValueClause(defaultValue).WithTrailingTrivia(parameter.GetTrailingTrivia())) .WithoutTrailingTrivia() .WithFormatterAnnotation(); return(context.Document.ReplaceNodeAsync(parameter, newParameter, cancellationToken)); }, GetEquivalenceKey(diagnostic)); context.RegisterCodeFix(codeAction, diagnostic); break; } } } }
public SymbolKindOrTypeKind(SymbolKind symbolKind) : this() { SymbolKind = symbolKind; TypeKind = null; }
public static bool MatchesKind(this ISymbol symbol, SymbolKind kind) { return(symbol?.Kind == kind); }
internal IntrinsicTypeSymbol(SymbolKind kind, string name, string documentation) : base(kind, name, documentation, null) { }
public static bool IsKind(this ISymbol symbol, SymbolKind kind1, SymbolKind kind2, SymbolKind kind3) { if (symbol == null) { return(false); } SymbolKind kind = symbol.Kind; return(kind == kind1 || kind == kind2 || kind == kind3); }
public static IMember Resolve(ITypeResolveContext context, SymbolKind symbolKind, string name, ITypeReference explicitInterfaceTypeReference = null, IList <string> typeParameterNames = null, IList <ITypeReference> parameterTypeReferences = null) { if (context.CurrentTypeDefinition == null) { return(null); } if (parameterTypeReferences == null) { parameterTypeReferences = EmptyList <ITypeReference> .Instance; } if (typeParameterNames == null || typeParameterNames.Count == 0) { // non-generic member // In this case, we can simply resolve the parameter types in the given context var parameterTypes = parameterTypeReferences.Resolve(context); if (explicitInterfaceTypeReference == null) { foreach (IMember member in context.CurrentTypeDefinition.Members) { if (member.IsExplicitInterfaceImplementation) { continue; } if (IsNonGenericMatch(member, symbolKind, name, parameterTypes)) { return(member); } } } else { IType explicitInterfaceType = explicitInterfaceTypeReference.Resolve(context); foreach (IMember member in context.CurrentTypeDefinition.Members) { if (!member.IsExplicitInterfaceImplementation) { continue; } if (member.ImplementedInterfaceMembers.Count != 1) { continue; } if (IsNonGenericMatch(member, symbolKind, name, parameterTypes)) { if (explicitInterfaceType.Equals(member.ImplementedInterfaceMembers[0].DeclaringType)) { return(member); } } } } } else { // generic member // In this case, we must specify the correct context for resolving the parameter types foreach (IMethod method in context.CurrentTypeDefinition.Methods) { if (method.SymbolKind != symbolKind) { continue; } if (method.Name != name) { continue; } if (method.Parameters.Count != parameterTypeReferences.Count) { continue; } // Compare type parameter count and names: if (!typeParameterNames.SequenceEqual(method.TypeParameters.Select(tp => tp.Name))) { continue; } // Once we know the type parameter names are fitting, we can resolve the // type references in the context of the method: var contextForMethod = context.WithCurrentMember(method); var parameterTypes = parameterTypeReferences.Resolve(contextForMethod); if (!IsParameterTypeMatch(method, parameterTypes)) { continue; } if (explicitInterfaceTypeReference == null) { if (!method.IsExplicitInterfaceImplementation) { return(method); } } else if (method.IsExplicitInterfaceImplementation && method.ImplementedInterfaceMembers.Count == 1) { IType explicitInterfaceType = explicitInterfaceTypeReference.Resolve(contextForMethod); if (explicitInterfaceType.Equals(method.ImplementedInterfaceMembers[0].DeclaringType)) { return(method); } } } } return(null); }
internal ContainerSymbol(SymbolKind kind, string name, string documentation, Symbol parent) : base(kind, name, documentation, parent) { _members = new List <Symbol>(); }
private void IndexedPropertiesBindingChecks(string source, MetadataReference reference, SymbolKind symbolKind, string name) { var tree = Parse(source); var comp = CreateCompilation(tree, new[] { reference }); var model = comp.GetSemanticModel(tree); var expr = GetExprSyntaxForBinding(GetExprSyntaxList(tree)); var sym = model.GetSymbolInfo(expr); Assert.Equal(symbolKind, sym.Symbol.Kind); Assert.Equal(name, sym.Symbol.Name); var typeInfo = model.GetTypeInfo(expr); // https://github.com/dotnet/roslyn/issues/38509 // Assert.NotEqual(default, typeInfo); var methodGroup = model.GetMemberGroup(expr); Assert.NotEqual(default, methodGroup);
private string LowerCaseKind(SymbolKind kind) { return(kind.ToString().ToLowerInvariant()); }
private static DiagnosticResult GetExpectedDiagnostic(DiagnosticDescriptor rule, int line, int column, SymbolKind unsupportedSymbolKind) { return(new DiagnosticResult(rule) .WithLocation(line, column) .WithArguments(unsupportedSymbolKind)); }
private static DiagnosticResult GetBasicExpectedDiagnostic(int line, int column, SymbolKind unsupportedSymbolKind) { return(GetExpectedDiagnostic(VisualBasic.Analyzers.MetaAnalyzers.BasicRegisterActionAnalyzer.UnsupportedSymbolKindArgumentRule, line, column, unsupportedSymbolKind)); }
private static DiagnosticResult GetExpectedDiagnostic(string language, int line, int column, SymbolKind unsupportedSymbolKind) { string fileName = language == LanguageNames.CSharp ? "Test0.cs" : "Test0.vb"; return(new DiagnosticResult { Id = DiagnosticIds.UnsupportedSymbolKindArgumentRuleId, Message = string.Format(CodeAnalysisDiagnosticsResources.UnsupportedSymbolKindArgumentToRegisterActionMessage, unsupportedSymbolKind.ToString()), Severity = DiagnosticSeverity.Warning, Locations = new[] { new DiagnosticResultLocation(fileName, line, column) } }); }
public static IMember Resolve(ITypeResolveContext context, SymbolKind symbolKind, string name, ITypeReference explicitInterfaceTypeReference = null, IList<string> typeParameterNames = null, IList<ITypeReference> parameterTypeReferences = null) { if (context.CurrentTypeDefinition == null) return null; if (parameterTypeReferences == null) parameterTypeReferences = EmptyList<ITypeReference>.Instance; if (typeParameterNames == null || typeParameterNames.Count == 0) { // non-generic member // In this case, we can simply resolve the parameter types in the given context var parameterTypes = parameterTypeReferences.Resolve(context); if (explicitInterfaceTypeReference == null) { foreach (IMember member in context.CurrentTypeDefinition.Members) { if (member.IsExplicitInterfaceImplementation) continue; if (IsNonGenericMatch(member, symbolKind, name, parameterTypes)) return member; } } else { IType explicitInterfaceType = explicitInterfaceTypeReference.Resolve(context); foreach (IMember member in context.CurrentTypeDefinition.Members) { if (!member.IsExplicitInterfaceImplementation) continue; if (member.ImplementedInterfaceMembers.Count != 1) continue; if (IsNonGenericMatch(member, symbolKind, name, parameterTypes)) { if (explicitInterfaceType.Equals(member.ImplementedInterfaceMembers[0].DeclaringType)) return member; } } } } else { // generic member // In this case, we must specify the correct context for resolving the parameter types foreach (IMethod method in context.CurrentTypeDefinition.Methods) { if (method.SymbolKind != symbolKind) continue; if (method.Name != name) continue; if (method.Parameters.Count != parameterTypeReferences.Count) continue; // Compare type parameter count and names: if (!typeParameterNames.SequenceEqual(method.TypeParameters.Select(tp => tp.Name))) continue; // Once we know the type parameter names are fitting, we can resolve the // type references in the context of the method: var contextForMethod = context.WithCurrentMember(method); var parameterTypes = parameterTypeReferences.Resolve(contextForMethod); if (!IsParameterTypeMatch(method, parameterTypes)) continue; if (explicitInterfaceTypeReference == null) { if (!method.IsExplicitInterfaceImplementation) return method; } else if (method.IsExplicitInterfaceImplementation && method.ImplementedInterfaceMembers.Count == 1) { IType explicitInterfaceType = explicitInterfaceTypeReference.Resolve(contextForMethod); if (explicitInterfaceType.Equals(method.ImplementedInterfaceMembers[0].DeclaringType)) return method; } } } return null; }
private static bool MemberNameExistsInHierarchy(string memberName, INamedTypeSymbol containingType, SymbolKind kind) { for (INamedTypeSymbol baseType = containingType; baseType != null; baseType = baseType.BaseType) { if (baseType.GetMembers(memberName).Any(member => member.Kind == kind)) { return(true); } } return(false); }
public SymbolKindViewModel(SymbolKind symbolKind, string name, SymbolSpecification specification) { this._symbolKind = symbolKind; Name = name; IsChecked = specification.ApplicableSymbolKindList.Any(k => k.SymbolKind == symbolKind); }
public SymInfo(string name, SymbolKind kind, string description) { this.name = name; this.kind = kind; this.description = description; }
protected override Accessibility GetDefaultAccessibility(SymbolKind targetSymbolKind, CodeGenerationDestination destination) { switch (targetSymbolKind) { case SymbolKind.Field: case SymbolKind.Method: case SymbolKind.Property: case SymbolKind.Event: return Accessibility.Private; case SymbolKind.NamedType: switch (destination) { case CodeGenerationDestination.ClassType: case CodeGenerationDestination.EnumType: case CodeGenerationDestination.InterfaceType: case CodeGenerationDestination.StructType: return Accessibility.Private; default: return Accessibility.Internal; } default: Debug.Fail("Invalid symbol kind: " + targetSymbolKind); throw Exceptions.ThrowEFail(); } }
public static bool IsKind(this ISymbol symbol, SymbolKind kind) { return(symbol.MatchesKind(kind)); }
private static DiagnosticResult GetCSharpExpectedDiagnostic(int line, int column, SymbolKind unsupportedSymbolKind) { return(GetExpectedDiagnostic(LanguageNames.CSharp, line, column, unsupportedSymbolKind)); }
public static bool MatchesKind(this ISymbol symbol, SymbolKind kind1, SymbolKind kind2, SymbolKind kind3) { return(symbol != null && (symbol.Kind == kind1 || symbol.Kind == kind2 || symbol.Kind == kind3)); }
/// <summary> /// Some kinds of methods are not considered to be hideable by certain kinds of members. /// Specifically, methods, properties, and types cannot hide constructors, destructors, /// operators, conversions, or accessors. /// </summary> public static bool CanBeHiddenByMemberKind(this MethodSymbol hiddenMethod, SymbolKind hidingMemberKind) { Debug.Assert((object)hiddenMethod != null); // Nothing can hide a destructor (see SymbolPreparer::ReportHiding) if (hiddenMethod.MethodKind == MethodKind.Destructor) { return false; } switch (hidingMemberKind) { case SymbolKind.ErrorType: case SymbolKind.NamedType: case SymbolKind.Method: case SymbolKind.Property: return CanBeHiddenByMethodPropertyOrType(hiddenMethod); case SymbolKind.Field: case SymbolKind.Event: // Events are not covered by CSemanticChecker::FindSymHiddenByMethPropAgg. return true; default: throw ExceptionUtilities.UnexpectedValue(hidingMemberKind); } }
private static ISymbol CreateSymbolMock( SymbolKind kind, Accessibility declaredAccessibility = Accessibility.NotApplicable, bool isExtensionMethod = false, MethodKind methodKind = MethodKind.Ordinary, INamedTypeSymbol containingType = null, bool isConst = false, ITypeSymbol elementType = null, INamespaceOrTypeSymbol target = null, ITypeSymbol pointedAtType = null, bool isWithEvents = false, TypeKind typeKind = TypeKind.Unknown) { var symbolMock = new Mock <ISymbol>(); symbolMock.SetupGet(s => s.Kind).Returns(kind); symbolMock.SetupGet(s => s.DeclaredAccessibility).Returns(declaredAccessibility); symbolMock.SetupGet(s => s.ContainingType).Returns(containingType); if (kind == SymbolKind.ArrayType) { var arrayTypeMock = symbolMock.As <IArrayTypeSymbol>(); arrayTypeMock.SetupGet(s => s.ElementType).Returns(elementType); } if (kind == SymbolKind.Alias) { var aliasMock = symbolMock.As <IAliasSymbol>(); aliasMock.SetupGet(s => s.Target).Returns(target); } if (kind == SymbolKind.Method) { var methodTypeMock = symbolMock.As <IMethodSymbol>(); methodTypeMock.SetupGet(s => s.MethodKind).Returns(methodKind); methodTypeMock.SetupGet(s => s.IsExtensionMethod).Returns(isExtensionMethod); } if (kind == SymbolKind.NamedType) { var namedTypeMock = symbolMock.As <INamedTypeSymbol>(); namedTypeMock.SetupGet(s => s.TypeKind).Returns(typeKind); } if (kind == SymbolKind.Field) { var fieldMock = symbolMock.As <IFieldSymbol>(); fieldMock.SetupGet(s => s.IsConst).Returns(isConst); } if (kind == SymbolKind.PointerType) { var pointerTypeMock = symbolMock.As <IPointerTypeSymbol>(); pointerTypeMock.SetupGet(s => s.PointedAtType).Returns(pointedAtType); } if (kind == SymbolKind.Property) { var propertyMock = symbolMock.As <IPropertySymbol>(); propertyMock.SetupGet(s => s.IsWithEvents).Returns(isWithEvents); } return(symbolMock.Object); }
private void TestGlyph( StandardGlyphGroup expectedGlyphGroup, SymbolKind kind = SymbolKind.Method, Accessibility declaredAccessibility = Accessibility.NotApplicable, bool isExtensionMethod = true, MethodKind methodKind = MethodKind.Ordinary, INamedTypeSymbol containingType = null, bool isConst = false, ITypeSymbol elementType = null, INamespaceOrTypeSymbol target = null, ITypeSymbol pointedAtType = null, bool isWithEvents = false, TypeKind typeKind = TypeKind.Unknown) { var symbol = CreateSymbolMock(kind, declaredAccessibility, isExtensionMethod, methodKind, containingType, isConst, elementType, target, pointedAtType, isWithEvents, typeKind); Assert.Equal(expectedGlyphGroup, symbol.GetGlyph().GetStandardGlyphGroup()); }
static string GetSymbolTypeName(SymbolKind kind, string name) { var ns = GetSymbolNamespace(kind); return(typeof(SymbolProvider).GetAssembly().GetName().Name + "." + ns + "." + kind + name); }
private static void TestGetSpeculativeSemanticModelForTypeSyntax_Common( SemanticModel model, int position, TypeSyntax speculatedTypeSyntax, SpeculativeBindingOption bindingOption, SymbolKind expectedSymbolKind, string expectedTypeDislayString) { Assert.False(model.IsSpeculativeSemanticModel); Assert.Null(model.ParentModel); Assert.Equal(0, model.OriginalPositionForSpeculation); SemanticModel speculativeModel; var success = model.TryGetSpeculativeSemanticModel(position, speculatedTypeSyntax, out speculativeModel, bindingOption); Assert.True(success); Assert.NotNull(speculativeModel); Assert.True(speculativeModel.IsSpeculativeSemanticModel); Assert.Equal(model, speculativeModel.ParentModel); Assert.NotNull(speculativeModel); Assert.Equal(position, speculativeModel.OriginalPositionForSpeculation); var symbol = speculativeModel.GetSymbolInfo(speculatedTypeSyntax).Symbol; Assert.NotNull(symbol); Assert.Equal(expectedSymbolKind, symbol.Kind); Assert.Equal(expectedTypeDislayString, symbol.ToDisplayString()); var typeSymbol = speculativeModel.GetTypeInfo(speculatedTypeSyntax).Type; Assert.NotNull(symbol); Assert.Equal(expectedSymbolKind, symbol.Kind); Assert.Equal(expectedTypeDislayString, symbol.ToDisplayString()); if (speculatedTypeSyntax.Kind == SyntaxKind.QualifiedName) { var right = ((QualifiedNameSyntax)speculatedTypeSyntax).Right; symbol = speculativeModel.GetSymbolInfo(right).Symbol; Assert.NotNull(symbol); Assert.Equal(expectedSymbolKind, symbol.Kind); Assert.Equal(expectedTypeDislayString, symbol.ToDisplayString()); typeSymbol = speculativeModel.GetTypeInfo(right).Type; Assert.NotNull(symbol); Assert.Equal(expectedSymbolKind, symbol.Kind); Assert.Equal(expectedTypeDislayString, symbol.ToDisplayString()); } }
public static bool recordSymbolKind(int symbolId, SymbolKind symbolKind) { bool ret = sourcetraildbPINVOKE.recordSymbolKind(symbolId, (int)symbolKind); return(ret); }
/// <summary> /// Constructor /// </summary> /// <param name="kind">Symbol kind</param> /// <param name="symbol">Symbol name</param> /// <param name="address">Address of symbol, usually the same as the address passed to <see cref="ISymbolResolver.Resolve(ulong[], SymbolResolverResult[])"/></param> public SymbolResolverResult(SymbolKind kind, string symbol, ulong address) { Kind = kind; Symbol = symbol ?? throw new ArgumentNullException(nameof(symbol)); Address = address; }
private void CheckExpressionAndParent( string text, SymbolKind exprSymbolKind, string exprDisplayString, SymbolKind parentSymbolKind, string parentDisplayString, params DiagnosticDescription[] expectedDiagnostics) { var tree = Parse(text); var comp = CreateCompilationWithMscorlib(tree, new[] { TestReferences.NetFx.v4_0_30319.System_Core }); comp.VerifyDiagnostics(expectedDiagnostics); var model = comp.GetSemanticModel(tree); var expr = GetExprSyntaxForBinding(GetExprSyntaxList(tree)); Assert.Equal(SyntaxKind.IdentifierName, expr.Kind()); var info = model.GetSymbolInfo(expr); Assert.NotNull(info); Assert.Equal(exprSymbolKind, info.Symbol.Kind); Assert.Equal(exprDisplayString, info.Symbol.ToTestDisplayString()); var parentExpr = (ExpressionSyntax)expr.Parent; Assert.Equal(SyntaxKind.SimpleMemberAccessExpression, parentExpr.Kind()); var parentInfo = model.GetSymbolInfo(parentExpr); Assert.NotNull(parentInfo); Assert.Equal(parentSymbolKind, parentInfo.Symbol.Kind); Assert.Equal(parentDisplayString, parentInfo.Symbol.ToTestDisplayString()); }
public MyCompletionsCategory(SymbolKind entityType) { DisplayText = GetVimKind(entityType); }
private static ISymbol CreateSymbolMock( SymbolKind kind, Accessibility declaredAccessibility = Accessibility.NotApplicable, bool isExtensionMethod = false, MethodKind methodKind = MethodKind.Ordinary, INamedTypeSymbol containingType = null, bool isConst = false, ITypeSymbol elementType = null, INamespaceOrTypeSymbol target = null, ITypeSymbol pointedAtType = null, bool isWithEvents = false, TypeKind typeKind = TypeKind.Unknown) { var symbolMock = new Mock<ISymbol>(); symbolMock.SetupGet(s => s.Kind).Returns(kind); symbolMock.SetupGet(s => s.DeclaredAccessibility).Returns(declaredAccessibility); symbolMock.SetupGet(s => s.ContainingType).Returns(containingType); if (kind == SymbolKind.ArrayType) { var arrayTypeMock = symbolMock.As<IArrayTypeSymbol>(); arrayTypeMock.SetupGet(s => s.ElementType).Returns(elementType); } if (kind == SymbolKind.Alias) { var aliasMock = symbolMock.As<IAliasSymbol>(); aliasMock.SetupGet(s => s.Target).Returns(target); } if (kind == SymbolKind.Method) { var methodTypeMock = symbolMock.As<IMethodSymbol>(); methodTypeMock.SetupGet(s => s.MethodKind).Returns(methodKind); methodTypeMock.SetupGet(s => s.IsExtensionMethod).Returns(isExtensionMethod); } if (kind == SymbolKind.NamedType) { var namedTypeMock = symbolMock.As<INamedTypeSymbol>(); namedTypeMock.SetupGet(s => s.TypeKind).Returns(typeKind); } if (kind == SymbolKind.Field) { var fieldMock = symbolMock.As<IFieldSymbol>(); fieldMock.SetupGet(s => s.IsConst).Returns(isConst); } if (kind == SymbolKind.PointerType) { var pointerTypeMock = symbolMock.As<IPointerTypeSymbol>(); pointerTypeMock.SetupGet(s => s.PointedAtType).Returns(pointedAtType); } if (kind == SymbolKind.Property) { var propertyMock = symbolMock.As<IPropertySymbol>(); propertyMock.SetupGet(s => s.IsWithEvents).Returns(isWithEvents); } return symbolMock.Object; }
public SymbolStartAnalyzerAction(Action <SymbolStartAnalysisContext> action, SymbolKind kind, DiagnosticAnalyzer analyzer) : base(analyzer) { Action = action; Kind = kind; }
protected MemberContainer(TypeContainer parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, Modifiers def_mod, MemberName name, VSharpAttributes attrs, SymbolKind sym) { caching_flags = Flags.Obsolete_Undetected; this.SymbolKind = sym; this.Parent = parent; this.declaringTypeDefinition = parent; this.name = name.Name; if (parent != null) { this.UnresolvedFile = parent.UnresolvedFile; } this.type_expr = type; this.attribs = attrs; member_name = name; mod_flags = mod; mod_flags = ModifiersExtensions.Check(allowed_mod, mod, def_mod, name.Location, Report); if (DeclaringTypeDefinition.Kind == TypeKind.Interface) { mod_flags |= Modifiers.PUBLIC | Modifiers.ABSTRACT; } if (attrs != null) { foreach (var a in attrs.Attrs) { this.attributes.Add(a); } } this.returnType = type as ITypeReference; if (member_name.ExplicitInterface != null) { ApplyExplicit(null); } }
private static DiagnosticResult GetBasicExpectedDiagnostic(int line, int column, SymbolKind unsupportedSymbolKind) { return(GetExpectedDiagnostic(LanguageNames.VisualBasic, line, column, unsupportedSymbolKind)); }
static bool IsNonGenericMatch(IMember member, SymbolKind symbolKind, string name, IList<IType> parameterTypes) { if (member.SymbolKind != symbolKind) return false; if (member.Name != name) return false; IMethod method = member as IMethod; if (method != null && method.TypeParameters.Count > 0) return false; return IsParameterTypeMatch(member, parameterTypes); }
public static int ToSortOrder(this SymbolKind kind) { switch (kind) { case SymbolKind.Field: return(0); case SymbolKind.Method: return(1); case SymbolKind.Property: return(2); case SymbolKind.Event: return(3); case SymbolKind.NamedType: return(4); case SymbolKind.Namespace: return(5); case SymbolKind.Alias: return(6); case SymbolKind.ArrayType: return(7); case SymbolKind.Assembly: return(8); #if false case SymbolKind.ErrorType: return(9); #endif case SymbolKind.Label: return(10); case SymbolKind.Local: return(11); case SymbolKind.NetModule: return(12); case SymbolKind.Parameter: return(13); case SymbolKind.RangeVariable: return(14); case SymbolKind.TypeParameter: return(15); case SymbolKind.PointerType: return(16); case SymbolKind.DynamicType: return(17); case SymbolKind.Preprocessing: return(18); default: throw ExceptionUtilities.UnexpectedValue(kind); } }
public DefaultUnresolvedTypeParameter(SymbolKind ownerType, int index, string name = null) { this.ownerType = ownerType; this.index = index; this.name = name ?? ((ownerType == SymbolKind.Method ? "!!" : "!") + index.ToString(CultureInfo.InvariantCulture)); }
private bool AreEquivalentWorker(ISymbol x, ISymbol y, SymbolKind k, Dictionary <INamedTypeSymbol, INamedTypeSymbol> equivalentTypesWithDifferingAssemblies) { Contract.Requires(x.Kind == y.Kind && x.Kind == k); switch (k) { case SymbolKind.ArrayType: return(ArrayTypesAreEquivalent((IArrayTypeSymbol)x, (IArrayTypeSymbol)y, equivalentTypesWithDifferingAssemblies)); case SymbolKind.Assembly: return(AssembliesAreEquivalent((IAssemblySymbol)x, (IAssemblySymbol)y)); case SymbolKind.DynamicType: return(DynamicTypesAreEquivalent((IDynamicTypeSymbol)x, (IDynamicTypeSymbol)y)); case SymbolKind.Event: return(EventsAreEquivalent((IEventSymbol)x, (IEventSymbol)y, equivalentTypesWithDifferingAssemblies)); case SymbolKind.Field: return(FieldsAreEquivalent((IFieldSymbol)x, (IFieldSymbol)y, equivalentTypesWithDifferingAssemblies)); case SymbolKind.Label: return(LabelsAreEquivalent((ILabelSymbol)x, (ILabelSymbol)y)); case SymbolKind.Local: return(LocalsAreEquivalent((ILocalSymbol)x, (ILocalSymbol)y)); case SymbolKind.Method: return(MethodsAreEquivalent((IMethodSymbol)x, (IMethodSymbol)y, equivalentTypesWithDifferingAssemblies)); case SymbolKind.NetModule: return(ModulesAreEquivalent((IModuleSymbol)x, (IModuleSymbol)y)); case SymbolKind.NamedType: case SymbolKind.ErrorType: // ErrorType is handled in NamedTypesAreEquivalent return(NamedTypesAreEquivalent((INamedTypeSymbol)x, (INamedTypeSymbol)y, equivalentTypesWithDifferingAssemblies)); case SymbolKind.Namespace: return(NamespacesAreEquivalent((INamespaceSymbol)x, (INamespaceSymbol)y, equivalentTypesWithDifferingAssemblies)); case SymbolKind.Parameter: return(ParametersAreEquivalent((IParameterSymbol)x, (IParameterSymbol)y, equivalentTypesWithDifferingAssemblies)); case SymbolKind.PointerType: return(PointerTypesAreEquivalent((IPointerTypeSymbol)x, (IPointerTypeSymbol)y, equivalentTypesWithDifferingAssemblies)); case SymbolKind.Property: return(PropertiesAreEquivalent((IPropertySymbol)x, (IPropertySymbol)y, equivalentTypesWithDifferingAssemblies)); case SymbolKind.RangeVariable: return(RangeVariablesAreEquivalent((IRangeVariableSymbol)x, (IRangeVariableSymbol)y)); case SymbolKind.TypeParameter: return(TypeParametersAreEquivalent((ITypeParameterSymbol)x, (ITypeParameterSymbol)y, equivalentTypesWithDifferingAssemblies)); case SymbolKind.Preprocessing: return(PreprocessingSymbolsAreEquivalent((IPreprocessingSymbol)x, (IPreprocessingSymbol)y)); default: return(false); } }
protected LocalVariableSymbol(SymbolKind kind, string name, string documentation, Symbol parent, TypeSymbol valueType) : base(kind, name, documentation, parent, valueType) { }
static string GetSymbolTypeName(SymbolKind kind, string name) { return("Mono.Cecil" + "." + GetSymbolNamespace(kind) + "." + kind + name); }