Skip to content

Commit c372923

Browse files
committed
remove Unmarshalled*
1 parent 71255d3 commit c372923

14 files changed

+6
-342
lines changed

src/Components/WebAssembly/JSInterop/src/PublicAPI.Shipped.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
#nullable enable
2-
~Microsoft.JSInterop.WebAssembly.WebAssemblyJSRuntime.InvokeUnmarshalled<T0, T1, T2, TResult>(string identifier, T0 arg0, T1 arg1, T2 arg2) -> TResult
3-
~Microsoft.JSInterop.WebAssembly.WebAssemblyJSRuntime.InvokeUnmarshalled<T0, T1, TResult>(string identifier, T0 arg0, T1 arg1) -> TResult
4-
~Microsoft.JSInterop.WebAssembly.WebAssemblyJSRuntime.InvokeUnmarshalled<T0, TResult>(string identifier, T0 arg0) -> TResult
5-
~Microsoft.JSInterop.WebAssembly.WebAssemblyJSRuntime.InvokeUnmarshalled<TResult>(string identifier) -> TResult
62
~override Microsoft.JSInterop.WebAssembly.WebAssemblyJSRuntime.BeginInvokeJS(long asyncHandle, string identifier, string argsJson, Microsoft.JSInterop.JSCallResultType resultType, long targetInstanceId) -> void
73
~override Microsoft.JSInterop.WebAssembly.WebAssemblyJSRuntime.InvokeJS(string identifier, string argsJson, Microsoft.JSInterop.JSCallResultType resultType, long targetInstanceId) -> string
84
Microsoft.JSInterop.WebAssembly.WebAssemblyJSRuntime
9-
Microsoft.JSInterop.WebAssembly.WebAssemblyJSRuntime.InvokeUnmarshalled<T0, T1, T2, TResult>(string! identifier, T0 arg0, T1 arg1, T2 arg2) -> TResult
10-
Microsoft.JSInterop.WebAssembly.WebAssemblyJSRuntime.InvokeUnmarshalled<T0, T1, TResult>(string! identifier, T0 arg0, T1 arg1) -> TResult
11-
Microsoft.JSInterop.WebAssembly.WebAssemblyJSRuntime.InvokeUnmarshalled<T0, TResult>(string! identifier, T0 arg0) -> TResult
12-
Microsoft.JSInterop.WebAssembly.WebAssemblyJSRuntime.InvokeUnmarshalled<TResult>(string! identifier) -> TResult
135
Microsoft.JSInterop.WebAssembly.WebAssemblyJSRuntime.WebAssemblyJSRuntime() -> void
146
override Microsoft.JSInterop.WebAssembly.WebAssemblyJSRuntime.BeginInvokeJS(long asyncHandle, string! identifier, string? argsJson, Microsoft.JSInterop.JSCallResultType resultType, long targetInstanceId) -> void
157
override Microsoft.JSInterop.WebAssembly.WebAssemblyJSRuntime.EndInvokeDotNet(Microsoft.JSInterop.Infrastructure.DotNetInvocationInfo callInfo, in Microsoft.JSInterop.Infrastructure.DotNetInvocationResult dispatchResult) -> void

src/Components/WebAssembly/JSInterop/src/WebAssemblyJSObjectReference.cs

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Microsoft.JSInterop.WebAssembly;
77

