private void SerializeLocalConstantTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (var row in _localConstantTable) { writer.WriteReference((uint)_debugHeapsOpt.ResolveStringIndex(row.Name), metadataSizes.StringIndexSize); writer.WriteReference((uint)_debugHeapsOpt.ResolveBlobIndex(row.Signature), metadataSizes.BlobIndexSize); } }
private void SerializeImportScopeTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (var row in _importScopeTable) { writer.WriteReference(row.Parent, metadataSizes.ImportScopeIndexSize); writer.WriteReference((uint)_debugHeapsOpt.ResolveBlobIndex(row.Imports), metadataSizes.BlobIndexSize); } }
private void SerializeStateMachineMethodTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (var row in _stateMachineMethodTable) { writer.WriteReference(row.MoveNextMethod, metadataSizes.MethodDefIndexSize); writer.WriteReference(row.KickoffMethod, metadataSizes.MethodDefIndexSize); } }
private void SerializeMethodDebugInformationTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (var row in _methodDebugInformationTable) { writer.WriteReference(row.Document, metadataSizes.DocumentIndexSize); writer.WriteReference((uint)_debugHeapsOpt.ResolveBlobIndex(row.SequencePoints), metadataSizes.BlobIndexSize); } }
private void SerializeDocumentTable(BlobBuilder writer, Sizes sizes) { foreach (var row in _documentTable) { writer.WriteReference(MetadataTokens.GetHeapOffset(row.Name), isSmall: (sizes.BlobIndexSize == 2)); writer.WriteReference(MetadataTokens.GetHeapOffset(row.HashAlgorithm), isSmall: (sizes.GuidIndexSize == 2)); writer.WriteReference(MetadataTokens.GetHeapOffset(row.Hash), isSmall: (sizes.BlobIndexSize == 2)); } }
private void SerializeDocumentTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (var row in _documentTable) { writer.WriteReference((uint)_debugHeapsOpt.ResolveBlobIndex(row.Name), metadataSizes.BlobIndexSize); writer.WriteReference(row.HashAlgorithm, metadataSizes.GuidIndexSize); writer.WriteReference((uint)_debugHeapsOpt.ResolveBlobIndex(row.Hash), metadataSizes.BlobIndexSize); writer.WriteReference(row.Language, metadataSizes.GuidIndexSize); } }
private void SerializeCustomDebugInformationTable(BlobBuilder writer, MetadataSizes metadataSizes) { // sort by Parent, Kind _customDebugInformationTable.Sort(CustomDebugInformationRowComparer.Instance); foreach (var row in _customDebugInformationTable) { writer.WriteReference(row.Parent, metadataSizes.HasCustomDebugInformationSize); writer.WriteReference(row.Kind, metadataSizes.GuidIndexSize); writer.WriteReference((uint)_debugHeapsOpt.ResolveBlobIndex(row.Value), metadataSizes.BlobIndexSize); } }
private void SerializeLocalScopeTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (var row in _localScopeTable) { writer.WriteReference(row.Method, metadataSizes.MethodDefIndexSize); writer.WriteReference(row.ImportScope, metadataSizes.ImportScopeIndexSize); writer.WriteReference(row.VariableList, metadataSizes.LocalVariableIndexSize); writer.WriteReference(row.ConstantList, metadataSizes.LocalConstantIndexSize); writer.WriteUInt32(row.StartOffset); writer.WriteUInt32(row.Length); } }
private void SerializeMethodTable(BlobBuilder writer, Sizes sizes) { foreach (var row in _methodTable) { writer.WriteReference(MetadataTokens.GetHeapOffset(row.Spans), isSmall: (sizes.BlobIndexSize == 2)); } }
private void SerializeLocalVariableTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (var row in _localVariableTable) { writer.WriteUInt16(row.Attributes); writer.WriteUInt16(row.Index); writer.WriteReference((uint)_debugHeapsOpt.ResolveStringIndex(row.Name), metadataSizes.StringIndexSize); } }
private void SerializeStandAloneSigTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (StandaloneSigRow row in _standAloneSigTable) { writer.WriteReference((uint)_heaps.ResolveBlobIndex(row.Signature), metadataSizes.BlobIndexSize); } }
private void SerializeCustomDebugInformationTable(BlobBuilder writer, MetadataSizes metadataSizes) { // Note: we can sort the table at this point since no other table can reference its rows via RowId or CodedIndex (which would need updating otherwise). // OrderBy performs a stable sort, so multiple attributes with the same parent and kind will be sorted in the order they were added to the table. foreach (CustomDebugInformationRow row in _customDebugInformationTable.OrderBy((x, y) => { int result = (int)x.Parent - (int)y.Parent; return (result != 0) ? result : (int)x.Kind - (int)y.Kind; })) { writer.WriteReference(row.Parent, metadataSizes.HasCustomDebugInformationSize); writer.WriteReference(row.Kind, metadataSizes.GuidIndexSize); writer.WriteReference((uint)_debugHeapsOpt.ResolveBlobIndex(row.Value), metadataSizes.BlobIndexSize); } }
private void SerializeImportScopeTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (var row in _importScopeTable) { writer.WriteReference(row.Parent, metadataSizes.ImportScopeIndexSize); writer.WriteReference((uint)_debugHeapsOpt.ResolveBlobIndex(row.Imports), metadataSizes.BlobIndexSize); } }
private void SerializeLocalVariableTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (var row in _localVariableTable) { writer.WriteUInt16(row.Attributes); writer.WriteUInt16(row.Index); writer.WriteReference((uint)_debugHeapsOpt.ResolveStringIndex(row.Name), metadataSizes.StringIndexSize); } }
private void SerializeMethodDebugInformationTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (var row in _methodDebugInformationTable) { writer.WriteReference(row.Document, metadataSizes.DocumentIndexSize); writer.WriteReference((uint)_debugHeapsOpt.ResolveBlobIndex(row.SequencePoints), metadataSizes.BlobIndexSize); } }
private void SerializeFieldRvaTable(BlobBuilder writer, MetadataSizes metadataSizes, int mappedFieldDataStreamRva) { #if DEBUG for (int i = 1; i < _fieldRvaTable.Count; i++) { Debug.Assert(_fieldRvaTable[i - 1].Field < _fieldRvaTable[i].Field); } #endif foreach (FieldRvaRow fieldRva in _fieldRvaTable) { writer.WriteUInt32((uint)mappedFieldDataStreamRva + fieldRva.Offset); writer.WriteReference(fieldRva.Field, metadataSizes.FieldDefIndexSize); } }
private void SerializeImplMapTable(BlobBuilder writer, MetadataSizes metadataSizes) { #if DEBUG for (int i = 1; i < _implMapTable.Count; i++) { Debug.Assert(_implMapTable[i - 1].MemberForwarded < _implMapTable[i].MemberForwarded); } #endif foreach (ImplMapRow implMap in _implMapTable) { writer.WriteUInt16(implMap.MappingFlags); writer.WriteReference(implMap.MemberForwarded, metadataSizes.MemberForwardedCodedIndexSize); writer.WriteReference((uint)_heaps.ResolveStringIndex(implMap.ImportName), metadataSizes.StringIndexSize); writer.WriteReference(implMap.ImportScope, metadataSizes.ModuleRefIndexSize); } }
private void SerializeTypeSpecTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (TypeSpecRow typeSpec in _typeSpecTable) { writer.WriteReference((uint)_heaps.ResolveBlobIndex(typeSpec.Signature), metadataSizes.BlobIndexSize); } }
private void SerializeModuleRefTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (ModuleRefRow moduleRef in _moduleRefTable) { writer.WriteReference((uint)_heaps.ResolveStringIndex(moduleRef.Name), metadataSizes.StringIndexSize); } }
private void SerializeMethodImplTable(BlobBuilder writer, MetadataSizes metadataSizes) { #if DEBUG for (int i = 1; i < _methodImplTable.Count; i++) { Debug.Assert(_methodImplTable[i - 1].Class <= _methodImplTable[i].Class); } #endif foreach (MethodImplRow methodImpl in _methodImplTable) { writer.WriteReference(methodImpl.Class, metadataSizes.TypeDefIndexSize); writer.WriteReference(methodImpl.MethodBody, metadataSizes.MethodDefOrRefCodedIndexSize); writer.WriteReference(methodImpl.MethodDecl, metadataSizes.MethodDefOrRefCodedIndexSize); } }
private void SerializeMethodSemanticsTable(BlobBuilder writer, MetadataSizes metadataSizes) { // Note: we can sort the table at this point since no other table can reference its rows via RowId or CodedIndex (which would need updating otherwise). // OrderBy performs a stable sort, so multiple attributes with the same parent will be sorted in the order they were added to the table. var ordered = _methodSemanticsTableNeedsSorting ? _methodSemanticsTable.OrderBy((x, y) => (int)x.Association - (int)y.Association) : _methodSemanticsTable; foreach (MethodSemanticsRow methodSemantic in ordered) { writer.WriteUInt16(methodSemantic.Semantic); writer.WriteReference(methodSemantic.Method, metadataSizes.MethodDefIndexSize); writer.WriteReference(methodSemantic.Association, metadataSizes.HasSemanticsCodedIndexSize); } }
private void SerializeClassLayoutTable(BlobBuilder writer, MetadataSizes metadataSizes) { #if DEBUG for (int i = 1; i < _classLayoutTable.Count; i++) { Debug.Assert(_classLayoutTable[i - 1].Parent < _classLayoutTable[i].Parent); } #endif foreach (ClassLayoutRow classLayout in _classLayoutTable) { writer.WriteUInt16(classLayout.PackingSize); writer.WriteUInt32(classLayout.ClassSize); writer.WriteReference(classLayout.Parent, metadataSizes.TypeDefIndexSize); } }
private void SerializePropertyTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (PropertyRow property in _propertyTable) { writer.WriteUInt16(property.PropFlags); writer.WriteReference((uint)_heaps.ResolveStringIndex(property.Name), metadataSizes.StringIndexSize); writer.WriteReference((uint)_heaps.ResolveBlobIndex(property.Type), metadataSizes.BlobIndexSize); } }
private void SerializeAssemblyRefTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (AssemblyRefTableRow row in _assemblyRefTable) { writer.WriteUInt16((ushort)row.Version.Major); writer.WriteUInt16((ushort)row.Version.Minor); writer.WriteUInt16((ushort)row.Version.Build); writer.WriteUInt16((ushort)row.Version.Revision); writer.WriteUInt32(row.Flags); writer.WriteReference((uint)_heaps.ResolveBlobIndex(row.PublicKeyToken), metadataSizes.BlobIndexSize); writer.WriteReference((uint)_heaps.ResolveStringIndex(row.Name), metadataSizes.StringIndexSize); writer.WriteReference((uint)_heaps.ResolveStringIndex(row.Culture), metadataSizes.StringIndexSize); writer.WriteReference((uint)_heaps.ResolveBlobIndex(row.HashValue), metadataSizes.BlobIndexSize); } }
private void SerializeLocalScopeTable(BlobBuilder writer, MetadataSizes metadataSizes) { #if DEBUG // Spec: The table is required to be sorted first by Method in ascending order, then by StartOffset in ascending order, then by Length in descending order. for (int i = 1; i < _localScopeTable.Count; i++) { Debug.Assert(_localScopeTable[i - 1].Method <= _localScopeTable[i].Method); if (_localScopeTable[i - 1].Method == _localScopeTable[i].Method) { Debug.Assert(_localScopeTable[i - 1].StartOffset <= _localScopeTable[i].StartOffset); if (_localScopeTable[i - 1].StartOffset == _localScopeTable[i].StartOffset) { Debug.Assert(_localScopeTable[i - 1].Length >= _localScopeTable[i].Length); } } } #endif foreach (var row in _localScopeTable) { writer.WriteReference(row.Method, metadataSizes.MethodDefIndexSize); writer.WriteReference(row.ImportScope, metadataSizes.ImportScopeIndexSize); writer.WriteReference(row.VariableList, metadataSizes.LocalVariableIndexSize); writer.WriteReference(row.ConstantList, metadataSizes.LocalConstantIndexSize); writer.WriteUInt32(row.StartOffset); writer.WriteUInt32(row.Length); } }
private void SerializeFileTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (FileTableRow fileReference in _fileTable) { writer.WriteUInt32(fileReference.Flags); writer.WriteReference((uint)_heaps.ResolveStringIndex(fileReference.FileName), metadataSizes.StringIndexSize); writer.WriteReference((uint)_heaps.ResolveBlobIndex(fileReference.HashValue), metadataSizes.BlobIndexSize); } }
private void SerializeLocalConstantTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (var row in _localConstantTable) { writer.WriteReference((uint)_debugHeapsOpt.ResolveStringIndex(row.Name), metadataSizes.StringIndexSize); writer.WriteReference((uint)_debugHeapsOpt.ResolveBlobIndex(row.Signature), metadataSizes.BlobIndexSize); } }
private void SerializeExportedTypeTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (ExportedTypeRow exportedType in _exportedTypeTable) { writer.WriteUInt32((uint)exportedType.Flags); writer.WriteUInt32(exportedType.TypeDefId); writer.WriteReference((uint)_heaps.ResolveStringIndex(exportedType.TypeName), metadataSizes.StringIndexSize); writer.WriteReference((uint)_heaps.ResolveStringIndex(exportedType.TypeNamespace), metadataSizes.StringIndexSize); writer.WriteReference(exportedType.Implementation, metadataSizes.ImplementationCodedIndexSize); } }
private void SerializeStateMachineMethodTable(BlobBuilder writer, MetadataSizes metadataSizes) { #if DEBUG for (int i = 1; i < _stateMachineMethodTable.Count; i++) { Debug.Assert(_stateMachineMethodTable[i - 1].MoveNextMethod < _stateMachineMethodTable[i].MoveNextMethod); } #endif foreach (var row in _stateMachineMethodTable) { writer.WriteReference(row.MoveNextMethod, metadataSizes.MethodDefIndexSize); writer.WriteReference(row.KickoffMethod, metadataSizes.MethodDefIndexSize); } }
private void SerializeManifestResourceTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (ManifestResourceRow manifestResource in _manifestResourceTable) { writer.WriteUInt32(manifestResource.Offset); writer.WriteUInt32(manifestResource.Flags); writer.WriteReference((uint)_heaps.ResolveStringIndex(manifestResource.Name), metadataSizes.StringIndexSize); writer.WriteReference(manifestResource.Implementation, metadataSizes.ImplementationCodedIndexSize); } }
private void SerializeEventTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (EventRow eventRow in _eventTable) { writer.WriteUInt16(eventRow.EventFlags); writer.WriteReference((uint)_heaps.ResolveStringIndex(eventRow.Name), metadataSizes.StringIndexSize); writer.WriteReference(eventRow.EventType, metadataSizes.TypeDefOrRefCodedIndexSize); } }
private void SerializeNestedClassTable(BlobBuilder writer, MetadataSizes metadataSizes) { #if DEBUG for (int i = 1; i < _nestedClassTable.Count; i++) { Debug.Assert(_nestedClassTable[i - 1].NestedClass <= _nestedClassTable[i].NestedClass); } #endif foreach (NestedClassRow nestedClass in _nestedClassTable) { writer.WriteReference(nestedClass.NestedClass, metadataSizes.TypeDefIndexSize); writer.WriteReference(nestedClass.EnclosingClass, metadataSizes.TypeDefIndexSize); } }
private void SerializeEventMapTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (EventMapRow eventMap in _eventMapTable) { writer.WriteReference(eventMap.Parent, metadataSizes.TypeDefIndexSize); writer.WriteReference(eventMap.EventList, metadataSizes.EventDefIndexSize); } }
private void SerializeDeclSecurityTable(BlobBuilder writer, MetadataSizes metadataSizes) { // Note: we can sort the table at this point since no other table can reference its rows via RowId or CodedIndex (which would need updating otherwise). // OrderBy performs a stable sort, so multiple attributes with the same parent will be sorted in the order they were added to the table. var ordered = _declSecurityTableNeedsSorting ? _declSecurityTable.OrderBy((x, y) => (int)x.Parent - (int)y.Parent) : _declSecurityTable; foreach (DeclSecurityRow declSecurity in ordered) { writer.WriteUInt16(declSecurity.Action); writer.WriteReference(declSecurity.Parent, metadataSizes.DeclSecurityCodedIndexSize); writer.WriteReference((uint)_heaps.ResolveBlobIndex(declSecurity.PermissionSet), metadataSizes.BlobIndexSize); } }
private void SerializeGenericParamConstraintTable(BlobBuilder writer, MetadataSizes metadataSizes) { #if DEBUG for (int i = 1; i < _genericParamConstraintTable.Count; i++) { Debug.Assert(_genericParamConstraintTable[i - 1].Owner <= _genericParamConstraintTable[i].Owner); } #endif foreach (GenericParamConstraintRow genericParamConstraint in _genericParamConstraintTable) { writer.WriteReference(genericParamConstraint.Owner, metadataSizes.GenericParamIndexSize); writer.WriteReference(genericParamConstraint.Constraint, metadataSizes.TypeDefOrRefCodedIndexSize); } }
private void SerializeMethodSpecTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (MethodSpecRow methodSpec in _methodSpecTable) { writer.WriteReference(methodSpec.Method, metadataSizes.MethodDefOrRefCodedIndexSize); writer.WriteReference((uint)_heaps.ResolveBlobIndex(methodSpec.Instantiation), metadataSizes.BlobIndexSize); } }
private void SerializeFieldLayoutTable(BlobBuilder writer, MetadataSizes metadataSizes) { #if DEBUG for (int i = 1; i < _fieldLayoutTable.Count; i++) { Debug.Assert(_fieldLayoutTable[i - 1].Field < _fieldLayoutTable[i].Field); } #endif foreach (FieldLayoutRow fieldLayout in _fieldLayoutTable) { writer.WriteUInt32(fieldLayout.Offset); writer.WriteReference(fieldLayout.Field, metadataSizes.FieldDefIndexSize); } }
private void SerializeDocumentTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (var row in _documentTable) { writer.WriteReference((uint)_debugHeapsOpt.ResolveBlobIndex(row.Name), metadataSizes.BlobIndexSize); writer.WriteReference(row.HashAlgorithm, metadataSizes.GuidIndexSize); writer.WriteReference((uint)_debugHeapsOpt.ResolveBlobIndex(row.Hash), metadataSizes.BlobIndexSize); writer.WriteReference(row.Language, metadataSizes.GuidIndexSize); } }
private void SerializeGenericParamTable(BlobBuilder writer, MetadataSizes metadataSizes) { #if DEBUG for (int i = 1; i < _genericParamTable.Count; i++) { Debug.Assert( _genericParamTable[i - 1].Owner < _genericParamTable[i].Owner || _genericParamTable[i - 1].Owner == _genericParamTable[i].Owner && _genericParamTable[i - 1].Number < _genericParamTable[i].Number); } #endif foreach (GenericParamRow genericParam in _genericParamTable) { writer.WriteUInt16(genericParam.Number); writer.WriteUInt16(genericParam.Flags); writer.WriteReference(genericParam.Owner, metadataSizes.TypeOrMethodDefCodedIndexSize); writer.WriteReference((uint)_heaps.ResolveStringIndex(genericParam.Name), metadataSizes.StringIndexSize); } }
private void SerializePropertyMapTable(BlobBuilder writer, MetadataSizes metadataSizes) { foreach (PropertyMapRow propertyMap in _propertyMapTable) { writer.WriteReference(propertyMap.Parent, metadataSizes.TypeDefIndexSize); writer.WriteReference(propertyMap.PropertyList, metadataSizes.PropertyDefIndexSize); } }