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

Fix MVVM Toolkit build errors when using C# < 9.0 #4285

Merged

Conversation

Sergio0694
Copy link
Member

Fixes #4269 (comment)

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

Using ObservableValidator or IRecipient<T> from the MVVM Toolkit causes a build error when using C# < 9.0.

What is the new behavior?

Fixed those build warnings. We should only restrict to C# 9 for the explicitly used source generator features.
These two instead don't need any new C# syntax, so they should work just fine even on C# 8.0.
If an even lower version of C# is set, then the two generators will just not run.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • New component
    • Pull Request has been submitted to the documentation repository instructions. Link:
    • Added description of major feature to project description for NuGet package (4000 total character limit, so don't push entire description over that)
    • If control, added to Visual Studio Design project
  • Sample in sample app has been added / updated (for bug fixes / features)
  • New major technical changes in the toolkit have or will be added to the Wiki e.g. build changes, source generators, testing infrastructure, sample creation changes, etc...
  • 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

@Sergio0694 Sergio0694 added bug 🐛 An unexpected issue that highlights incorrect behavior .NET Components which are .NET based (non UWP specific) mvvm-toolkit 🧰 Issues/PRs for the Microsoft.Toolkit.Mvvm package hotfix 🌶 priority 🚩 labels Sep 29, 2021
@Sergio0694 Sergio0694 added this to the 7.1.1 milestone Sep 29, 2021
@ghost
Copy link

ghost commented Sep 29, 2021

Thanks Sergio0694 for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@ghost ghost requested review from michael-hawker, azchohfi and Rosuavio September 29, 2021 09:32
@Sergio0694
Copy link
Member Author

@michael-hawker We absolutely need to get this one merged in for 7.1.1, as the MVVM Toolkit will just be causing build errors for all customers using C# 7.3 or lower otherwise if they use either ObservableValidator or IRecipient<T>, even without explicitly opting in into any of the source generator features. Sorry I didn't notice this sooner! 😅

Copy link
Member

@michael-hawker michael-hawker left a comment

Choose a reason for hiding this comment

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

Tested with an ObservableValidator on a file new project before and after and seemed to work great, thanks!

@michael-hawker michael-hawker merged commit 69576f9 into CommunityToolkit:main Oct 7, 2021
@Sergio0694 Sergio0694 deleted the bugfix/csharp8.0-mvvm-toolkit branch October 7, 2021 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior hotfix 🌶 mvvm-toolkit 🧰 Issues/PRs for the Microsoft.Toolkit.Mvvm package .NET Components which are .NET based (non UWP specific) priority 🚩
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]Mvvm Toolkit 7.1.0 no longer supports .NetStandard 2.0 ?
3 participants