8-
internal sealed class WebAssemblyJSObjectReference : JSInProcessObjectReference, IJSUnmarshalledObjectReference
8+
internal sealed class WebAssemblyJSObjectReference : JSInProcessObjectReference
99
{
1010
private readonly WebAssemblyJSRuntime _jsRuntime;
1111

@@ -14,38 +14,4 @@ public WebAssemblyJSObjectReference(WebAssemblyJSRuntime jsRuntime, long id)
1414
{
1515
_jsRuntime = jsRuntime;
1616
}
17-
18-
#pragma warning disable CS0612 // Type or member is obsolete
19-
[Obsolete("This method is obsolete. Use JSImportAttribute instead.")]
20-
public TResult InvokeUnmarshalled<TResult>(string identifier)
21-
{
22-
ThrowIfDisposed();
23-
24-
return _jsRuntime.InvokeUnmarshalled<object?, object?, object?, TResult>(identifier, null, null, null, Id);
25-
}
26-
27-
[Obsolete("This method is obsolete. Use JSImportAttribute instead.")]
28-
public TResult InvokeUnmarshalled<T0, TResult>(string identifier, T0 arg0)
29-
{
30-
ThrowIfDisposed();
31-
32-
return _jsRuntime.InvokeUnmarshalled<T0, object?, object?, TResult>(identifier, arg0, null, null, Id);
33-
}
34-
35-
[Obsolete("This method is obsolete. Use JSImportAttribute instead.")]
36-
public TResult InvokeUnmarshalled<T0, T1, TResult>(string identifier, T0 arg0, T1 arg1)
37-
{
38-
ThrowIfDisposed();
39-
40-
return _jsRuntime.InvokeUnmarshalled<T0, T1, object?, TResult>(identifier, arg0, arg1, null, Id);
41-
}
42-
43-
[Obsolete("This method is obsolete. Use JSImportAttribute instead.")]
44-
public TResult InvokeUnmarshalled<T0, T1, T2, TResult>(string identifier, T0 arg0, T1 arg1, T2 arg2)
45-
{
46-
ThrowIfDisposed();
47-
48-
return _jsRuntime.InvokeUnmarshalled<T0, T1, T2, TResult>(identifier, arg0, arg1, arg2, Id);
49-
}
50-
#pragma warning restore CS0612 // Type or member is obsolete
5117
}

src/Components/WebAssembly/JSInterop/src/WebAssemblyJSObjectReferenceJsonConverter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ public override bool CanConvert(Type typeToConvert)
2020
{
2121
return typeToConvert == typeof(WebAssemblyJSObjectReference) ||
2222
typeToConvert == typeof(IJSObjectReference) ||
23-
typeToConvert == typeof(IJSInProcessObjectReference) ||
24-
typeToConvert == typeof(IJSUnmarshalledObjectReference);
23+
typeToConvert == typeof(IJSInProcessObjectReference);
2524
}
2625

2726
public override IJSObjectReference? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)

src/Components/WebAssembly/JSInterop/src/WebAssemblyJSRuntime.cs

Lines changed: 1 addition & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Microsoft.JSInterop.WebAssembly;
1212
/// Provides methods for invoking JavaScript functions for applications running
1313
/// on the Mono WebAssembly runtime.
1414
/// </summary>
15-
public abstract class WebAssemblyJSRuntime : JSInProcessRuntime, IJSUnmarshalledRuntime
15+
public abstract class WebAssemblyJSRuntime : JSInProcessRuntime
1616
{
1717
/// <summary>
1818
/// Initializes a new instance of <see cref="WebAssemblyJSRuntime"/>.
@@ -56,73 +56,4 @@ protected override void SendByteArray(int id, byte[] data)
5656
{
5757
InternalCalls.ReceiveByteArray(id, data);
5858
}
59-
60-
[Obsolete("This method is obsolete. Use JSImportAttribute instead.")]
61-
internal TResult InvokeUnmarshalled<T0, T1, T2, TResult>(string identifier, T0 arg0, T1 arg1, T2 arg2, long targetInstanceId)
62-
{
63-
var resultType = JSCallResultTypeHelper.FromGeneric<TResult>();
64-
65-
var callInfo = new JSCallInfo
66-
{
67-
FunctionIdentifier = identifier,
68-
TargetInstanceId = targetInstanceId,
69-
ResultType = resultType,
70-
};
71-
72-
string exception;
73-
74-
switch (resultType)
75-
{
76-
case JSCallResultType.Default:
77-
case JSCallResultType.JSVoidResult:
78-
var result = InternalCalls.InvokeJS<T0, T1, T2, TResult>(out exception, ref callInfo, arg0, arg1, arg2);
79-
return exception != null
80-
? throw new JSException(exception)
81-
: result;
82-
case JSCallResultType.JSObjectReference:
83-
var id = InternalCalls.InvokeJS<T0, T1, T2, int>(out exception, ref callInfo, arg0, arg1, arg2);
84-
return exception != null
85-
? throw new JSException(exception)
86-
: (TResult)(object)new WebAssemblyJSObjectReference(this, id);
87-
case JSCallResultType.JSStreamReference:
88-
var serializedStreamReference = InternalCalls.InvokeJS<T0, T1, T2, string>(out exception, ref callInfo, arg0, arg1, arg2);
89-
return exception != null
90-
? throw new JSException(exception)
91-
: (TResult)(object)DeserializeJSStreamReference(serializedStreamReference);
92-
default:
93-
throw new InvalidOperationException($"Invalid result type '{resultType}'.");
94-
}
95-
}
96-
97-
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "IJSStreamReference is referenced in Microsoft.JSInterop.Infrastructure.JSStreamReferenceJsonConverter")]
98-
private IJSStreamReference DeserializeJSStreamReference(string serializedStreamReference)
99-
{
100-
var jsStreamReference = JsonSerializer.Deserialize<IJSStreamReference>(serializedStreamReference, JsonSerializerOptions);
101-
if (jsStreamReference is null)
102-
{
103-
throw new ArgumentException($"Failed to parse as {nameof(IJSStreamReference)}.", nameof(serializedStreamReference));
104-
}
105-
106-
return jsStreamReference;
107-
}
108-
109-
/// <inheritdoc />
110-
[Obsolete("This method is obsolete. Use JSImportAttribute instead.")]
111-
public TResult InvokeUnmarshalled<TResult>(string identifier)
112-
=> InvokeUnmarshalled<object?, object?, object?, TResult>(identifier, null, null, null, 0);
113-
114-
/// <inheritdoc />
115-
[Obsolete("This method is obsolete. Use JSImportAttribute instead.")]
116-
public TResult InvokeUnmarshalled<T0, TResult>(string identifier, T0 arg0)
117-
=> InvokeUnmarshalled<T0, object?, object?, TResult>(identifier, arg0, null, null, 0);
118-
119-
/// <inheritdoc />
120-
[Obsolete("This method is obsolete. Use JSImportAttribute instead.")]
121-
public TResult InvokeUnmarshalled<T0, T1, TResult>(string identifier, T0 arg0, T1 arg1)
122-
=> InvokeUnmarshalled<T0, T1, object?, TResult>(identifier, arg0, arg1, null, 0);
123-
124-
/// <inheritdoc />
125-
[Obsolete("This method is obsolete. Use JSImportAttribute instead.")]
126-
public TResult InvokeUnmarshalled<T0, T1, T2, TResult>(string identifier, T0 arg0, T1 arg1, T2 arg2)
127-
=> InvokeUnmarshalled<T0, T1, T2, TResult>(identifier, arg0, arg1, arg2, 0);
12859
}

src/Components/WebAssembly/WebAssembly/src/Microsoft.AspNetCore.Components.WebAssembly.WarningSuppressions.xml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@
1313
<property name="Scope">member</property>
1414
<property name="Target">M:Microsoft.AspNetCore.Components.RootComponentTypeCache.ResolveType(Microsoft.AspNetCore.Components.RootComponentTypeCache.Key,System.Reflection.Assembly[])</property>
1515
</attribute>
16-
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
17-
<argument>ILLink</argument>
18-
<argument>IL2026</argument>
19-
<property name="Scope">member</property>
20-
<property name="Target">M:Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHostBuilder.InitializeRegisteredRootComponents(Microsoft.JSInterop.IJSUnmarshalledRuntime)</property>
21-
</attribute>
2216
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
2317
<argument>ILLink</argument>
2418
<argument>IL2026</argument>
@@ -43,11 +37,5 @@
4337
<property name="Scope">member</property>
4438
<property name="Target">M:Microsoft.Extensions.HotReload.HotReloadAgent.&lt;GetHandlerActions&gt;g__GetUpdateMethod|9_1(System.Type,System.String)</property>
4539
</attribute>
46-
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
47-
<argument>ILLink</argument>
48-
<argument>IL2072</argument>
49-
<property name="Scope">member</property>
50-
<property name="Target">M:Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHostBuilder.InitializeRegisteredRootComponents(Microsoft.JSInterop.IJSUnmarshalledRuntime)</property>
51-
</attribute>
5240
</assembly>
5341
</linker>

src/Components/WebAssembly/WebAssembly/test/JSObjectReferenceJsonConverterTest.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,4 @@ public void Read_ReadsJson_IJSInProcessObjectReference()
4444
// Assert
4545
Assert.Equal(expectedId, deserialized?.Id);
4646
}
47-
48-
[Fact]
49-
public void Read_ReadsJson_IJSUnmarshalledObjectReference()
50-
{
51-
// Arrange
52-
var expectedId = 3;
53-
var json = $"{{\"__jsObjectId\":{expectedId}}}";
54-
55-
// Act
56-
var deserialized = (WebAssemblyJSObjectReference)JsonSerializer.Deserialize<IJSUnmarshalledObjectReference>(json, JsonSerializerOptions)!;
57-
58-
// Assert
59-
Assert.Equal(expectedId, deserialized?.Id);
60-
}
6147
}

