From 100b7160a86438542364ce34c5c5e09daa90228d Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Tue, 22 Feb 2011 13:33:22 +0100 Subject: [PATCH] Fix constants. --- Mono.Cecil/Mono.Cecil/FieldDefinition.cs | 10 +--------- Mono.Cecil/Mono.Cecil/IConstantProvider.cs | 12 ++++++++---- Mono.Cecil/Mono.Cecil/ParameterDefinition.cs | 10 +--------- Mono.Cecil/Mono.Cecil/PropertyDefinition.cs | 10 +--------- 4 files changed, 11 insertions(+), 31 deletions(-) diff --git a/Mono.Cecil/Mono.Cecil/FieldDefinition.cs b/Mono.Cecil/Mono.Cecil/FieldDefinition.cs index f52e7ddc6..caa4898c2 100644 --- a/Mono.Cecil/Mono.Cecil/FieldDefinition.cs +++ b/Mono.Cecil/Mono.Cecil/FieldDefinition.cs @@ -124,7 +124,7 @@ namespace Mono.Cecil { public bool HasConstant { get { - ResolveConstant (); + this.ResolveConstant (ref constant, Module); return constant != Mixin.NoValue; } @@ -136,14 +136,6 @@ namespace Mono.Cecil { set { constant = value; } } - void ResolveConstant () - { - if (constant != Mixin.NotResolved) - return; - - this.ResolveConstant (ref constant, Module); - } - public bool HasCustomAttributes { get { if (custom_attributes != null) diff --git a/Mono.Cecil/Mono.Cecil/IConstantProvider.cs b/Mono.Cecil/Mono.Cecil/IConstantProvider.cs index dbc5481cc..a3eaacc7c 100644 --- a/Mono.Cecil/Mono.Cecil/IConstantProvider.cs +++ b/Mono.Cecil/Mono.Cecil/IConstantProvider.cs @@ -44,10 +44,14 @@ namespace Mono.Cecil { ref object constant, ModuleDefinition module) { - if (module.HasImage ()) - module.Read (ref constant, self, (provider, reader) => reader.ReadConstant (provider)); - else - constant = Mixin.NoValue; + lock (module.SyncRoot) { + if (constant != Mixin.NotResolved) + return; + if (module.HasImage ()) + constant = module.Read (self, (provider, reader) => reader.ReadConstant (provider)); + else + constant = Mixin.NoValue; + } } } } diff --git a/Mono.Cecil/Mono.Cecil/ParameterDefinition.cs b/Mono.Cecil/Mono.Cecil/ParameterDefinition.cs index 540072f14..ec916975f 100644 --- a/Mono.Cecil/Mono.Cecil/ParameterDefinition.cs +++ b/Mono.Cecil/Mono.Cecil/ParameterDefinition.cs @@ -51,7 +51,7 @@ namespace Mono.Cecil { public bool HasConstant { get { - ResolveConstant (); + this.ResolveConstant (ref constant, parameter_type.Module); return constant != Mixin.NoValue; } @@ -63,14 +63,6 @@ namespace Mono.Cecil { set { constant = value; } } - void ResolveConstant () - { - if (constant != Mixin.NotResolved) - return; - - this.ResolveConstant (ref constant, parameter_type.Module); - } - public bool HasCustomAttributes { get { if (custom_attributes != null) diff --git a/Mono.Cecil/Mono.Cecil/PropertyDefinition.cs b/Mono.Cecil/Mono.Cecil/PropertyDefinition.cs index 54148492e..43b459e63 100644 --- a/Mono.Cecil/Mono.Cecil/PropertyDefinition.cs +++ b/Mono.Cecil/Mono.Cecil/PropertyDefinition.cs @@ -168,7 +168,7 @@ namespace Mono.Cecil { public bool HasConstant { get { - ResolveConstant (); + this.ResolveConstant (ref constant, Module); return constant != Mixin.NoValue; } @@ -180,14 +180,6 @@ namespace Mono.Cecil { set { constant = value; } } - void ResolveConstant () - { - if (constant != Mixin.NotResolved) - return; - - this.ResolveConstant (ref constant, Module); - } - #region PropertyAttributes public bool IsSpecialName {