Esempio n. 1
0
        private unsafe SourceText CreateTextFromTemporaryStorage(ISupportDirectMemoryAccess accessor, int streamLength, CancellationToken cancellationToken)
        {
            char *src = (char *)accessor.GetPointer();

            Debug.Assert(*src == 0xFEFF); // BOM: Unicode, little endian
            // Skip the BOM when creating the reader
            using (var reader = new DirectMemoryAccessStreamReader(src + 1, streamLength / sizeof(char) - 1))
            {
                var buffer = CreateTextBuffer(reader, cancellationToken);
                return(buffer.CurrentSnapshot.AsRoslynText(Encoding.Unicode));
            }
        }
 private unsafe SourceText CreateTextFromTemporaryStorage(ISupportDirectMemoryAccess accessor, int streamLength, CancellationToken cancellationToken)
 {
     char* src = (char*)accessor.GetPointer();
     Debug.Assert(*src == 0xFEFF); // BOM: Unicode, little endian
     // Skip the BOM when creating the reader
     using (var reader = new DirectMemoryAccessStreamReader(src + 1, streamLength / sizeof(char) - 1))
     {
         var buffer = CreateTextBuffer(reader, cancellationToken);
         return buffer.CurrentSnapshot.AsRoslynText(Encoding.Unicode);
     }
 }