Blazor.MediaCaptureStreams icon indicating copy to clipboard operation
Blazor.MediaCaptureStreams copied to clipboard

Types Inheriting from `IJSWrapper` should have `[IJSWrapperConverter]` attribute.

Open KristofferStrube opened this issue 1 year ago • 0 comments

Adding the IJSWrapperConverter attribute from Blazor.WebIDL to types that implement or inherit from IJSWrapper would make JSInterop with the types defined in this library easier.

This would make it so that you can do this:

MediaStream mediaStream = ... // some mediastream;

await JSRuntime.InvokeVoidAsync("methodTakingMediaStream", mediaStream);

instead of:

MediaStream mediaStream = ... // some mediastream;

await JSRuntime.InvokeVoidAsync("methodTakingMediaStream", mediaStream.JSReference);

This problem only gets worse when we have option types that hold wrapper types like the MediaStreamAudioSorceOptions type from Blazor.WebAudio.

Eventually I would like an analyzer that makes an error in the build if you have forgotten to add the IJSWrapperConverter attribute to some class.

KristofferStrube avatar Jul 04 '24 15:07 KristofferStrube