Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting the error CS0103 The name 'paramName' does not exist in the current context in terminal but not in IDE #39162

Closed
livan3li opened this issue Mar 3, 2024 · 2 comments
Labels
Area-NetSDK untriaged Request triage from a team member

Comments

@livan3li
Copy link

livan3li commented Mar 3, 2024

Describe the bug

If I try to build project that have the following code in the project I get

error CS0103: The name 'paramName' does not exist in the current context

in the terminal.

[Route($"{nameof(paramName)}")] public async Task<IActionResult<bool>> GetValue(string paramName) { // some code... }

But if I try to build same code/project through solution explorer in vs code like in the following picture I do not get any error.
image

And also I do not get any error from VS Code telling the above error. I get only if I run dotnet build command in the terminal.

I don't know if this error is caused by C# Extension or dotnet SDK. I wanted to post bug here.

To Reproduce

  1. Try to build above sample code two different ways.
    a. By Solution Explorer like in the image
    b. By dotnet build command in terminal

Further technical details

  • DOTNET VERSION: 6.0.418
  • C# Extension Version: 2.19.13
  • C# Dev Kit Version: 1.3.10
  • VSCode Version: 1.87.0
  • OS: Linux Debian.12-x64
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NetSDK untriaged Request triage from a team member labels Mar 3, 2024
@KalleOlaviNiemitalo
Copy link
Contributor

KalleOlaviNiemitalo commented Mar 3, 2024

That's a C# 11 feature; see dotnet/csharplang#373 and What's new in C# 11. According to C# language versioning, "C# 11 is supported only on .NET 7 and newer versions." So it's by design that you get an error on .NET SDK 6.0.418. But I wonder why C# Extension and C# Dev Kit allow this code.

@marcpopMSFT
Copy link
Member

Per Kalle, looks like this is a new feature. Feel free to file a devkit issue if you believe it should be flagged in the UI rather than in the build. By design for the sdk though.

@marcpopMSFT marcpopMSFT closed this as not planned Won't fix, can't repro, duplicate, stale Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-NetSDK untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

3 participants