private static void __Execute(atom.Trace context, int level, PropertyDeclarationSyntax data, string file, bool isShowPrivate) { if (__IsEnabled(data, isShowPrivate)) { context. SetComment(__GetType(data, data.Type?.ToString()), HINT.DATA_TYPE). SetUrl(file, __GetLine(data.GetLocation()), __GetPosition(data.GetLocation())). SetValue(data.Initializer?.Value?.ToString()). Send(NAME.SOURCE.PREVIEW, NAME.TYPE.PARAMETER, level, data.Identifier.ValueText); } }
private void Analyze( SyntaxNodeAnalysisContext context, PropertyDeclarationSyntax propertyDeclaration, IPropertySymbol property) { if (property.ContainingType is null) { return; } if (property.ContainingType.IsAbstract) { return; } if (!CommandParameterSymbol.IsParameterProperty(property)) { return; } var isInsideCommand = property .ContainingType .AllInterfaces .Any(s => s.DisplayNameMatches(SymbolNames.CliFxCommandInterface)); if (!isInsideCommand) { context.ReportDiagnostic(CreateDiagnostic(propertyDeclaration.GetLocation())); } }
public static void Analyze(SyntaxNodeAnalysisContext context, PropertyDeclarationSyntax property) { IFieldSymbol fieldSymbol = GetBackingFieldSymbol(context, property); if (fieldSymbol != null) { var declarator = (VariableDeclaratorSyntax)fieldSymbol.DeclaringSyntaxReferences[0].GetSyntax(context.CancellationToken); if (declarator.SyntaxTree.Equals(property.SyntaxTree)) { IPropertySymbol propertySymbol = context .SemanticModel .GetDeclaredSymbol(property, context.CancellationToken); if (propertySymbol != null && propertySymbol.IsStatic == fieldSymbol.IsStatic && propertySymbol.Type == fieldSymbol.Type && propertySymbol.ContainingType?.Equals(fieldSymbol.ContainingType) == true && CheckPreprocessorDirectives(property, declarator)) { context.ReportDiagnostic( DiagnosticDescriptors.ReplacePropertyWithAutoImplementedProperty, property.GetLocation()); FadeOut(context, property); } } } }
private void Analyze( SyntaxNodeAnalysisContext context, PropertyDeclarationSyntax propertyDeclaration, IPropertySymbol property) { var parameter = CommandParameterSymbol.TryResolve(property); if (parameter is null) { return; } foreach (var validatorType in parameter.ValidatorTypes) { // We check against an internal interface because checking against a generic class is a pain var validatorImplementsInterface = validatorType .AllInterfaces .Any(s => s.DisplayNameMatches(SymbolNames.CliFxBindingValidatorInterface)); if (!validatorImplementsInterface) { context.ReportDiagnostic(CreateDiagnostic(propertyDeclaration.GetLocation())); // No need to report multiple identical diagnostics on the same node break; } } }
private void Analyze( SyntaxNodeAnalysisContext context, PropertyDeclarationSyntax propertyDeclaration, IPropertySymbol property) { var option = CommandOptionSymbol.TryResolve(property); if (option is null) { return; } if (option.ConverterType is null) { return; } // We check against an internal interface because checking against a generic class is a pain var converterImplementsInterface = option .ConverterType .AllInterfaces .Any(s => s.DisplayNameMatches(SymbolNames.CliFxBindingConverterInterface)); if (!converterImplementsInterface) { context.ReportDiagnostic(CreateDiagnostic(propertyDeclaration.GetLocation())); } }
public ISyntaxNodeDeclaration Convert(PropertyDeclarationSyntax propertyDeclarationSyntax) { var location = propertyDeclarationSyntax.GetLocation(); var locationLineSpan = location.GetLineSpan(); var declaration = CreateLocation(locationLineSpan.StartLinePosition); return(CreateProperty(declaration, propertyDeclarationSyntax)); }
private void AnalyzeProperty(SyntaxNodeAnalysisContext context) { PropertyDeclarationSyntax propertyDeclarationSyntax = context.Node as PropertyDeclarationSyntax; if (propertyDeclarationSyntax != null) { Diagnose(propertyDeclarationSyntax.Identifier.ValueText, propertyDeclarationSyntax.GetLocation(), context.ReportDiagnostic); } }
public ISyntaxNodeDeclaration Convert(PropertyDeclarationSyntax propertyDeclarationSyntax) { var location = propertyDeclarationSyntax.GetLocation(); var locationLineSpan = location.GetLineSpan(); var declaration = CreateLocation(locationLineSpan.StartLinePosition); var body = GetBody(propertyDeclarationSyntax); var bodyLocation = body.GetLocation(); var bodyLineSpan = bodyLocation.GetLineSpan(); var bodyStart = CreateLocation(bodyLineSpan.StartLinePosition); var bodyEnd = CreateLocation(bodyLineSpan.EndLinePosition); return(CreateProperty(declaration, bodyStart, bodyEnd, body)); }
private static void AnalyzeProperty(SyntaxNodeAnalysisContext context) { PropertyDeclarationSyntax node = (PropertyDeclarationSyntax)context.Node; if (Helper.IsInTestClass(context)) { return; } if (!IsPositiveName(node.Identifier.Text)) { CreateDiagnostic(context, node.GetLocation()); } }
private void Analyze( SyntaxNodeAnalysisContext context, PropertyDeclarationSyntax propertyDeclaration, IPropertySymbol property) { if (property.ContainingType is null) { return; } var parameter = CommandParameterSymbol.TryResolve(property); if (parameter is null) { return; } if (string.IsNullOrWhiteSpace(parameter.Name)) { return; } var otherProperties = property .ContainingType .GetMembers() .OfType <IPropertySymbol>() .Where(m => !m.Equals(property, SymbolEqualityComparer.Default)) .ToArray(); foreach (var otherProperty in otherProperties) { var otherParameter = CommandParameterSymbol.TryResolve(otherProperty); if (otherParameter is null) { continue; } if (string.IsNullOrWhiteSpace(otherParameter.Name)) { continue; } if (string.Equals(parameter.Name, otherParameter.Name, StringComparison.OrdinalIgnoreCase)) { context.ReportDiagnostic(CreateDiagnostic(propertyDeclaration.GetLocation())); } } }
private void Analyze( SyntaxNodeAnalysisContext context, PropertyDeclarationSyntax propertyDeclaration, IPropertySymbol property) { if (property.ContainingType is null) { return; } var option = CommandOptionSymbol.TryResolve(property); if (option is null) { return; } if (option.ShortName is null) { return; } var otherProperties = property .ContainingType .GetMembers() .OfType <IPropertySymbol>() .Where(m => !m.Equals(property, SymbolEqualityComparer.Default)) .ToArray(); foreach (var otherProperty in otherProperties) { var otherOption = CommandOptionSymbol.TryResolve(otherProperty); if (otherOption is null) { continue; } if (otherOption.ShortName is null) { continue; } if (option.ShortName == otherOption.ShortName) { context.ReportDiagnostic(CreateDiagnostic(propertyDeclaration.GetLocation())); } } }
private void Analyze( SyntaxNodeAnalysisContext context, PropertyDeclarationSyntax propertyDeclaration, IPropertySymbol property) { var option = CommandOptionSymbol.TryResolve(property); if (option is null) { return; } if (string.IsNullOrWhiteSpace(option.Name) && option.ShortName is null) { context.ReportDiagnostic(CreateDiagnostic(propertyDeclaration.GetLocation())); } }
static void AnalyzePropertyDeclaration(SyntaxNodeAnalysisContext context, PropertyDeclarationSyntax propertyDeclarationSyntax, ITypeSymbol enumerableTypeSymbol) { if (propertyDeclarationSyntax.Modifiers.Any(token => token.Text == "public")) { return; } var semanticModel = context.SemanticModel; var typeSymbol = semanticModel.GetDeclaredSymbol(propertyDeclarationSyntax).Type; if (typeSymbol is null || !typeSymbol.BoxesEnumerator()) { return; } var diagnostic = Diagnostic.Create(rule, propertyDeclarationSyntax.GetLocation(), enumerableTypeSymbol.Name, typeSymbol.Name); context.ReportDiagnostic(diagnostic); }
private void Analyze( SyntaxNodeAnalysisContext context, PropertyDeclarationSyntax propertyDeclaration, IPropertySymbol property) { if (property.ContainingType is null) { return; } if (!CommandParameterSymbol.IsParameterProperty(property)) { return; } if (IsScalar(property.Type)) { return; } var otherProperties = property .ContainingType .GetMembers() .OfType <IPropertySymbol>() .Where(m => !m.Equals(property, SymbolEqualityComparer.Default)) .ToArray(); foreach (var otherProperty in otherProperties) { if (!CommandParameterSymbol.IsParameterProperty(otherProperty)) { continue; } if (!IsScalar(otherProperty.Type)) { context.ReportDiagnostic(CreateDiagnostic(propertyDeclaration.GetLocation())); } } }
private void Analyze( SyntaxNodeAnalysisContext context, PropertyDeclarationSyntax propertyDeclaration, IPropertySymbol property) { var option = CommandOptionSymbol.TryResolve(property); if (option is null) { return; } if (option.ShortName is null) { return; } if (!char.IsLetter(option.ShortName.Value)) { context.ReportDiagnostic(CreateDiagnostic(propertyDeclaration.GetLocation())); } }
public override void VisitPropertyDeclaration(PropertyDeclarationSyntax node) { AddEntry(node.Identifier.Text, node.GetLocation()); base.VisitPropertyDeclaration(node); }