parent
e43041d75f
commit
d052b22874
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -112,11 +112,11 @@ async function readFileData(elem: InputElement, fileId: number, startOffset: num
|
|||
function readFileDataSharedMemory(readRequest: any): number {
|
||||
const inputFileElementReferenceId = monoPlatform.readStringField(readRequest, 0);
|
||||
const inputFileElement = document.querySelector(`[_bl_${inputFileElementReferenceId}]`);
|
||||
const fileId = monoPlatform.readInt32Field(readRequest, 4);
|
||||
const sourceOffset = monoPlatform.readUint64Field(readRequest, 8);
|
||||
const destination = monoPlatform.readInt32Field(readRequest, 16) as unknown as System_Array<number>;
|
||||
const destinationOffset = monoPlatform.readInt32Field(readRequest, 20);
|
||||
const maxBytes = monoPlatform.readInt32Field(readRequest, 24);
|
||||
const fileId = monoPlatform.readInt32Field(readRequest, 8);
|
||||
const sourceOffset = monoPlatform.readUint64Field(readRequest, 12);
|
||||
const destination = monoPlatform.readInt32Field(readRequest, 24) as unknown as System_Array<number>;
|
||||
const destinationOffset = monoPlatform.readInt32Field(readRequest, 32);
|
||||
const maxBytes = monoPlatform.readInt32Field(readRequest, 36);
|
||||
|
||||
const sourceArrayBuffer = getFileById(inputFileElement as InputElement, fileId).arrayBuffer as ArrayBuffer;
|
||||
const bytesToRead = Math.min(maxBytes, sourceArrayBuffer.byteLength - sourceOffset);
|
||||
|
|
|
|||
|
|
@ -8,22 +8,25 @@ namespace Microsoft.AspNetCore.Components.Forms
|
|||
[StructLayout(LayoutKind.Explicit)]
|
||||
internal struct ReadRequest
|
||||
{
|
||||
// Even though this type is only intended for use on WebAssembly, make it able to
|
||||
// load on 64-bit runtimes by allowing 8 bytes for each reference-typed field.
|
||||
|
||||
[FieldOffset(0)]
|
||||
public string InputFileElementReferenceId;
|
||||
|
||||
[FieldOffset(4)]
|
||||
[FieldOffset(8)]
|
||||
public int FileId;
|
||||
|
||||
[FieldOffset(8)]
|
||||
[FieldOffset(12)]
|
||||
public long SourceOffset;
|
||||
|
||||
[FieldOffset(16)]
|
||||
[FieldOffset(24)]
|
||||
public byte[] Destination;
|
||||
|
||||
[FieldOffset(20)]
|
||||
[FieldOffset(32)]
|
||||
public int DestinationOffset;
|
||||
|
||||
[FieldOffset(24)]
|
||||
[FieldOffset(36)]
|
||||
public int MaxBytes;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,5 +65,16 @@ namespace Microsoft.AspNetCore.Components.Forms
|
|||
var ex = Assert.Throws<InvalidOperationException>(() => instance.GetMultipleFiles(1));
|
||||
Assert.Equal($"The maximum number of files accepted is 1, but 2 were supplied.", ex.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadRequestTypeCanBeLoaded()
|
||||
{
|
||||
// Represents https://github.com/dotnet/aspnetcore/issues/26882
|
||||
// Even though the ReadRequest type is only ever used on WebAssembly, developers might
|
||||
// do something that causes the type to be loaded on other environments, for example
|
||||
// using reflection. It's just a DTO with no behaviors so there's nothing to test
|
||||
// except that loading the type doesn't trigger an exception.
|
||||
GC.KeepAlive(new ReadRequest());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue