void ReadSecurityBlob(BlobReader reader, IAttribute[] attributes, ITypeResolveContext context, ResolveResult securityActionRR) { for (int i = 0; i < attributes.Length; i++) { string attributeTypeName = reader.ReadSerString(); ITypeReference attributeTypeRef = ReflectionHelper.ParseReflectionName(attributeTypeName); IType attributeType = attributeTypeRef.Resolve(context); reader.ReadCompressedUInt32(); // ?? // The specification seems to be incorrect here, so I'm using the logic from Cecil instead. uint numNamed = reader.ReadCompressedUInt32(); var namedArgs = new List <KeyValuePair <IMember, ResolveResult> >((int)numNamed); for (uint j = 0; j < numNamed; j++) { var namedArg = reader.ReadNamedArg(attributeType); if (namedArg.Key != null) { namedArgs.Add(namedArg); } } attributes[i] = new DefaultAttribute( attributeType, positionalArguments: new ResolveResult[] { securityActionRR }, namedArguments: namedArgs); } }
private void DecodeBlob(List <ResolveResult> positionalArguments, List <KeyValuePair <IMember, ResolveResult> > namedArguments) { if (blob == null) { return; } BlobReader reader = new BlobReader(blob, context.CurrentAssembly); if (reader.ReadUInt16() != 0x0001) { Debug.WriteLine("Unknown blob prolog"); return; } foreach (var ctorParameter in ctorParameterTypes.Resolve(context)) { ResolveResult arg; bool isError; try { arg = reader.ReadFixedArg(ctorParameter); positionalArguments.Add(arg); isError = arg.IsError; } catch (Exception ex) { Debug.WriteLine("Crash during blob decoding: " + ex); isError = true; } if (isError) { // After a decoding error, we must stop decoding the blob because // we might have read too few bytes due to the error. // Just fill up the remaining arguments with ErrorResolveResult: while (positionalArguments.Count < ctorParameterTypes.Count) { positionalArguments.Add(ErrorResolveResult.UnknownError); } return; } } try { ushort numNamed = reader.ReadUInt16(); for (int i = 0; i < numNamed; i++) { var namedArg = reader.ReadNamedArg(attributeType); if (namedArg.Key != null) { namedArguments.Add(namedArg); } } } catch (Exception ex) { Debug.WriteLine("Crash during blob decoding: " + ex); } }
void DecodeBlob(List<ResolveResult> positionalArguments, List<KeyValuePair<IMember, ResolveResult>> namedArguments) { if (blob == null) return; BlobReader reader = new BlobReader(blob, context.CurrentAssembly); if (reader.ReadUInt16() != 0x0001) { //Debug.WriteLine("Unknown blob prolog"); return; } foreach (var ctorParameter in ctorParameterTypes.Resolve(context)) { ResolveResult arg; bool isError; try { arg = reader.ReadFixedArg (ctorParameter); positionalArguments.Add(arg); isError = arg.IsError; } catch (Exception) { //Debug.WriteLine("Crash during blob decoding: " + ex); isError = true; } if (isError) { // After a decoding error, we must stop decoding the blob because // we might have read too few bytes due to the error. // Just fill up the remaining arguments with ErrorResolveResult: while (positionalArguments.Count < ctorParameterTypes.Count) positionalArguments.Add(ErrorResolveResult.UnknownError); return; } } try { ushort numNamed = reader.ReadUInt16(); for (int i = 0; i < numNamed; i++) { var namedArg = reader.ReadNamedArg(attributeType); if (namedArg.Key != null) namedArguments.Add(namedArg); } } catch (Exception) { //Debug.WriteLine("Crash during blob decoding: " + ex); } }
void ReadSecurityBlob(BlobReader reader, IAttribute[] attributes, ITypeResolveContext context, ResolveResult securityActionRR) { for (int i = 0; i < attributes.Length; i++) { string attributeTypeName = reader.ReadSerString(); ITypeReference attributeTypeRef = ReflectionHelper.ParseReflectionName(attributeTypeName); IType attributeType = attributeTypeRef.Resolve(context); reader.ReadCompressedUInt32(); // ?? // The specification seems to be incorrect here, so I'm using the logic from Cecil instead. uint numNamed = reader.ReadCompressedUInt32(); var namedArgs = new List<KeyValuePair<IMember, ResolveResult>>((int)numNamed); for (uint j = 0; j < numNamed; j++) { var namedArg = reader.ReadNamedArg(attributeType); if (namedArg.Key != null) namedArgs.Add(namedArg); } attributes[i] = new DefaultAttribute( attributeType, positionalArguments: new ResolveResult[] { securityActionRR }, namedArguments: namedArgs); } }
void DecodeBlob(ICollection<ResolveResult> newPositionalArguments, ICollection<KeyValuePair<IMember, ResolveResult>> newNamedArguments) { if (blob == null) return; var reader = new BlobReader(blob, context.CurrentAssembly); if (reader.ReadUInt16() != 0x0001) { Debug.WriteLine("Unknown blob prolog"); return; } foreach (var ctorParameter in ctorParameterTypes.Resolve(context)) { ResolveResult arg = reader.ReadFixedArg(ctorParameter); newPositionalArguments.Add(arg); if (arg.IsError) { // After a decoding error, we must stop decoding the blob because // we might have read too few bytes due to the error. // Just fill up the remaining arguments with ErrorResolveResult: while (newPositionalArguments.Count < ctorParameterTypes.Count) newPositionalArguments.Add(ErrorResolveResult.UnknownError); return; } } ushort numNamed = reader.ReadUInt16(); for (int i = 0; i < numNamed; i++) { var namedArg = reader.ReadNamedArg(attributeType); if (namedArg.Key != null) newNamedArguments.Add(namedArg); } }