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

Support code generation targeting C# < 9 #4

Closed
AArnott opened this issue Dec 14, 2020 · 1 comment
Closed

Support code generation targeting C# < 9 #4

AArnott opened this issue Dec 14, 2020 · 1 comment
Labels
enhancement New feature or request wontfix This will not be worked on

Comments

@AArnott
Copy link
Member

AArnott commented Dec 14, 2020

Source generators work in projects that target less than the C# 9 language version, so the generator should take the LangVersion into account and generate valid code given that target version.

Examples of C# features the generated code may rely on that require newer language versions include:

  1. Nullable ref annotations (C# 8)
  2. Function pointers (C# 9)
  3. 'null pointer constant pattern':

    Windows.Win32.PCWSTR.g.cs(52,15,52,19): error CS8370: Feature 'null pointer constant pattern' is not available in C# 7.3. Please use language version 8.0 or greater.

  4. 'readonly members'

    Windows.Win32.D2D_MATRIX_4X4_F.g.cs(66,22,66,30): error CS8370: Feature 'readonly members' is not available in C# 7.3. Please use language version 8.0 or greater.

Note that C# 9 does work on projects that target .NET Framework as well as .NET Core 3.1. But there are features of C# 8+ that do not work on .NET Framework, such as default interface methods from C# 8 or certain calling conventions of function pointers. By avoiding use of such features, many projects have successfully targeted .NET Framework while compiling with the C# 9 language version.

@AArnott
Copy link
Member Author

AArnott commented Jun 16, 2022

This becomes less of a priority as time goes by, and it's already so low relative to other issues we won't likely get to it while there is any interest.

@AArnott AArnott closed this as not planned Won't fix, can't repro, duplicate, stale Jun 16, 2022
@AArnott AArnott added the wontfix This will not be worked on label Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant