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

Compilation Failure on Generated Record Constructor for .NET 6 #5

Closed
MooVC opened this issue Jul 31, 2024 · 0 comments · Fixed by #7
Closed

Compilation Failure on Generated Record Constructor for .NET 6 #5

MooVC opened this issue Jul 31, 2024 · 0 comments · Fixed by #7
Assignees
Labels
bug Something isn't working

Comments

@MooVC
Copy link
Owner

MooVC commented Jul 31, 2024

Describe the bug
The generated constructor for a record type applies the SetsRequiredMembers attribute, however, this was added in .NET 7, resulting in a compilation failure in projects targeting .NET 6.

To Reproduce
The constructor is generated when the record is marked as partial. To reproduce:

  1. Create a new project that targets .NET 6
  2. Annotate a record with Fluentify
  3. Mark the record as partial
  4. Compile

Expected behavior
The code should compile.

Environment (please complete the following information):

  • Fluentify Version: 1.0.0
  • .NET Version: NET 6
  • IDE: Visual Studio 2022 v7.10.5

Additional context
CS0246 The type or namespace name 'SetsRequiredMembers' could not be found (are you missing a using directive or an assembly reference?)

@MooVC MooVC added the bug Something isn't working label Jul 31, 2024
@MooVC MooVC self-assigned this Jul 31, 2024
MooVC added a commit that referenced this issue Aug 5, 2024
- The fully qualified type information for the subject upon which Fluentify has been placed is now captured and utilized when generating extensions, thereby enabling support for nest classes (#3).
- Utilized Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing to improve the quality of the Generator tests.

## Fixed

- The generated code files for classes now apply a conditional preprocessor directive to #nullable calls to prevent compilation failure in .NET Standard 2.0 projects.
- The generated extensions no longer call ArgumentNullException.ThrowIfNull to prevent compilation failure in .NET Standard 2.0 projects.
- The generated extensions no longer use pattern matching to prevent compilation failure in .NET Standard 2.0 projects.
- The generated constructor for records now applies a preprocessor directive to the SetRequiredMembers attribute to prevent compilation failure in .NET 6 projects (#5).
@MooVC MooVC linked a pull request Aug 5, 2024 that will close this issue
MooVC added a commit that referenced this issue Aug 5, 2024
* ## Changed

- The fully qualified type information for the subject upon which Fluentify has been placed is now captured and utilized when generating extensions, thereby enabling support for nest classes.

#3

* ## Changed

- The fully qualified type information for the subject upon which Fluentify has been placed is now captured and utilized when generating extensions, thereby enabling support for nest classes (#3).
- Utilized Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing to improve the quality of the Generator tests.

## Fixed

- The generated code files for classes now apply a conditional preprocessor directive to #nullable calls to prevent compilation failure in .NET Standard 2.0 projects.
- The generated extensions no longer call ArgumentNullException.ThrowIfNull to prevent compilation failure in .NET Standard 2.0 projects.
- The generated extensions no longer use pattern matching to prevent compilation failure in .NET Standard 2.0 projects.
- The generated constructor for records now applies a preprocessor directive to the SetRequiredMembers attribute to prevent compilation failure in .NET 6 projects (#5).

* ## Fixed

- The generated code files no longer include the namespace if the containing namespace is global (#6).

* Refactored unit tests to utilize the same snippets for coarse and fine grain API tests
@MooVC MooVC closed this as completed in #7 Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant