-
Notifications
You must be signed in to change notification settings - Fork 200
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
Flow RootNamespace from MsBuild #243
Conversation
@@ -125,7 +125,7 @@ internal async Task OnProjectChanged(IProjectVersionedValue<IProjectSubscription | |||
} | |||
|
|||
var configuration = FallbackRazorConfiguration.SelectConfiguration(version); | |||
var hostProject = new HostProject(CommonServices.UnconfiguredProject.FullPath, configuration); | |||
var hostProject = new HostProject(CommonServices.UnconfiguredProject.FullPath, configuration, rootNamespace: null); |
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'm not setting RootNamespace
here. I assumed we don't care about RootNamespace
in unconfigured project case.
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.
What's the user-visible behavior of that?
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.
The design time code gen will be generated with namespace __GeneratedComponent
instead of the RootNamespace. So intellisense for all components will be available regardless of the folder structure. What I am not sure of is in what cases FallbackRazorConfiguration
be used for Component apps?
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.
Only time this will ever impact components is if something is severely misconfigured in a users app and we can't determine what type of project it is. IMO not something we should worry about because this is a severe error case.
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.
Yeah, I think this is OK.
@@ -464,6 +464,7 @@ internal void OnDocumentStructureChanged(object state) | |||
|
|||
private void ConfigureProjectEngine(RazorProjectEngineBuilder builder) | |||
{ | |||
builder.SetRootNamespace(_documentTracker.ProjectSnapshot.RootNamespace); |
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.
It's possible the snapshot is null depending on how quick everything instantiates. You'll need to handle the situation when you can't resolve the root namespace here. For instance, in the TagHelper case below the document tracker just returns null
where as this will null ref
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.
Also note, if the snapshot is null
, when it populates everything will be reconfigured so there'd only be a slight lapse in a user having an unconfigured root namespace.
@@ -125,7 +125,7 @@ internal async Task OnProjectChanged(IProjectVersionedValue<IProjectSubscription | |||
} | |||
|
|||
var configuration = FallbackRazorConfiguration.SelectConfiguration(version); | |||
var hostProject = new HostProject(CommonServices.UnconfiguredProject.FullPath, configuration); | |||
var hostProject = new HostProject(CommonServices.UnconfiguredProject.FullPath, configuration, rootNamespace: null); |
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.
Only time this will ever impact components is if something is severely misconfigured in a users app and we can't determine what type of project it is. IMO not something we should worry about because this is a severe error case.
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.
This is awesome! Let's hold off on merging this to master because it can't go into preview 4 of ASP.NET Core.
If you want, feel free to set up a long-lived branch where you can do this and other preview5 work and merge there.
012b2ac
to
2fc55b8
Compare
I've created |
- Flow Root namespace through in command line builds - Flow Root namespace through in design time builds - Feedback
2fc55b8
to
5632cb1
Compare
uhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh Ok. I hope that doesn't cause trouble when we create the actual one. AZDO doesn't let us delete branches that have releases. |
Fixes dotnet/aspnetcore#5106
RootNamespace
for command line scenarios.RootNamespace
throughRazorCodeGenerationOptions
DefaultRazorProjectHost
to bring inRootNamespace
from MsBuild for design time scenarios.RootNamespace
throughHostProject
andProjectSnapshot