private void AddOneArgTypeHelper(Type clsArgument, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) { // This function will not increase the argument count. It only fills in bytes // in the signature based on clsArgument. This helper is called for return type. ASSERT.PRECONDITION(clsArgument != null); ASSERT.PRECONDITION((optionalCustomModifiers == null && requiredCustomModifiers == null) || !clsArgument.ContainsGenericParameters); ASSERT.PRECONDITION(requiredCustomModifiers == null || Array.IndexOf(requiredCustomModifiers, null) == -1); ASSERT.PRECONDITION(optionalCustomModifiers == null || Array.IndexOf(optionalCustomModifiers, null) == -1); if (optionalCustomModifiers != null) { for (int i = 0; i < optionalCustomModifiers.Length; i++) { AddElementType(ELEMENT_TYPE_CMOD_OPT); ASSERT.CONSISTENCY_CHECK(!MetadataToken.IsNullToken(optionalCustomModifiers[i].MetadataTokenInternal)); AddToken(m_module.GetTypeToken(optionalCustomModifiers[i]).Token); } } if (requiredCustomModifiers != null) { for (int i = 0; i < requiredCustomModifiers.Length; i++) { AddElementType(ELEMENT_TYPE_CMOD_REQD); ASSERT.CONSISTENCY_CHECK(!MetadataToken.IsNullToken(requiredCustomModifiers[i].MetadataTokenInternal)); AddToken(m_module.GetTypeToken(requiredCustomModifiers[i]).Token); } } AddOneArgTypeHelper(clsArgument); }
private unsafe void PopulateEvents(RuntimeType.RuntimeTypeCache.Filter filter, RuntimeTypeHandle declaringTypeHandle, Hashtable csEventInfos, List <RuntimeEventInfo> list) { int token = declaringTypeHandle.GetToken(); if (!MetadataToken.IsNullToken(token)) { MetadataImport metadataImport = declaringTypeHandle.GetModuleHandle().GetMetadataImport(); int count = metadataImport.EnumEventsCount(token); int * result = stackalloc int[count]; //result.AllocatedUntil = count metadataImport.EnumEvents(token, result, count); this.PopulateEvents(filter, declaringTypeHandle, metadataImport, result, count, csEventInfos, list); //Ensures that result.AllocatedUntil >= count! } }
private void AddOneArgTypeHelper(Type clsArgument, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) { // This function will not increase the argument count. It only fills in bytes // in the signature based on clsArgument. This helper is called for return type. Contract.Requires(clsArgument != null); Contract.Requires((optionalCustomModifiers == null && requiredCustomModifiers == null) || !clsArgument.ContainsGenericParameters); if (optionalCustomModifiers != null) { for (int i = 0; i < optionalCustomModifiers.Length; i++) { Type t = optionalCustomModifiers[i]; if (t == null) { throw new ArgumentNullException(nameof(optionalCustomModifiers)); } if (t.HasElementType) { throw new ArgumentException(Environment.GetResourceString("Argument_ArraysInvalid"), nameof(optionalCustomModifiers)); } if (t.ContainsGenericParameters) { throw new ArgumentException(Environment.GetResourceString("Argument_GenericsInvalid"), nameof(optionalCustomModifiers)); } AddElementType(CorElementType.CModOpt); int token = m_module.GetTypeToken(t).Token; Debug.Assert(!MetadataToken.IsNullToken(token)); AddToken(token); } } if (requiredCustomModifiers != null) { for (int i = 0; i < requiredCustomModifiers.Length; i++) { Type t = requiredCustomModifiers[i]; if (t == null) { throw new ArgumentNullException(nameof(requiredCustomModifiers)); } if (t.HasElementType) { throw new ArgumentException(Environment.GetResourceString("Argument_ArraysInvalid"), nameof(requiredCustomModifiers)); } if (t.ContainsGenericParameters) { throw new ArgumentException(Environment.GetResourceString("Argument_GenericsInvalid"), nameof(requiredCustomModifiers)); } AddElementType(CorElementType.CModReqd); int token = m_module.GetTypeToken(t).Token; Debug.Assert(!MetadataToken.IsNullToken(token)); AddToken(token); } } AddOneArgTypeHelper(clsArgument); }
private void AddOneArgTypeHelper(Type clsArgument, Type[]?requiredCustomModifiers, Type[]?optionalCustomModifiers) { // This function will not increase the argument count. It only fills in bytes // in the signature based on clsArgument. This helper is called for return type. Debug.Assert(clsArgument != null); if (optionalCustomModifiers != null) { for (int i = 0; i < optionalCustomModifiers.Length; i++) { Type t = optionalCustomModifiers[i]; if (t == null) { throw new ArgumentNullException(nameof(optionalCustomModifiers)); } if (t.HasElementType) { throw new ArgumentException(SR.Argument_ArraysInvalid, nameof(optionalCustomModifiers)); } if (t.ContainsGenericParameters) { throw new ArgumentException(SR.Argument_GenericsInvalid, nameof(optionalCustomModifiers)); } AddElementType(CorElementType.ELEMENT_TYPE_CMOD_OPT); int token = m_module !.GetTypeToken(t).Token; Debug.Assert(!MetadataToken.IsNullToken(token)); AddToken(token); } } if (requiredCustomModifiers != null) { for (int i = 0; i < requiredCustomModifiers.Length; i++) { Type t = requiredCustomModifiers[i]; if (t == null) { throw new ArgumentNullException(nameof(requiredCustomModifiers)); } if (t.HasElementType) { throw new ArgumentException(SR.Argument_ArraysInvalid, nameof(requiredCustomModifiers)); } if (t.ContainsGenericParameters) { throw new ArgumentException(SR.Argument_GenericsInvalid, nameof(requiredCustomModifiers)); } AddElementType(CorElementType.ELEMENT_TYPE_CMOD_REQD); int token = m_module !.GetTypeToken(t).Token; Debug.Assert(!MetadataToken.IsNullToken(token)); AddToken(token); } } AddOneArgTypeHelper(clsArgument); }
public void AddArgument(Type argument, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) { if (m_sigDone) { throw new ArgumentException(Environment.GetResourceString("Argument_SigIsFinalized")); } if (argument == null) { throw new ArgumentNullException("argument"); } if (requiredCustomModifiers != null) { for (int i = 0; i < requiredCustomModifiers.Length; i++) { Type t = requiredCustomModifiers[i]; if (t == null) { throw new ArgumentNullException("requiredCustomModifiers"); } if (t.HasElementType) { throw new ArgumentException(Environment.GetResourceString("Argument_ArraysInvalid"), "requiredCustomModifiers"); } if (t.ContainsGenericParameters) { throw new ArgumentException(Environment.GetResourceString("Argument_GenericsInvalid"), "requiredCustomModifiers"); } ASSERT.CONSISTENCY_CHECK(!MetadataToken.IsNullToken(t.MetadataTokenInternal)); } } if (optionalCustomModifiers != null) { for (int i = 0; i < optionalCustomModifiers.Length; i++) { Type t = optionalCustomModifiers[i]; if (t == null) { throw new ArgumentNullException("optionalCustomModifiers"); } if (t.HasElementType) { throw new ArgumentException(Environment.GetResourceString("Argument_ArraysInvalid"), "optionalCustomModifiers"); } if (t.ContainsGenericParameters) { throw new ArgumentException(Environment.GetResourceString("Argument_GenericsInvalid"), "optionalCustomModifiers"); } ASSERT.CONSISTENCY_CHECK(!MetadataToken.IsNullToken(t.MetadataTokenInternal)); } } IncrementArgCounts(); // Add an argument to the signature. Takes a Type and determines whether it // is one of the primitive types of which we have special knowledge or a more // general class. In the former case, we only add the appropriate short cut encoding, // otherwise we will calculate proper description for the type. AddOneArgTypeHelper(argument, requiredCustomModifiers, optionalCustomModifiers); }
internal void AddDynamicArgument(DynamicScope dynamicScope, Type clsArgument, Type[]?requiredCustomModifiers, Type[]?optionalCustomModifiers) { IncrementArgCounts(); Debug.Assert(clsArgument != null); if (optionalCustomModifiers != null) { for (int i = 0; i < optionalCustomModifiers.Length; i++) { Type t = optionalCustomModifiers[i]; if (t is not RuntimeType rtType) { throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(optionalCustomModifiers)); } if (t.HasElementType) { throw new ArgumentException(SR.Argument_ArraysInvalid, nameof(optionalCustomModifiers)); } if (t.ContainsGenericParameters) { throw new ArgumentException(SR.Argument_GenericsInvalid, nameof(optionalCustomModifiers)); } AddElementType(CorElementType.ELEMENT_TYPE_CMOD_OPT); int token = dynamicScope.GetTokenFor(rtType.TypeHandle); Debug.Assert(!MetadataToken.IsNullToken(token)); AddToken(token); } } if (requiredCustomModifiers != null) { for (int i = 0; i < requiredCustomModifiers.Length; i++) { Type t = requiredCustomModifiers[i]; if (t is not RuntimeType rtType) { throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(requiredCustomModifiers)); } if (t.HasElementType) { throw new ArgumentException(SR.Argument_ArraysInvalid, nameof(requiredCustomModifiers)); } if (t.ContainsGenericParameters) { throw new ArgumentException(SR.Argument_GenericsInvalid, nameof(requiredCustomModifiers)); } AddElementType(CorElementType.ELEMENT_TYPE_CMOD_REQD); int token = dynamicScope.GetTokenFor(rtType.TypeHandle); Debug.Assert(!MetadataToken.IsNullToken(token)); AddToken(token); } } AddOneArgTypeHelper(clsArgument); }