src/Components/test/E2ETest/Tests/InteropTest.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ public void CanInvokeDotNetMethods()
133133
["invokeThrowsSerializingCircularStructure"] = "Success",
134134
["invokeThrowsUndefinedJSObjectReference"] = "Success",
135135
["invokeThrowsNullJSObjectReference"] = "Success",
136-
["jsUnmarshalledObjectReference.unmarshalledFunction"] = "True",
137-
["jsToDotNetStreamReturnValueUnmarshalled"] = "Success",
138-
["jsCastedUnmarshalledObjectReference.unmarshalledFunction"] = "False",
139136
["stringValueUpperSync"] = "MY STRING",
140137
["testDtoNonSerializedValueSync"] = "99999",
141138
["testDtoSync"] = "Same",

src/Components/test/testassets/BasicTestApp/InteropComponent.razor

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@
236236

237237
if (shouldSupportSyncInterop)
238238
{
239-
await InvokeInProcessJSInterop();
239+
InvokeInProcessJSInterop();
240240
}
241241

242242
var byteArray = new byte[] { 1, 5, 7, 15, 35, 200 };
@@ -334,7 +334,7 @@
334334
ReceiveDotNetObjectByRefResult["testDto"] = result.TestDto.Value == passDotNetObjectByRef ? "Same" : "Different";
335335
}
336336

337-
public async Task InvokeInProcessJSInterop()
337+
public void InvokeInProcessJSInterop()
338338
{
339339
var inProcRuntime = ((IJSInProcessRuntime)JSRuntime);
340340

@@ -408,39 +408,6 @@
408408
{
409409
ReturnValues["invokeVoidReturnsWithoutSerializingInIJSInProcessObjectReference"] = $"Failure: {ex.Message}";
410410
}
411-
412-
// we should be able to downcast a IJSInProcessObjectReference as a IJSUnmarshalledObjectReference
413-
var unmarshalledCast = (IJSUnmarshalledObjectReference)jsInProcObjectReference;
414-
#pragma warning disable CS0618 // Type or member is obsolete
415-
ReturnValues["jsCastedUnmarshalledObjectReference.unmarshalledFunction"] = unmarshalledCast.InvokeUnmarshalled<InteropStruct, bool>("unmarshalledFunction", new InteropStruct
416-
{
417-
Message = "Sent from .NET",
418-
NumberField = 41,
419-
}).ToString();
420-
421-
try
422-
{
423-
jsInProcObjectReference.Dispose();
424-
ReturnValues["disposeJSInProcessObjectReference"] = "Success";
425-
}
426-
catch (Exception ex)
427-
{
428-
ReturnValues["disposeJSInProcessObjectReference"] = $"Failure: {ex.Message}";
429-
}
430-
431-
var unmarshalledRuntime = (IJSUnmarshalledRuntime)JSRuntime;
432-
var jsUnmarshalledReference = unmarshalledRuntime.InvokeUnmarshalled<IJSUnmarshalledObjectReference>("returnJSObjectReference");
433-
ReturnValues["jsUnmarshalledObjectReference.unmarshalledFunction"] = jsUnmarshalledReference.InvokeUnmarshalled<InteropStruct, bool>("unmarshalledFunction", new InteropStruct
434-
{
435-
Message = "Sent from .NET",
436-
NumberField = 42,
437-
}).ToString();
438-
439-
440-
var dataReference = unmarshalledRuntime.InvokeUnmarshalled<IJSStreamReference>("jsToDotNetStreamReturnValue");
441-
#pragma warning restore CS0618 // Type or member is obsolete
442-
using var dataReferenceStream = await dataReference.OpenReadStreamAsync();
443-
await ValidateStreamValuesAsync("jsToDotNetStreamReturnValueUnmarshalled", dataReferenceStream);
444411
}
445412

446413
public class PassDotNetObjectByRefArgs

src/Components/test/testassets/BasicTestApp/wwwroot/js/jsinteroptests.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,6 @@ function returnJSObjectReference() {
346346
dispose: function () {
347347
DotNet.disposeJSObjectReference(this);
348348
},
349-
unmarshalledFunction: function (fields) {
350-
const message = Blazor.platform.readStringField(fields, 0);
351-
const numberField = Blazor.platform.readInt32Field(fields, 8);
352-
return message === "Sent from .NET" && numberField === 42;
353-
}
354349
};
355350
}
356351

src/JSInterop/Microsoft.JSInterop/src/IJSUnmarshalledObjectReference.cs

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)