internal void SerializeCustomDebugInformation(ArrayBuilder <Cci.MemoryStream> customDebugInfo) { if (this.LocalSlots.IsDefaultOrEmpty) { return; } Cci.MemoryStream customMetadata = new Cci.MemoryStream(); Cci.BinaryWriter cmw = new Cci.BinaryWriter(customMetadata); cmw.WriteByte(4); // version cmw.WriteByte(6); // kind: EditAndContinueLocalSlotMap cmw.Align(4); // length (will be patched) uint lengthPosition = cmw.BaseStream.Position; cmw.WriteUint(0); SerializeLocalSlots(cmw); uint length = customMetadata.Position; // align with values that the reader skips while (length % 4 != 0) { cmw.WriteByte(AlignmentValue); length++; } cmw.BaseStream.Position = lengthPosition; cmw.WriteUint(length); cmw.BaseStream.Position = length; customDebugInfo.Add(customMetadata); }
public void WriteData(Cci.BinaryWriter resourceWriter) { if (fileReference == null) { try { using (Stream stream = streamProvider()) { if (stream == null) { throw new InvalidOperationException(CodeAnalysisResources.ResourceStreamProviderShouldReturnNonNullStream); } var count = (int)(stream.Length - stream.Position); resourceWriter.WriteInt(count); var to = resourceWriter.BaseStream; var position = (int)to.Position; to.Position = (uint)(position + count); resourceWriter.Align(8); var buffer = to.Buffer; stream.Read(buffer, position, count); } } catch (Exception e) { throw new ResourceException(this.name, e); } } }
private Cci.MemoryStream SerializeRecord(byte kind, Action<Cci.BinaryWriter> data) { Cci.MemoryStream customMetadata = new Cci.MemoryStream(); Cci.BinaryWriter cmw = new Cci.BinaryWriter(customMetadata); cmw.WriteByte(Cci.CustomDebugInfoConstants.CdiVersion); cmw.WriteByte(kind); cmw.Align(4); // length (will be patched) uint lengthPosition = cmw.BaseStream.Position; cmw.WriteUint(0); data(cmw); uint length = customMetadata.Position; cmw.BaseStream.Position = lengthPosition; cmw.WriteUint(length); cmw.BaseStream.Position = length; return customMetadata; }
private Cci.MemoryStream SerializeRecord(byte kind, Action <Cci.BinaryWriter> data) { Cci.MemoryStream customMetadata = new Cci.MemoryStream(); Cci.BinaryWriter cmw = new Cci.BinaryWriter(customMetadata); cmw.WriteByte(Cci.CustomDebugInfoConstants.CdiVersion); cmw.WriteByte(kind); cmw.Align(4); // length (will be patched) uint lengthPosition = cmw.BaseStream.Position; cmw.WriteUint(0); data(cmw); uint length = customMetadata.Position; cmw.BaseStream.Position = lengthPosition; cmw.WriteUint(length); cmw.BaseStream.Position = length; return(customMetadata); }