Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a race condition between certain Has properties and their collection property #843

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions Mono.Cecil/AssemblyReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -899,8 +899,6 @@ public Collection<TypeDefinition> ReadNestedTypes (TypeDefinition type)
nested_types.Add (nested_type);
}

metadata.RemoveNestedTypeMapping (type);

return nested_types;
}

Expand Down Expand Up @@ -975,7 +973,6 @@ TypeDefinition GetNestedTypeDeclaringType (TypeDefinition type)
if (!metadata.TryGetReverseNestedTypeMapping (type, out declaring_rid))
return null;

metadata.RemoveReverseNestedTypeMapping (type);
return GetTypeDefinition (declaring_rid);
}

Expand Down Expand Up @@ -1242,8 +1239,6 @@ public InterfaceImplementationCollection ReadInterfaces (TypeDefinition type)
new MetadataToken(TokenType.InterfaceImpl, mapping [i].Col1)));
}

metadata.RemoveInterfaceMapping (type);

return interfaces;
}

Expand Down Expand Up @@ -1466,8 +1461,6 @@ public Collection<EventDefinition> ReadEvents (TypeDefinition type)

var events = new MemberDefinitionCollection<EventDefinition> (type, (int) range.Length);

metadata.RemoveEventsRange (type);

if (range.Length == 0)
return events;

Expand Down Expand Up @@ -1536,8 +1529,6 @@ public Collection<PropertyDefinition> ReadProperties (TypeDefinition type)
if (!metadata.TryGetPropertiesRange (type, out range))
return new MemberDefinitionCollection<PropertyDefinition> (type);

metadata.RemovePropertiesRange (type);

var properties = new MemberDefinitionCollection<PropertyDefinition> (type, (int) range.Length);

if (range.Length == 0)
Expand Down Expand Up @@ -1912,8 +1903,6 @@ public Collection<GenericParameter> ReadGenericParameters (IGenericParameterProv
if (!metadata.TryGetGenericParameterRanges (provider, out ranges))
return new GenericParameterCollection (provider);

metadata.RemoveGenericParameterRange (provider);

var generic_parameters = new GenericParameterCollection (provider, RangesSize (ranges));

for (int i = 0; i < ranges.Length; i++)
Expand Down Expand Up @@ -2029,8 +2018,6 @@ public GenericParameterConstraintCollection ReadGenericConstraints (GenericParam
new MetadataToken (TokenType.GenericParamConstraint, mapping [i].Col1)));
}

metadata.RemoveGenericConstraintMapping (generic_parameter);

return constraints;
}

Expand Down Expand Up @@ -2083,8 +2070,6 @@ public Collection<MethodReference> ReadOverrides (MethodDefinition method)
for (int i = 0; i < mapping.Count; i++)
overrides.Add ((MethodReference) LookupToken (mapping [i]));

metadata.RemoveOverrideMapping (method);

return overrides;
}

Expand Down Expand Up @@ -2521,8 +2506,6 @@ public Collection<CustomAttribute> ReadCustomAttributes (ICustomAttributeProvide
for (int i = 0; i < ranges.Length; i++)
ReadCustomAttributeRange (ranges [i], custom_attributes);

metadata.RemoveCustomAttributeRange (owner);

if (module.IsWindowsMetadata ())
foreach (var custom_attribute in custom_attributes)
WindowsRuntimeProjections.Project (owner, custom_attribute);
Expand Down Expand Up @@ -2676,8 +2659,6 @@ public Collection<SecurityDeclaration> ReadSecurityDeclarations (ISecurityDeclar
for (int i = 0; i < ranges.Length; i++)
ReadSecurityDeclarationRange (ranges [i], security_declarations);

metadata.RemoveSecurityDeclarationRange (owner);

return security_declarations;
}

Expand Down
50 changes: 0 additions & 50 deletions Mono.Cecil/MetadataSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,6 @@ public void SetNestedTypeMapping (uint type_rid, Collection<uint> mapping)
NestedTypes [type_rid] = mapping;
}

