protected override IEnumerable <AnalyzerTreeNodeData> FetchChildren(CancellationToken ct) { foundMethods = new Lazy <Hashtable>(LazyThreadSafetyMode.ExecutionAndPublication); var includeAllModules = showWrites && CustomAttributesUtils.IsPseudoCustomAttributeType(analyzedField.DeclaringType); var analyzer = new ScopedWhereUsedAnalyzer <AnalyzerTreeNodeData>(Context.DocumentService, analyzedField, FindReferencesInType, includeAllModules); foreach (var child in analyzer.PerformAnalysis(ct)) { yield return(child); } foundMethods = null; if (showWrites) { var hash = new HashSet <AssemblyDef>(); foreach (var module in analyzer.AllModules) { if (module.Assembly is AssemblyDef asm && hash.Add(asm)) { foreach (var node in CheckCustomAttributeNamedArgumentWrite(Context, asm, analyzedField)) { yield return(node); } } foreach (var node in CheckCustomAttributeNamedArgumentWrite(Context, module, analyzedField)) { yield return(node); } } } }
public AttributeAppliedToNode(TypeDef analyzedType) { this.analyzedType = analyzedType ?? throw new ArgumentNullException(nameof(analyzedType)); analyzedTypes = new List <TypeDef> { analyzedType }; includeAllModules = CustomAttributesUtils.IsPseudoCustomAttributeType(analyzedType); var ca = analyzedType.CustomAttributes.Find("System.AttributeUsageAttribute"); if (ca is not null && ca.ConstructorArguments.Count == 1 && ca.ConstructorArguments[0].Value is int) { usage = (AttributeTargets)ca.ConstructorArguments[0].Value; }
protected override IEnumerable <AnalyzerTreeNodeData> FetchChildren(CancellationToken ct) { InitializeAnalyzer(); if (isSetter) { property = analyzedMethod.DeclaringType.Properties.FirstOrDefault(a => a.SetMethod == analyzedMethod); } var includeAllModules = !(property is null) && CustomAttributesUtils.IsPseudoCustomAttributeType(analyzedMethod.DeclaringType); ComUtils.GetMemberInfo(analyzedMethod, out isComType, out comGuid, out vtblIndex); includeAllModules |= isComType; var options = ScopedWhereUsedAnalyzerOptions.None; if (includeAllModules) { options |= ScopedWhereUsedAnalyzerOptions.IncludeAllModules; } if (isComType) { options |= ScopedWhereUsedAnalyzerOptions.ForcePublic; } var analyzer = new ScopedWhereUsedAnalyzer <AnalyzerTreeNodeData>(Context.DocumentService, analyzedMethod, FindReferencesInType, options); foreach (var child in analyzer.PerformAnalysis(ct)) { yield return(child); } if (!(property is null)) { var hash = new HashSet <AssemblyDef>(); foreach (var module in analyzer.AllModules) { if (module.Assembly is AssemblyDef asm && hash.Add(module.Assembly)) { foreach (var node in FieldAccessNode.CheckCustomAttributeNamedArgumentWrite(Context, asm, property)) { yield return(node); } } foreach (var node in FieldAccessNode.CheckCustomAttributeNamedArgumentWrite(Context, module, property)) { yield return(node); } } } ReleaseAnalyzer(); }
protected override IEnumerable <AnalyzerTreeNodeData> FetchChildren(CancellationToken ct) { foundMethods = new ConcurrentDictionary <MethodDef, int>(); if (isSetter) { property = analyzedMethod.DeclaringType.Properties.FirstOrDefault(a => a.SetMethod == analyzedMethod); } var includeAllModules = (property is not null && CustomAttributesUtils.IsPseudoCustomAttributeType(analyzedMethod.DeclaringType)) || implMapName is not null; var options = ScopedWhereUsedAnalyzerOptions.None; if (includeAllModules) { options |= ScopedWhereUsedAnalyzerOptions.IncludeAllModules; } if (implMapName is not null) { options |= ScopedWhereUsedAnalyzerOptions.ForcePublic; } var analyzer = new ScopedWhereUsedAnalyzer <AnalyzerTreeNodeData>(Context.DocumentService, analyzedMethod, FindReferencesInType, options); foreach (var child in analyzer.PerformAnalysis(ct)) { yield return(child); } if (property is not null) { var hash = new HashSet <AssemblyDef>(); foreach (var module in analyzer.AllModules) { if (module.Assembly is AssemblyDef asm && hash.Add(asm)) { foreach (var node in FieldAccessNode.CheckCustomAttributeNamedArgumentWrite(Context, asm, property)) { yield return(node); } } foreach (var node in FieldAccessNode.CheckCustomAttributeNamedArgumentWrite(Context, module, property)) { yield return(node); } } } foundMethods = null; }