internal ExceptionSources (TypeReference exception)
{
Exception = exception;
- SourcesList = new List<IMemberReference> ();
- Sources = new ReadOnlyCollection<IMemberReference> (SourcesList);
+ Sources = new HashSet<MemberReference> ();
}
public TypeReference Exception { get; private set; }
- public ReadOnlyCollection<IMemberReference> Sources { get; private set; }
- internal List<IMemberReference> SourcesList;
+ internal HashSet<MemberReference> Sources;
}
this.locations = locations;
}
- public IEnumerable<ExceptionSources> this [IMemberReference member] {
+ public IEnumerable<ExceptionSources> this [MemberReference member] {
get {
if (member == null)
throw new ArgumentNullException ("member");
- IMemberReference memberDef = member.Resolve ();
+ MemberReference memberDef = member.Resolve ();
if (memberDef == null) {
ArrayType array = member.DeclaringType as ArrayType;
if (array != null && array.Rank > 1) {
Dictionary<string, ExceptionSources> e;
if (!db.TryGetValue (memberDecl, out e)) {
e = new Dictionary<string, ExceptionSources> ();
+ db.Add (memberDecl, e);
var bodies = GetMethodBodies (member);
foreach (var body in bodies) {
if (body == null)
continue;
FillExceptions (body, e);
}
- db.Add (memberDecl, e);
}
return e.Values;
}
}
- MethodBody[] GetMethodBodies (IMemberReference member)
+ MethodBody[] GetMethodBodies (MemberReference member)
{
if (member is MethodReference) {
return new[]{ (((MethodReference) member).Resolve ()).Body };
}
if (member is PropertyReference) {
- PropertyDefinition prop = ((PropertyReference) member).Resolve ();
+ PropertyDefinition prop = (PropertyDefinition) member;
return new[]{
prop.GetMethod != null ? prop.GetMethod.Body : null,
prop.SetMethod != null ? prop.SetMethod.Body : null,
if (member is FieldReference)
return new MethodBody[]{};
if (member is EventReference) {
- EventDefinition ev = ((EventReference) member).Resolve ();
+ EventDefinition ev = (EventDefinition) member;
return new[]{
ev.AddMethod != null ? ev.AddMethod.Body : null,
ev.InvokeMethod != null ? ev.InvokeMethod.Body : null,
if ((locations & ExceptionLocations.Assembly) == 0 &&
(locations & ExceptionLocations.DependentAssemblies) == 0)
break;
- IMemberReference memberRef = ((IMemberReference) instruction.Operand);
+ MemberReference memberRef = ((MemberReference) instruction.Operand);
if (((locations & ExceptionLocations.Assembly) != 0 &&
body.Method.DeclaringType.Scope.Name == memberRef.DeclaringType.Scope.Name) ||
((locations & ExceptionLocations.DependentAssemblies) != 0 &&
body.Method.DeclaringType.Scope.Name != memberRef.DeclaringType.Scope.Name)) {
+
IEnumerable<ExceptionSources> memberExceptions = this [memberRef];
AddExceptions (body, instruction,
memberExceptions.Select (es => es.Exception),
if (IsExceptionConstructor (ctor)) {
AddExceptions (body, instruction,
new TypeReference[]{ctor.DeclaringType},
- new IMemberReference[]{body.Method},
+ new MemberReference[]{body.Method},
exceptions);
}
break;
}
}
- void AddExceptions (MethodBody body, Instruction instruction, IEnumerable<TypeReference> add, IEnumerable<IMemberReference> sources,
+ void AddExceptions (MethodBody body, Instruction instruction, IEnumerable<TypeReference> add, IEnumerable<MemberReference> sources,
Dictionary<string, ExceptionSources> exceptions)
{
var handlers = body.ExceptionHandlers.Cast<ExceptionHandler> ()
s = new ExceptionSources (ex);
exceptions.Add (eName, s);
}
- s.SourcesList.AddRange (sources);
+ foreach (var m in sources)
+ s.Sources.Add (m);
}
}
}