-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
RevEng: Make some APIs public (non-Internal) #10517
Conversation
@ajcvickers? (make EntityEntryGraphIterator public) |
@tonysneed Do you depend on EntityEntryGraphIterator or IEntityEntryGraphIterator? |
@tonysneed FYI, I imagined EntityFrameworkCore.Scaffolding.Handlebars would override |
@ajcvickers I'm creating a new public static void TraverseGraph(this DbContext context, object item,
Action<EntityEntryGraphNode> callback)
{
IStateManager stateManager = context.Entry(item).GetInfrastructure().StateManager;
var node = new EntityEntryGraphNode(stateManager.GetOrCreateEntry(item), null, null);
IEntityEntryGraphIterator graphIterator = new EntityEntryGraphIterator();
var visited = new HashSet<int>();
graphIterator.TraverseGraph(node, n =>
{
// Check visited
if (visited.Contains(n.Entry.Entity.GetHashCode()))
return false;
// Execute callback
callback(n);
// Add visited
visited.Add(n.Entry.Entity.GetHashCode());
// Return true if node state is null
return true;
});
} The reason for my own |
// if outputDir is a subfolder of projectDir, then use each subfolder as a subnamespace | ||
// --output-dir $(projectFolder)/A/B/C | ||
// => "namespace $(rootnamespace).A.B.C" | ||
private string SubnamespaceFromOutputPath(string projectDir, string outputDir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these args converted to full path specification rather than relative paths?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to do a bit verification in this area before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
projectDir
is. outputDir
is as it was entered by the user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will normalize outputDir here.
/// <summary> | ||
/// Represents the files added for a model. | ||
/// </summary> | ||
public class ModelFiles |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we review these names before release?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. We'll cover in API review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree the tests could use a bit more cleanup. I'll address as part of #9111 |
@tonysneed For the not stopping on state set thing, we have an issue to fix this: #8226. It's good additional feedback that you would use this. About the code you posted, is there a reason not to resolve IEntityEntryGraphIterator from the context D.I. rather than newing it up explicitly? For example, (I'm asking these questions so as to determine if it is best just to make the service public or also the default implementation of the service. Generally we only make the default implementation public if it is expected that it act as a base class for customized implementations.) |
I'll comment over there for clarification.
It didn't dawn on me I could use the context as a service locator. I'll refactor the code to do that. It would be nice to have |
@tonysneed Thanks. Filed #10540 to track making IEntityEntryGraphIterator public. |
This exposes the entry point into the Reverse Engineer functionality (IReverseEngineerScaffolder); the contract for code generators (IModelCodeGenerator); and the service for selecting a code generator (IModelCodeGeneratorSelector). It also adds extension methods for adding our design-time services to an IServiceCollection. (fixes #9339) This cleans up some other DI contracts too.
This exposes the entry point into the Reverse Engineer functionality (
IReverseEngineerScaffolder
); the contract for code generators (IModelCodeGenerator
); and the service for selecting a code generator (IModelCodeGeneratorSelector
).It also adds extension methods for adding our design-time services to an
IServiceCollection
. (fixes #9339) You can use them like this:This cleans up some other DI contracts too.
cc @dazinator @ErikEJ @tonysneed