public void RemoveNestedTypeMapping (TypeDefinition type)
{
NestedTypes.Remove (type.token.RID);
}

public bool TryGetReverseNestedTypeMapping (TypeDefinition type, out uint declaring)
{
return ReverseNestedTypes.TryGetValue (type.token.RID, out declaring);
Expand All @@ -258,11 +253,6 @@ public void SetReverseNestedTypeMapping (uint nested, uint declaring)
ReverseNestedTypes [nested] = declaring;
}

public void RemoveReverseNestedTypeMapping (TypeDefinition type)
{
ReverseNestedTypes.Remove (type.token.RID);
}

public bool TryGetInterfaceMapping (TypeDefinition type, out Collection<Row<uint, MetadataToken>> mapping)
{
return Interfaces.TryGetValue (type.token.RID, out mapping);
Expand All @@ -273,11 +263,6 @@ public void SetInterfaceMapping (uint type_rid, Collection<Row<uint, MetadataTok
Interfaces [type_rid] = mapping;
}

public void RemoveInterfaceMapping (TypeDefinition type)
{
Interfaces.Remove (type.token.RID);
}

public void AddPropertiesRange (uint type_rid, Range range)
{
Properties.Add (type_rid, range);
Expand All @@ -288,11 +273,6 @@ public bool TryGetPropertiesRange (TypeDefinition type, out Range range)
return Properties.TryGetValue (type.token.RID, out range);
}

public void RemovePropertiesRange (TypeDefinition type)
{
Properties.Remove (type.token.RID);
}

public void AddEventsRange (uint type_rid, Range range)
{
Events.Add (type_rid, range);
Expand All @@ -303,41 +283,21 @@ public bool TryGetEventsRange (TypeDefinition type, out Range range)
return Events.TryGetValue (type.token.RID, out range);
}

public void RemoveEventsRange (TypeDefinition type)
{
Events.Remove (type.token.RID);
}

public bool TryGetGenericParameterRanges (IGenericParameterProvider owner, out Range [] ranges)
{
return GenericParameters.TryGetValue (owner.MetadataToken, out ranges);
}

public void RemoveGenericParameterRange (IGenericParameterProvider owner)
{
GenericParameters.Remove (owner.MetadataToken);
}

public bool TryGetCustomAttributeRanges (ICustomAttributeProvider owner, out Range [] ranges)
{
return CustomAttributes.TryGetValue (owner.MetadataToken, out ranges);
}

public void RemoveCustomAttributeRange (ICustomAttributeProvider owner)
{
CustomAttributes.Remove (owner.MetadataToken);
}

public bool TryGetSecurityDeclarationRanges (ISecurityDeclarationProvider owner, out Range [] ranges)
{
return SecurityDeclarations.TryGetValue (owner.MetadataToken, out ranges);
}

public void RemoveSecurityDeclarationRange (ISecurityDeclarationProvider owner)
{
SecurityDeclarations.Remove (owner.MetadataToken);
}

public bool TryGetGenericConstraintMapping (GenericParameter generic_parameter, out Collection<Row<uint, MetadataToken>> mapping)
{
return GenericConstraints.TryGetValue (generic_parameter.token.RID, out mapping);
Expand All @@ -348,11 +308,6 @@ public void SetGenericConstraintMapping (uint gp_rid, Collection<Row<uint, Metad
GenericConstraints [gp_rid] = mapping;
}

public void RemoveGenericConstraintMapping (GenericParameter generic_parameter)
{
GenericConstraints.Remove (generic_parameter.token.RID);
}

public bool TryGetOverrideMapping (MethodDefinition method, out Collection<MetadataToken> mapping)
{
return Overrides.TryGetValue (method.token.RID, out mapping);
Expand All @@ -363,11 +318,6 @@ public void SetOverrideMapping (uint rid, Collection<MetadataToken> mapping)
Overrides [rid] = mapping;
}

public void RemoveOverrideMapping (MethodDefinition method)
{
Overrides.Remove (method.token.RID);
}

public Document GetDocument (uint rid)
{
if (rid < 1 || rid > Documents.Length)
Expand Down