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

Proposal for Improvement of Error Message Regarding Null Propagation Operator #72803

Open
vsfeedback opened this issue Mar 29, 2024 · 0 comments
Labels
Area-Compilers Bug Concept-Diagnostic Clarity The issues deals with the ease of understanding of errors and warnings.
Milestone

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


Dear Visual Studio Development Team,

I am writing to share a suggestion for improvement that I believe would enhance the developer experience when using the null propagation operator in Visual Studio.

Currently, when developers attempt to use the null propagation operator (?.) to assign a value to a property of an object that may be null, the compiler generates the error CS0131. This situation can lead to confusion for developers regarding the cause of the error.

I suggest that the error message generated in such cases be enhanced to include a clear explanation of why the use of the null propagation operator is not allowed in the context of a property assignment. For example, the message could state that "The null propagation operator cannot be used to assign a value to a property when the object may be null. Instead, use an explicit null check with an if statement to ensure the safety of the property assignment."

I am confident that such an improvement would help developers more easily understand the nature of the error and correct their code accordingly. This would contribute to making Visual Studio even more user-friendly and improving developer efficiency.

Thank you for considering this improvement suggestion. I am open to any further discussion on this topic and ready to provide more details if needed.

Best regards,
LACOMBE Dominique


Original Comments

Feedback Bot on 3/3/2024, 06:11 PM:

(private comment, text removed)

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Language Design untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 29, 2024
@CyrusNajmabadi CyrusNajmabadi added Area-Compilers Concept-Diagnostic Clarity The issues deals with the ease of understanding of errors and warnings. and removed Area-Language Design untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 29, 2024
@CyrusNajmabadi CyrusNajmabadi added this to the Backlog milestone Mar 29, 2024
@jaredpar jaredpar added the Bug label Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Bug Concept-Diagnostic Clarity The issues deals with the ease of understanding of errors and warnings.
Projects
None yet
Development

No branches or pull requests

3 participants