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

Nested StronglyTypedId 1.0.0-beta02 #40

Closed
patrolez opened this issue Nov 5, 2021 · 3 comments · Fixed by #41
Closed

Nested StronglyTypedId 1.0.0-beta02 #40

patrolez opened this issue Nov 5, 2021 · 3 comments · Fixed by #41

Comments

@patrolez
Copy link

patrolez commented Nov 5, 2021

Hello @andrewlock,
I am migrating from 0.2.1 to 1.0.0-beta02 and I have noticed that nesting:

public partial class Blog
{
  [StronglyTypedId(backingType: StronglyTypedIdBackingType.String, converters: StronglyTypedIdConverter.NewtonsoftJson | StronglyTypedIdConverter.SystemTextJson | StronglyTypedIdConverter.EfCoreValueConverter)]
  public partial struct PostId { }
}

Stopped triggering code generation, so calling a constructor is not possible and dotnet sdk 5.0.402 returns:
error CS1729: 'Blog.PostId' does not contain a constructor that takes 1 arguments

While it was working for 0.2.1. For now, I have just moved PostId outside to be directly under namespace scope and prefixed its name, then done some Find&Replace action.

@andrewlock
Copy link
Owner

Hi @patrolez, apologies, the source generator version doesn't support nested structs yet, but thanks for flagging it!

@patrolez
Copy link
Author

Hello @andrewlock,
I've just read through the entire README file and this limitation is highlighted, so there is nothing to apologize about 👍

Could it be also included within a list about breaking changes related to description which could be helpful regarding migration from 0.2 to 1.x?

I can see that there are two files with such a list:
https://github.com/andrewlock/StronglyTypedId/blob/master/CHANGELOG.md
https://github.com/andrewlock/StronglyTypedId/blob/master/releasenotes.props

Btw. https://andrewlock.net/strongly-typed-ids-in-ef-core-using-strongly-typed-entity-ids-to-avoid-primitive-obsession-part-4/#creating-a-custom-valueconverterselector-for-strongly-typed-ids is great, and I think it could be also referred somewhere within repository OR the Readme file.

@andrewlock
Copy link
Owner

Hey @patrolez , thanks for trying it out! The nested id issue is a limitation I intend to fix soon. Thanks for the suggestions about extra docs, I'll add those too!

Note that for beta3 and onwards you will need to use the .net 6 SDK as the source generator uses a more efficient mechanism now

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 a pull request may close this issue.

2 participants