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 nesting and generics for union types #23

Merged
merged 9 commits into from
Sep 1, 2024
Merged

Conversation

jeffijoe
Copy link
Contributor

@jeffijoe jeffijoe commented Sep 1, 2024

Union nesting

This PR adds support for nesting union types within other types.

using System.Collections.Generic;
using FxKit.CompilerServices;

namespace Super.Duper.Unions;

public partial class One
{
    [Union]
    public partial record Problem
    {
        partial record Invalid;
        partial record Denied;
    }
}

public partial class Two
{
    [Union]
    public partial record Problem
    {
        partial record Invalid;
        partial record Denied;
    }
}

EnumMatch generator refactor

The EnumMatch generator has also been refactored for performance by properly utilizing incremental generation. The syntax writer has also been updated to use IndentedTextWriter

MustBePartialAnalyzer - check ancestry

The MustBePartialAnalyzer has been updated to check the type's ancestors for partial.

using FxKit.CompilerServices;

namespace Super.Duper.Unions;

// missing partial
public class Super
{
    // missing partial
    public class Duper
    {
        [Union]
        public partial record Nested
        {
          partial record Incorrect;
        }
    }
}

The Super and Duper types will be reported as missing partial.

@jeffijoe jeffijoe requested review from radyz, Xepe and jcorkhill September 1, 2024 21:24
@jeffijoe jeffijoe merged commit fe5bde8 into main Sep 1, 2024
2 checks passed
@jeffijoe jeffijoe deleted the feat/union-nesting branch September 1, 2024 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant