37 internal struct Record : IRecord
40 internal short Action;
42 internal BlobHandle PermissionSet;
44 readonly
int IRecord.FilterKey => Parent;
46 public readonly
int CompareTo(Record other) => Comparer<int>.Default.Compare(Parent, other.Parent);
50 internal const int Index = 0x0E;
54 for (
int i = 0; i < records.Length; i++)
56 records[i].Action = mr.ReadInt16();
57 records[i].Parent = mr.ReadHasDeclSecurity();
58 records[i].PermissionSet = MetadataTokens.BlobHandle(mr.ReadBlobIndex());
62 internal override void Write(ModuleBuilder module)
64 for (
int i = 0; i < rowCount; i++)
66 var h = module.Metadata.AddDeclarativeSecurityAttribute(
67 MetadataTokens.EntityHandle(records[i].Parent),
68 (
System.Reflection.DeclarativeSecurityAction)records[i].Action,
69 records[i].PermissionSet);
71 Debug.Assert(h == MetadataTokens.DeclarativeSecurityAttributeHandle(i + 1));
75 internal void Fixup(ModuleBuilder moduleBuilder)
77 for (
int i = 0; i < rowCount; i++)
79 var token = records[i].Parent;
80 moduleBuilder.FixupPseudoToken(
ref token);
83 token = (token >> 24)
switch
85 TypeDefTable.Index => (token & 0xFFFFFF) << 2 | 0,
87 AssemblyTable.Index => (token & 0xFFFFFF) << 2 | 2,
88 _ =>
throw new InvalidOperationException(),
91 records[i].Parent = token;