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

Skip field reference diagnostics from constructors #539

Merged
merged 1 commit into from
Dec 14, 2022

Conversation

Sergio0694
Copy link
Member

This PR is a small follow up for #532. Specifically it solves issues such as this:

partial class ViewModel
{
    private string name;

    public ViewModel()
    {
        name = ""; // Warning
    }
}

The issue being that:

  • If you assign the field, the MVVM Toolkit issues diagnostics
  • If you assign the property, you get a nullability warning on the field

The fix is to just not emit diagnostics when assigning fields if the assignment is from a constructor of that type.

cc. @Youssef1313 would you mind also taking a look to confirm if this makes sense? Thank you! 😄

PR Checklist

  • Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • Based off latest main branch of toolkit
  • PR doesn't include merge commits (always rebase on top of our main, if needed)
  • Tested code with current supported SDKs
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes
  • Every new API (including internal ones) has full XML docs
  • Code follows all style conventions

@Sergio0694 Sergio0694 added improvements ✨ Improvements to an existing functionality next preview ✈️ This changes will be available in the upcoming preview mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit labels Dec 14, 2022
Copy link
Contributor

@Youssef1313 Youssef1313 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me.

@Sergio0694
Copy link
Member Author

Awesome, thank you for taking a look! 😊

@Sergio0694 Sergio0694 merged commit 333265f into main Dec 14, 2022
@delete-merged-branch delete-merged-branch bot deleted the dev/skip-diagnostics-within-constructors branch December 14, 2022 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvements ✨ Improvements to an existing functionality mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit next preview ✈️ This changes will be available in the upcoming preview
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants