C# Interactive: warn/error when loading assemblies inappropriate for runtime
#48,985 opened on 2020/10/28
Repository metrics
- Stars
- (20,414 個のスター)
- PR merge metrics
- (平均マージ 6d 17h) (30d で 256 merged PRs)
説明
The C# Interactive window provides no warning when loading a .NET Core assembly into a C# Interactive window that is running in .NET Framework (or presumably vice versa). As a result, I loaded a .NET Core specific assembly and got very cryptic error messages that led to me giving up for an hour before realizing what I'd done wrong.
Can we emit a warning or error when loading an inappropriate assembly given the runtime?
This would be a great place to advertise the #reset core command as well so folks can switch the runtime (see also #48984).
Version Used: 16.9.30627.59.main
Steps to Reproduce:
Open the C# Interactive window (which defaults to .NET Framework 64-bit).
#r "D:\git\streamjsonrpc\bin\StreamJsonRpc.Tests\Debug\netcoreapp3.1\MessagePack.dll"
> MessagePack.Internal.AutomataKeyGen.GetKey(new byte[] { 109, 101, 116, 104, 111, 100 })
(1,1): error CS0012: The type 'ReadOnlySpan<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
(1,37): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
> #r "System.Runtime"
> MessagePack.Internal.AutomataKeyGen.GetKey(new byte[] { 109, 101, 116, 104, 111, 100 })
(1,1): error CS7069: Reference to type 'ReadOnlySpan<>' claims it is defined in 'System.Runtime', but it could not be found