public ScopedWhereUsedAnalyzer(IDsDocumentService documentService, TypeDef analyzedType, Func <TypeDef, IEnumerable <T> > typeAnalysisFunction, ScopedWhereUsedAnalyzerOptions options = ScopedWhereUsedAnalyzerOptions.None) { this.analyzedType = analyzedType; typeScope = analyzedType; this.typeAnalysisFunction = typeAnalysisFunction; this.documentService = documentService; allModules = new List <ModuleDef>(); this.options = options; }
Accessibility GetMethodAccessibility(MethodDef method, ScopedWhereUsedAnalyzerOptions options) { if (method is null) { return(0); } if ((options & ScopedWhereUsedAnalyzerOptions.ForcePublic) != 0) { return(Accessibility.Public); } Accessibility accessibility; switch (method.Attributes & MethodAttributes.MemberAccessMask) { case MethodAttributes.Private: default: accessibility = Accessibility.Private; break; case MethodAttributes.FamANDAssem: accessibility = Accessibility.FamilyAndInternal; break; case MethodAttributes.PrivateScope: case MethodAttributes.Family: accessibility = Accessibility.Family; break; case MethodAttributes.Assembly: accessibility = Accessibility.Internal; break; case MethodAttributes.FamORAssem: accessibility = Accessibility.FamilyOrInternal; break; case MethodAttributes.Public: accessibility = Accessibility.Public; break; } return(accessibility); }
public ScopedWhereUsedAnalyzer(IDsDocumentService documentService, FieldDef field, Func <TypeDef, IEnumerable <T> > typeAnalysisFunction, ScopedWhereUsedAnalyzerOptions options = ScopedWhereUsedAnalyzerOptions.None) : this(documentService, field.DeclaringType, typeAnalysisFunction, options) { switch ((options & ScopedWhereUsedAnalyzerOptions.ForcePublic) != 0 ? FieldAttributes.Public : field.Attributes& FieldAttributes.FieldAccessMask) { case FieldAttributes.Private: default: memberAccessibility = Accessibility.Private; break; case FieldAttributes.FamANDAssem: memberAccessibility = Accessibility.FamilyAndInternal; break; case FieldAttributes.Assembly: memberAccessibility = Accessibility.Internal; break; case FieldAttributes.PrivateScope: case FieldAttributes.Family: memberAccessibility = Accessibility.Family; break; case FieldAttributes.FamORAssem: memberAccessibility = Accessibility.FamilyOrInternal; break; case FieldAttributes.Public: memberAccessibility = Accessibility.Public; break; } }
public ScopedWhereUsedAnalyzer(IDsDocumentService documentService, EventDef eventDef, Func <TypeDef, IEnumerable <T> > typeAnalysisFunction, ScopedWhereUsedAnalyzerOptions options = ScopedWhereUsedAnalyzerOptions.None) : this(documentService, eventDef.DeclaringType, typeAnalysisFunction, options) { var adderAccessibility = eventDef.AddMethod is null ? Accessibility.Private : GetMethodAccessibility(eventDef.AddMethod, options); var removerAccessibility = eventDef.RemoveMethod is null ? Accessibility.Private : GetMethodAccessibility(eventDef.RemoveMethod, options); var invokerAccessibility = eventDef.InvokeMethod is null ? Accessibility.Private : GetMethodAccessibility(eventDef.InvokeMethod, options); memberAccessibility = (Accessibility)Math.Max(Math.Max((int)adderAccessibility, (int)removerAccessibility), (int)invokerAccessibility); }
public ScopedWhereUsedAnalyzer(IDsDocumentService documentService, PropertyDef property, Func <TypeDef, IEnumerable <T> > typeAnalysisFunction, ScopedWhereUsedAnalyzerOptions options = ScopedWhereUsedAnalyzerOptions.None) : this(documentService, property.DeclaringType, typeAnalysisFunction, options) { var getterAccessibility = property.GetMethod is null ? Accessibility.Private : GetMethodAccessibility(property.GetMethod, options); var setterAccessibility = property.SetMethod is null ? Accessibility.Private : GetMethodAccessibility(property.SetMethod, options); memberAccessibility = (Accessibility)Math.Max((int)getterAccessibility, (int)setterAccessibility); }
public ScopedWhereUsedAnalyzer(IDsDocumentService documentService, MethodDef method, Func <TypeDef, IEnumerable <T> > typeAnalysisFunction, ScopedWhereUsedAnalyzerOptions options = ScopedWhereUsedAnalyzerOptions.None) : this(documentService, method.DeclaringType, typeAnalysisFunction, options) => memberAccessibility = GetMethodAccessibility(method, options);