-
Notifications
You must be signed in to change notification settings - Fork 4k
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
C# 11 required properties do not compile on dotnet 6 #68478
Comments
Those errors are expected. The "required members" feature is part of C# 11 and is only supported on .NET 7 and up. |
1.use 2.In .net 6 projects, IntelliSense should not recommend "required members" |
That's not the case here though. That's what we support (and so we don't do additional work in non-supported scenarios). If you added that attribute somehow, it would work (though we still dont' support that scenario), we don't block it. So the error you're getting is correct. The issue here is that those attributes are missing.
Could you clarify what you mean? We def show things in the completion list to help speed up typing, regardless of version. We don't keep things out of the completion list as that can both be confusing, and it means if you try to type this, you can end up with some other piece of completed text. |
Although I am aware of missing
|
@CyrusNajmabadi @jcouv Please re-open |
Added a summary to OP: "The ask is that required properties not be recommended by the IDE on .NET 6 or lower." and assigned to the IDE team to take a look. |
The ide behavior is expected here. This is a viable way to fix the issue. And if we don't offer it, it could be confusing to the user (I believe we had this Convo when creating the feature). The user is not told to pick this option. They choose it, if appropriate, from the options offered. And if they want this, that means they're ok with moving forward. |
when cleaning up code, should use |
That is one of the options offered :-) |
The cleanup worked fine when I hadn't updated vs to the latest version, but now that I've updated vs to the latest version, the project has a build error after the cleanup because |
Can you give an example of what you mean? What was your code, and which fix did you pick? |
|
@mavasani Do you know how 'code cleanup' does this work? |
Also adding @sharwell Choosing "Fix all warnings and errors set in EditorConfig" in the code cleanup profile leads to code cleanup sequentially attempting to fix all analyzer and compiler warnings and errors in code and considers all code fixer as potential candidates for providing a fix. It seems that we may need to add logic such that a code fixer can declaratively state that it shouldn't be included in code cleanup, and all fixers that fall in this bucket of "application introduces further compiler errors" should be marked for exclusion in code cleanup. @sharwell thoughts? |
Another option is to make this low-pri. Or order after "declare as nullable". That said, neither of these is truly better than the other. So it's unclear to me what would be hte right behavior here as it depends on hte user. |
This is explicitly instructing the compiler to ignore the official support matrix and force required members to be allowed for a mismatched target framework, and as such is not an officially supported scenario. As a result, the analyzers related to required members may report diagnostics, and those diagnostics would be fixed if the configuration instructs it to. The change expected here would be the |
[Update(jcouv):] The ask is that required properties not be recommended by the IDE on .NET 6 or lower.
Describe the bug
When I want to use required properties in a project targeting net6.0 with LangVersion set to latest I face some compile errors.
To Reproduce
2.
dotnet build
Exceptions (if any)
Expected Behavior: build successful
The text was updated successfully, but these errors were encountered: