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

Fixes around namespaces and Fluent API calls #25435

Merged
merged 5 commits into from
Aug 12, 2021
Merged

Conversation

roji
Copy link
Member

@roji roji commented Aug 5, 2021

@bricelam this is a draft for getting your general OK before going further... #25046 (custom namespaces in scaffolding) is fully implemented, while #23848 (type-qualified Fluent APIs in the model snapshot) is a bit more tricky/ugly.

Closes #25046
Closes #23848
Closes #25434

@roji roji requested a review from bricelam August 5, 2021 17:47
@roji roji marked this pull request as draft August 5, 2021 20:58
* Add using namespace directives for scaffolded Fluent API calls which
  are outside the standard namespaces.
* Generate provider Fluent API calls as type-qualified in the model
  snapshot, to prevent ambiguity in multi-provider scenarios.

Closes #25046
Closes #23848
Closes #25434
@roji roji marked this pull request as ready for review August 11, 2021 22:20
@roji roji requested a review from AndriySvyryd August 11, 2021 22:20
Co-authored-by: Andriy Svyryd <AndriySvyryd@users.noreply.github.com>
@@ -1421,7 +1315,7 @@ protected virtual void GenerateKeyAnnotations(IKey key, IndentedStringBuilder st
Check.NotNull(annotations, nameof(annotations));
Check.NotNull(stringBuilder, nameof(stringBuilder));

foreach (var annotation in annotations)
foreach (var annotation in annotations.OrderBy(a => a.Name))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to reorder?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this method which was dead code (#25435 (comment)), but the same ordering is applied to raw annotations in the new GenerateAnnotations. It's for alphabetical determinism etc., nothing too important.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether using SortedDictionary would be faster since they were already ordered initially.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting idea... Hard to know - we'd likely pay more in other accesses/lookups (e.g. when generating the fluent APIs, when removing ignorable/by-convention annotations...), who knows which way it goes.

I've seen lots of things around code generation here which aren't very optimized - that's probably OK. If we have indication that things are slow, at some point we can profile a bit and get rid of the worst offenders etc...

(BTW perf is also why I decided to discovery namespaces in scaffolding via a single pass along with generation, rather than the approach used in MigrationsCodeGenerator of a 2nd pass only for namespace discovery. Not sure how much all this is important...)

@roji roji force-pushed the roji/CodeFragmentNamespaces branch from a46bc8e to b91f109 Compare August 12, 2021 09:28
@roji roji merged commit 65b3849 into main Aug 12, 2021
@roji roji deleted the roji/CodeFragmentNamespaces branch August 12, 2021 19:28
@roji
Copy link
Member Author

roji commented Aug 12, 2021

Thanks @AndriySvyryd!

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