Issues with LibVLCSharp's bundled System DLLs and use of extension methods.
Summary
Use of vlc-unity clashes with the use of extension methods that extend types defined in System.Buffers, System.Memory, System.Numerics or System.Runtime.CompilerServices.
Minimal project and steps to reproduce
Method 1:
- Clone or download https://github.com/cellarmation/vlc-unity-issue-102
- Open the project in Unity3D (created in 2019.4.16f1)
- Errors should be displayed in the error window indicating extension methods cannot be used due to multiple versions of the target to extend.
Method 2:
- Create a fresh Unity3D project (tested against 2019.4.16f1)
- Import vlc-unity
- Change Api Compatibility Level to ".NET 4.x"
- Create a class adding any extension method to System.Numerics.Vector3 or System.Numerics.Quaternion. Example here: https://github.com/cellarmation/vlc-unity-issue-102/blob/master/Assets/ExtensionMethods.cs
What is the current bug behavior?
Compile time errors are generated.
What is the expected correct behavior?
Creation of extension methods on types defined in System.Buffers, System.Memory, System.Numerics and System.Runtime.CompilerServices should be possible without compile time errors being generated (removing vlc-unity will make the code compile).
Does it work on other platforms? Does it work with the official VLC apps?
Not tested.
Relevant logs and/or screenshots
Assets\ExtensionMethods.cs(3,53): error CS0433: The type 'Vector3' exists in both 'System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Assets\ExtensionMethods.cs(10,53): error CS0433: The type 'Quaternion' exists in both 'System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Environment
- OS: Windows 10
- Version 10.0.19042 Build 19042
- Device: PC
- LibVLC version and architecture: 4.0.0 x64
- LibVLCSharp version: 4.0.0
- VLC Unity plugin version: Unknown? Using trial/demo version, can't find version information.
- Scripting backend used: Mono
Possible fixes
- If LibVLCSharp.dll could depend on the Unity3D provided copies of System.Buffers, System.Memory, System.Numerics and System.Runtime.CompilerServices rather than bundling its own versions as plugins this issue would go away.
- vlc-unity might be able to use asmdef files or some similar mechanism to stop the project picking up the references to LibVLCSharp.dll's bundled versions of System.Buffers, System.Memory, System.Numerics and System.Runtime.CompilerServices so that the extension methods only find the Unity3D bundled versions.