C
C#2w ago
jborean

How to fix VSCode Error/Warning for valid code

Is there something I need to do in vscode to use a newer lang version or something so that it doesn't think this is an error
interface IInterface
{
void Test(Action<ReadOnlySpan<byte>> callback);
}
interface IInterface
{
void Test(Action<ReadOnlySpan<byte>> callback);
}
The type 'ReadOnlySpan<byte>' may not be used as a type argument
The type 'ReadOnlySpan<byte>' may not be used as a type argument
The code compiles but vscode syntax highlighting shows it as an error
19 Replies
Sehra
Sehra2w ago
maybe that you forgot interface?
jborean
jboreanOP2w ago
Sorry that was just me copy/pasting wrong, it’s definitely there It’s complaining thinking ROS can’t be used in the Func but it can be since the latest C# version
Sehra
Sehra2w ago
should be fine since net9, see which target framework you are building for, and which sdk you are using
jborean
jboreanOP2w ago
the csproj has net9.0 To be clear it has
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
<PublishTrimmed>true</PublishTrimmed>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.IO.Pipelines" Version="9.0.0" />
</ItemGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
<PublishTrimmed>true</PublishTrimmed>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.IO.Pipelines" Version="9.0.0" />
</ItemGroup>

</Project>
Sehra
Sehra2w ago
looks fine, maybe something in vscode, check if the c# dev kit is updated
Angius
Angius2w ago
Try explicitly setting the language version?
jborean
jboreanOP2w ago
I'm not using the dev kit, just the plain C# extension
Angius
Angius2w ago
That could be the issue lol
jborean
jboreanOP2w ago
But it is up to date As in newer features only come to the dev kit one or just it gets more attention support wise from MS?
Angius
Angius2w ago
Both
jborean
jboreanOP2w ago
Ok, will look at submitting an issue on the extension then Unfortunately an explicit LangVersion didn't help Looks like it is ok in the dev kit so yes sounds like a bug they need to fix in the standard analyser
Angius
Angius2w ago
I'm not sure they will, DevKit is the way to add .NET support to VSCode
Sehra
Sehra2w ago
but also with an annoying sign in requirement
Angius
Angius2w ago
Well, yeah, it uses the same licensing model as VS proper Me, personally, $ridergang
MODiX
MODiX2w ago
:rider: 🇬 🇦 🇳 🇬
jborean
jboreanOP2w ago
DevKit is marked as optional and while I agree it has new features it is documented that the plain C# extension should work just fine for normal analysis without any VS subscription I would also love to use Rider but VSCode's remote ssh extension is miles ahead (it actually works on my host) than Rider's equivalent
jborean
jboreanOP2w ago
Opened https://github.com/dotnet/vscode-csharp/issues/7911, worst that can happen is they say no
GitHub
Issues · dotnet/vscode-csharp
Official C# support for Visual Studio Code. Contribute to dotnet/vscode-csharp development by creating an account on GitHub.
jborean
jboreanOP2w ago
Welp it turns out I had "dotnet.server.useOmnisharp": true set in my VSCode SSH remote settings but not local so I thought I wasn't using O# but it in fact was. Removed that and things start working magically

Did you find this page helpful?