Skip to content

[feature] code-first discriminated union API #1073

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

Open
wants to merge 59 commits into
base: main
Choose a base branch
from

Conversation

DeagleGross
Copy link
Collaborator

@DeagleGross DeagleGross commented May 27, 2023

Implemented code-first discriminated union generation as was described in feature request.

Several notes:

  1. implemented very straightforward diagnostics report. Please, let me know if we need more \ less \ modifications
    a) class is not marked with partial keyword
    b) unionName parameter of ProtoUnionAttribute<> is null or whitespace
    c) memberName parameter of ProtoUnionAttribute<> is null or whitespace
    d) fieldNumbers are not unique per full class
    e) memberNames are not unique per class
    f) namespace not found for a class (either standard or file-scoped namespace is supported)
  2. Tested functionality in E2E (using local nuget feed):

Here is confirmation that files are generated per union name
image

and small demo of reported diagnostics
DiscriminatedUnionDiagnostics

closes #1060

# Conflicts:
#	src/BuildToolsUnitTests/BuildToolsUnitTests.csproj
#	src/protobuf-net.BuildTools.Legacy/protobuf-net.BuildTools.Legacy.csproj
@DeagleGross DeagleGross requested a review from mgravell May 27, 2023 23:43
@DeagleGross DeagleGross self-assigned this May 27, 2023
@DeagleGross
Copy link
Collaborator Author

re 3: my fault - I did not pack protobuf-net.Core locally with new union attribute definition.
I will test locally, fix, and let you know when its ready to be reviewed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposed code-first discriminated union API
2 participants