dotnet icon indicating copy to clipboard operation
dotnet copied to clipboard

Toolkit Doesn't Detect UnSupported C# Version or Doesn't work on C# 8

Open AathifMahir opened this issue 2 years ago • 6 comments

Describe the bug

Community Toolkit MVVM Doesn't Support C# Version 8 and Does Only Work with C# Version 9 and Above at the time of writing, In this case there's no proper warning or error output that relates to Community Toolkit MVVM on Compilation

Regression

7.1.2

Reproducible in sample app?

  • [x] This bug can be reproduced in the sample app.

Steps to reproduce

1. Create Vanilla UWP Project
2. Install Community Toolkit 8.0 using Nuget
3. Compile the App

Expected behavior

Community Toolkit MVVM Should Have Language Barrier to Prevent the Dependency from Installing on C# version 8 since least version of C# that is supported by Community Toolkit MVVM is C# Version 9 at the time of writing or Community Toolkit MVVM Should Support C# version 8

Screenshots

Screenshot 2022-08-10 1303041

Visual Studio Version

2022

Visual Studio Build Number

17.3

Nuget packages

Community Toolkit 8.0

Help us help you

Yes, but only if others can assist.

AathifMahir avatar Aug 10 '22 19:08 AathifMahir

Hello AathifMahir, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

ghost avatar Aug 10 '22 19:08 ghost

@AathifMahir Are you saying Visual Studio should prevent you from installing the Toolkit if you're using an unsupported C# version?

Arlodotexe avatar Aug 10 '22 20:08 Arlodotexe

@AathifMahir Are you saying Visual Studio should prevent you from installing the Toolkit if you're using an unsupported C# version?

Nope, I was saying the opposite of that, I mean community toolkit should present a language barrier or output the issue after Initialization or installation if possible, seems like I wrote the issue in a complex way. Let me edit that

Edit: Fixed and Updated the Issue

AathifMahir avatar Aug 10 '22 20:08 AathifMahir

@AathifMahir there's many community toolkits, so you need to be more specific. But I'm pretty sure you're talking about the MVVM package. I think you and Sergio may have been talking about this on Discord?

There's supposed to be a specific analytic message which instructs the developer about this change, but appears to not be showing up here.

michael-hawker avatar Aug 10 '22 21:08 michael-hawker

I think I forgot to update the generated code in the cached args when I lowered the minimum language version to C# 8. I reckon removing the target-typed new expressions from there should be enough, and then we can keep C# 8 as minimum. The check there is already in place, it's just that it's not enough because that generated code accidentally still used C# 9 features.

Should be an easy fix, will take a look in a bit 🙂 I reckon it should be enough to just replace this with an initializer taking the identifier name explicitly:

https://github.com/CommunityToolkit/dotnet/blob/96517eace88d95ec52a881e3e1ed74ea51436b40/CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/ObservablePropertyGenerator.Execute.cs#L979-L983

Sergio0694 avatar Aug 10 '22 22:08 Sergio0694

@AathifMahir there's many community toolkits, so you need to be more specific. But I'm pretty sure you're talking about the MVVM package. I think you and Sergio may have been talking about this on Discord?

There's supposed to be a specific analytic message which instructs the developer about this change, but appears to not be showing up here.

Took care of it 👍

AathifMahir avatar Aug 10 '22 22:08 AathifMahir

Is vanilla UWP still under support with the new 8.x.x versions of the Mvvm Toolkit? Even C#8 as minimum version would require manually bumping the LanguageVersion of the consuming project, which brings some risks that have to be managed relating to some of the C#8 features, since UWP is normally stuck on 7.3. Or should UWP consumers refrain from using the Source Generator based functionalities, since the code generated adheres to the C#8 spec and even this could be subject to change when .Net Core 3.1 is deprecated in November?

zsolt3991 avatar Aug 16 '22 18:08 zsolt3991