Exemple #1
0
 /// <summary>
 /// Initializes <see cref="otherMethods"/>, <see cref="getMethods"/>,
 /// and <see cref="setMethods"/>.
 /// </summary>
 protected virtual void InitializePropertyMethods_NoLock()
 {
     getMethods = ThreadSafeListCreator.Create<MethodDef>();
     setMethods = ThreadSafeListCreator.Create<MethodDef>();
     otherMethods = ThreadSafeListCreator.Create<MethodDef>();
 }
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="local1">Local type #1</param>
		/// <param name="local2">Local type #2</param>
		/// <param name="local3">Local type #3</param>
		public LocalSig(TypeSig local1, TypeSig local2, TypeSig local3) {
			this.callingConvention = CallingConvention.LocalSig;
			this.locals = ThreadSafeListCreator.Create<TypeSig>(local1, local2, local3);
		}
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="flags">Flags</param>
 public VTable(VTableFlags flags)
 {
     this.flags   = flags;
     this.methods = ThreadSafeListCreator.Create <IMethod>();
 }
Exemple #4
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="genericType">The generic type</param>
		/// <param name="genArgs">Generic arguments</param>
		public GenericInstSig(ClassOrValueTypeSig genericType, IList<TypeSig> genArgs) {
			this.genericType = genericType;
			this.genericArgs = ThreadSafeListCreator.Create<TypeSig>(genArgs);
		}
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="callingConvention">Calling convention (must have GenericInst set)</param>
		/// <param name="size">Number of generic args</param>
		internal GenericInstMethodSig(CallingConvention callingConvention, uint size) {
			this.callingConvention = callingConvention;
			this.genericArgs = ThreadSafeListCreator.Create<TypeSig>((int)size);
		}
Exemple #6
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ctor">Custom attribute constructor</param>
 /// <param name="arguments">Constructor arguments. The list is now owned by this instance.</param>
 /// <param name="namedArguments">Named arguments. The list is now owned by this instance.</param>
 /// <param name="blobReader">A reader that returns the original custom attribute blob data</param>
 internal CustomAttribute(ICustomAttributeType ctor, List<CAArgument> arguments, List<CANamedArgument> namedArguments, IBinaryReader blobReader)
 {
     this.ctor = ctor;
     this.arguments = arguments == null ? ThreadSafeListCreator.Create<CAArgument>() : ThreadSafeListCreator.MakeThreadSafe(arguments);
     this.namedArguments = namedArguments == null ? ThreadSafeListCreator.Create<CANamedArgument>() : ThreadSafeListCreator.MakeThreadSafe(namedArguments);
     this.blobReader = blobReader;
 }
Exemple #7
0
 /// <summary>Reset <see cref="AddMethod"/>, <see cref="InvokeMethod"/>, <see cref="RemoveMethod"/>, <see cref="OtherMethods"/></summary>
 protected void ResetMethods()
 {
     otherMethods = null;
 }
Exemple #8
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="capacity">Initial capacity of <see cref="UsingCounts"/></param>
 public PdbUsingGroupsCustomDebugInfo(int capacity)
 {
     usingCounts = ThreadSafeListCreator.Create <ushort>(capacity);
 }
Exemple #9
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="capacity">Initial capacity of <see cref="Scopes"/></param>
 public PdbStateMachineHoistedLocalScopesCustomDebugInfo(int capacity)
 {
     scopes = ThreadSafeListCreator.Create <StateMachineHoistedLocalScope>(capacity);
 }
Exemple #10
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="stepInfosCapacity">Default capacity for <see cref="StepInfos"/></param>
 public PdbAsyncMethodCustomDebugInfo(int stepInfosCapacity)
 {
     asyncStepInfos = ThreadSafeListCreator.Create <PdbAsyncStepInfo>(stepInfosCapacity);
 }
Exemple #11
0
 /// <summary>
 /// Constructor
 /// </summary>
 public PdbUsingGroupsCustomDebugInfo()
 {
     usingCounts = ThreadSafeListCreator.Create <ushort>();
 }
 /// <summary>
 /// Default constructor
 /// </summary>
 public VTableFixups()
 {
     this.vtables = ThreadSafeListCreator.Create <VTable>();
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="rva">RVA of this vtable</param>
 /// <param name="flags">Flgas</param>
 /// <param name="methods">Vtable methods</param>
 public VTable(RVA rva, VTableFlags flags, IEnumerable <IMethod> methods)
 {
     this.rva     = rva;
     this.flags   = flags;
     this.methods = ThreadSafeListCreator.Create <IMethod>(methods);
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="rva">RVA of this vtable</param>
 /// <param name="flags">Flgas</param>
 /// <param name="numSlots">Number of methods in vtable</param>
 public VTable(RVA rva, VTableFlags flags, int numSlots)
 {
     this.rva     = rva;
     this.flags   = flags;
     this.methods = ThreadSafeListCreator.Create <IMethod>(numSlots);
 }
		void InitializePropertyMethods_NoLock() {
			if (otherMethods != null)
				return;
#if THREAD_SAFE
			theLock.EnterWriteLock(); try {
			if (otherMethods != null) return;
#endif
			ThreadSafe.IList<MethodDef> newOtherMethods;
			var dt = DeclaringType2_NoLock as TypeDefMD;
			if (dt == null)
				newOtherMethods = ThreadSafeListCreator.Create<MethodDef>();
			else
				dt.InitializeProperty(this, out getMethod, out setMethod, out newOtherMethods);
			otherMethods = newOtherMethods;
#if THREAD_SAFE
			} finally { theLock.ExitWriteLock(); }
#endif
		}
Exemple #16
0
 /// <summary>
 /// Constructor
 /// </summary>
 public PdbDynamicLocalsCustomDebugInfo()
 {
     locals = ThreadSafeListCreator.Create <PdbDynamicLocal>();
 }
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="initLocals">Init locals flag</param>
		/// <param name="instructions">All instructions. This instance will own the list.</param>
		/// <param name="exceptionHandlers">All exception handlers. This instance will own the list.</param>
		/// <param name="locals">All locals. This instance will own the locals in the list.</param>
		public CilBody(bool initLocals, IList<Instruction> instructions, IList<ExceptionHandler> exceptionHandlers, IList<Local> locals) {
			this.initLocals = initLocals;
			this.instructions = ThreadSafeListCreator.MakeThreadSafe(instructions);
			this.exceptionHandlers = ThreadSafeListCreator.MakeThreadSafe(exceptionHandlers);
			this.localList = new LocalList(locals);
		}
Exemple #18
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="capacity">Initial capacity of <see cref="Locals"/></param>
 public PdbDynamicLocalsCustomDebugInfo(int capacity)
 {
     locals = ThreadSafeListCreator.Create <PdbDynamicLocal>(capacity);
 }
Exemple #19
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="peImage">The PE image</param>
 /// <param name="cor20Header">The .NET header</param>
 /// <param name="mdHeader">The MD header</param>
 protected MetaData(IPEImage peImage, ImageCor20Header cor20Header, MetaDataHeader mdHeader)
 {
     try {
         this.allStreams = ThreadSafeListCreator.Create<DotNetStream>();
         this.peImage = peImage;
         this.cor20Header = cor20Header;
         this.mdHeader = mdHeader;
     }
     catch {
         if (peImage != null)
             peImage.Dispose();
         throw;
     }
 }
Exemple #20
0
 /// <summary>
 /// Constructor
 /// </summary>
 public PdbDynamicLocal()
 {
     flags = ThreadSafeListCreator.Create <byte>();
 }
Exemple #21
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="genericType">The generic type</param>
		/// <param name="genArgCount">Number of generic arguments</param>
		public GenericInstSig(ClassOrValueTypeSig genericType, uint genArgCount) {
			this.genericType = genericType;
			this.genericArgs = ThreadSafeListCreator.Create<TypeSig>((int)genArgCount);
		}
Exemple #22
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="capacity">Initial capacity of <see cref="Flags"/></param>
 public PdbDynamicLocal(int capacity)
 {
     flags = ThreadSafeListCreator.Create <byte>(capacity);
 }
Exemple #23
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="arrayType">Array type</param>
		/// <param name="rank">Array rank</param>
		/// <param name="sizes">Sizes list. <c>This instance will be the owner of this list.</c></param>
		/// <param name="lowerBounds">Lower bounds list. <c>This instance will be the owner of this list.</c></param>
		public ArraySig(TypeSig arrayType, uint rank, IEnumerable<uint> sizes, IEnumerable<int> lowerBounds)
			: base(arrayType) {
			this.rank = rank;
			this.sizes = ThreadSafeListCreator.Create<uint>(sizes);
			this.lowerBounds = ThreadSafeListCreator.Create<int>(lowerBounds);
		}
Exemple #24
0
 /// <summary>
 /// Constructor
 /// </summary>
 public PdbTupleElementNamesCustomDebugInfo()
 {
     names = ThreadSafeListCreator.Create <PdbTupleElementNames>();
 }
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="args">Generic args</param>
		public GenericInstMethodSig(IList<TypeSig> args) {
			this.callingConvention = CallingConvention.GenericInst;
			this.genericArgs = ThreadSafeListCreator.Create<TypeSig>(args);
		}
Exemple #26
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="capacity">Initial capacity of <see cref="Names"/></param>
 public PdbTupleElementNamesCustomDebugInfo(int capacity)
 {
     names = ThreadSafeListCreator.Create <PdbTupleElementNames>(capacity);
 }
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="locals">All locals (this instance now owns it)</param>
		/// <param name="dummy">Dummy</param>
		internal LocalSig(IList<TypeSig> locals, bool dummy) {
			this.callingConvention = CallingConvention.LocalSig;
			this.locals = ThreadSafeListCreator.MakeThreadSafe(locals);
		}
Exemple #28
0
 /// <summary>
 /// Constructor
 /// </summary>
 public PdbTupleElementNames()
 {
     tupleElementNames = ThreadSafeListCreator.Create <string>();
 }
Exemple #29
0
        internal void InitializeProperty(CorPropertyDef prop, out ThreadSafe.IList <MethodDef> getMethods, out ThreadSafe.IList <MethodDef> setMethods, out ThreadSafe.IList <MethodDef> otherMethods)
        {
            getMethods   = ThreadSafeListCreator.Create <MethodDef>();
            setMethods   = ThreadSafeListCreator.Create <MethodDef>();
            otherMethods = ThreadSafeListCreator.Create <MethodDef>();
            if (prop == null)
            {
                return;
            }

            var  mdi   = readerModule.MetaDataImport;
            uint token = prop.OriginalToken.Raw;

            uint getToken, setToken;

            MDAPI.GetPropertyGetterSetter(mdi, token, out getToken, out setToken);
            var otherTokens = MDAPI.GetPropertyOtherMethodTokens(mdi, token);

            var dict = CreateMethodDict();

            Add(dict, getMethods, getToken);
            Add(dict, setMethods, setToken);
            foreach (uint otherToken in otherTokens)
            {
                Add(dict, otherMethods, otherToken);
            }
        }
Exemple #30
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="capacity">Initial capacity of <see cref="TupleElementNames"/></param>
 public PdbTupleElementNames(int capacity)
 {
     tupleElementNames = ThreadSafeListCreator.Create <string>(capacity);
 }
Exemple #31
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="action">The security action</param>
 /// <param name="securityAttrs">The security attributes (now owned by this)</param>
 public DeclSecurityUser(SecurityAction action, IList<SecurityAttribute> securityAttrs)
 {
     this.action = action;
     this.securityAttrs = ThreadSafeListCreator.MakeThreadSafe(securityAttrs);
 }
Exemple #32
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="capacity">Initial capacity of <see cref="Names"/></param>
 public PortablePdbTupleElementNamesCustomDebugInfo(int capacity)
 {
     names = ThreadSafeListCreator.Create <string>(capacity);
 }
		/// <summary>
		/// Default constructor
		/// </summary>
		public CilBody() {
			this.initLocals = true;
			this.instructions = ThreadSafeListCreator.Create<Instruction>();
			this.exceptionHandlers = ThreadSafeListCreator.Create<ExceptionHandler>();
			this.localList = new LocalList();
		}
Exemple #34
0
 /// <summary>
 /// Constructor
 /// </summary>
 public PdbAsyncMethodSteppingInformationCustomDebugInfo()
 {
     asyncStepInfos = ThreadSafeListCreator.Create <PdbAsyncStepInfo>();
 }
Exemple #35
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ctor">Custom attribute constructor</param>
 /// <param name="arguments">Constructor arguments or <c>null</c> if none</param>
 /// <param name="namedArguments">Named arguments or <c>null</c> if none</param>
 /// <param name="blobReader">A reader that returns the original custom attribute blob data</param>
 public CustomAttribute(ICustomAttributeType ctor, IEnumerable<CAArgument> arguments, IEnumerable<CANamedArgument> namedArguments, IBinaryReader blobReader)
 {
     this.ctor = ctor;
     this.arguments = arguments == null ? ThreadSafeListCreator.Create<CAArgument>() : ThreadSafeListCreator.Create<CAArgument>(arguments);
     this.namedArguments = namedArguments == null ? ThreadSafeListCreator.Create<CANamedArgument>() : ThreadSafeListCreator.Create<CANamedArgument>(namedArguments);
     this.blobReader = blobReader;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="local1">Local type #1</param>
 /// <param name="local2">Local type #2</param>
 /// <param name="local3">Local type #3</param>
 public LocalSig(TypeSig local1, TypeSig local2, TypeSig local3)
 {
     this.callingConvention = CallingConvention.LocalSig;
     this.locals            = ThreadSafeListCreator.Create <TypeSig>(local1, local2, local3);
 }
Exemple #37
0
 /// <summary>
 /// Dispose method
 /// </summary>
 /// <param name="disposing"><c>true</c> if called by <see cref="Dispose()"/></param>
 protected virtual void Dispose(bool disposing)
 {
     if (!disposing)
         return;
     Dispose(peImage);
     Dispose(stringsStream);
     Dispose(usStream);
     Dispose(blobStream);
     Dispose(guidStream);
     Dispose(tablesStream);
     var as2 = allStreams;
     if (as2 != null) {
         foreach (var stream in as2.GetSafeEnumerable())
             Dispose(stream);
     }
     peImage = null;
     cor20Header = null;
     mdHeader = null;
     stringsStream = null;
     usStream = null;
     blobStream = null;
     guidStream = null;
     tablesStream = null;
     allStreams = null;
     fieldRidToTypeDefRid = null;
     methodRidToTypeDefRid = null;
     typeDefRidToNestedClasses = null;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="locals">All locals</param>
 public LocalSig(params TypeSig[] locals)
 {
     this.callingConvention = CallingConvention.LocalSig;
     this.locals            = ThreadSafeListCreator.Create <TypeSig>(locals);
 }
Exemple #39
0
 /// <summary>
 /// Initializes <see cref="otherMethods"/>, <see cref="addMethod"/>,
 /// <see cref="invokeMethod"/> and <see cref="removeMethod"/>.
 /// </summary>
 protected virtual void InitializeEventMethods_NoLock()
 {
     otherMethods = ThreadSafeListCreator.Create<MethodDef>();
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="locals">All locals (this instance now owns it)</param>
 /// <param name="dummy">Dummy</param>
 internal LocalSig(IList <TypeSig> locals, bool dummy)
 {
     this.callingConvention = CallingConvention.LocalSig;
     this.locals            = ThreadSafeListCreator.MakeThreadSafe(locals);
 }
Exemple #41
0
		/// <summary>
		/// Default constructor
		/// </summary>
		public GenericInstSig() {
			this.genericArgs = ThreadSafeListCreator.Create<TypeSig>();
		}
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="callingConvention">Calling convention (must have GenericInst set)</param>
 /// <param name="size">Number of generic args</param>
 internal GenericInstMethodSig(CallingConvention callingConvention, uint size)
 {
     this.callingConvention = callingConvention;
     this.genericArgs       = ThreadSafeListCreator.Create <TypeSig>((int)size);
 }
Exemple #43
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="genericType">The generic type</param>
		/// <param name="genArg1">Generic argument #1</param>
		/// <param name="genArg2">Generic argument #2</param>
		/// <param name="genArg3">Generic argument #3</param>
		public GenericInstSig(ClassOrValueTypeSig genericType, TypeSig genArg1, TypeSig genArg2, TypeSig genArg3) {
			this.genericType = genericType;
			this.genericArgs = ThreadSafeListCreator.Create<TypeSig>(genArg1, genArg2, genArg3);
		}
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="arg1">Generic arg #1</param>
 /// <param name="arg2">Generic arg #2</param>
 /// <param name="arg3">Generic arg #3</param>
 public GenericInstMethodSig(TypeSig arg1, TypeSig arg2, TypeSig arg3)
 {
     this.callingConvention = CallingConvention.GenericInst;
     this.genericArgs       = ThreadSafeListCreator.Create <TypeSig>(arg1, arg2, arg3);
 }
Exemple #45
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="arrayType">Array type</param>
		/// <param name="rank">Array rank</param>
		public ArraySig(TypeSig arrayType, uint rank)
			: base(arrayType) {
			this.rank = rank;
			this.sizes = ThreadSafeListCreator.Create<uint>();
			this.lowerBounds = ThreadSafeListCreator.Create<int>();
		}
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="args">Generic args</param>
 public GenericInstMethodSig(IList <TypeSig> args)
 {
     this.callingConvention = CallingConvention.GenericInst;
     this.genericArgs       = ThreadSafeListCreator.Create <TypeSig>(args);
 }
Exemple #47
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="arrayType">Array type</param>
		/// <param name="rank">Array rank</param>
		/// <param name="sizes">Sizes list. <c>This instance will be the owner of this list.</c></param>
		/// <param name="lowerBounds">Lower bounds list. <c>This instance will be the owner of this list.</c></param>
		internal ArraySig(TypeSig arrayType, uint rank, IList<uint> sizes, IList<int> lowerBounds)
			: base(arrayType) {
			this.rank = rank;
			this.sizes = ThreadSafeListCreator.MakeThreadSafe(sizes);
			this.lowerBounds = ThreadSafeListCreator.MakeThreadSafe(lowerBounds);
		}
 /// <summary>
 /// Default constructor
 /// </summary>
 public LocalSig()
 {
     this.callingConvention = CallingConvention.LocalSig;
     this.locals            = ThreadSafeListCreator.Create <TypeSig>();
 }
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="arg1">Generic arg #1</param>
		/// <param name="arg2">Generic arg #2</param>
		/// <param name="arg3">Generic arg #3</param>
		public GenericInstMethodSig(TypeSig arg1, TypeSig arg2, TypeSig arg3) {
			this.callingConvention = CallingConvention.GenericInst;
			this.genericArgs = ThreadSafeListCreator.Create<TypeSig>(arg1, arg2, arg3);
		}
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="callingConvention">Calling convention (must have LocalSig set)</param>
 /// <param name="count">Number of locals</param>
 internal LocalSig(CallingConvention callingConvention, uint count)
 {
     this.callingConvention = callingConvention;
     this.locals            = ThreadSafeListCreator.Create <TypeSig>((int)count);
 }
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="callingConvention">Calling convention (must have LocalSig set)</param>
		/// <param name="count">Number of locals</param>
		internal LocalSig(CallingConvention callingConvention, uint count) {
			this.callingConvention = callingConvention;
			this.locals = ThreadSafeListCreator.Create<TypeSig>((int)count);
		}
Exemple #52
0
 /// <summary>Reset <see cref="GetMethods"/>, <see cref="SetMethods"/>, <see cref="OtherMethods"/></summary>
 protected void ResetMethods()
 {
     otherMethods = null;
 }
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="locals">All locals</param>
		public LocalSig(IList<TypeSig> locals) {
			this.callingConvention = CallingConvention.LocalSig;
			this.locals = ThreadSafeListCreator.Create<TypeSig>(locals);
		}
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="attrType">Attribute type</param>
 /// <param name="namedArguments">Named arguments that will be owned by this instance</param>
 public SecurityAttribute(ITypeDefOrRef attrType, IList <CANamedArgument> namedArguments)
 {
     this.attrType       = attrType;
     this.namedArguments = ThreadSafeListCreator.MakeThreadSafe(namedArguments ?? new List <CANamedArgument>());
 }
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="attrType">Attribute type</param>
		/// <param name="namedArguments">Named arguments that will be owned by this instance</param>
		public SecurityAttribute(ITypeDefOrRef attrType, IList<CANamedArgument> namedArguments) {
			this.attrType = attrType;
			this.namedArguments = ThreadSafeListCreator.MakeThreadSafe(namedArguments ?? new List<CANamedArgument>());
		}
 /// <summary>
 /// Default constructor
 /// </summary>
 public VTable()
 {
     this.methods = ThreadSafeListCreator.Create <IMethod>();
 }