-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Update "empty" web project templates to use minimal hostinng and routing #32003
Conversation
Hello human! Please make sure you've included the Shiproom Template in a comment or (preferably) the PR description. Also, make sure this PR is not marked as a draft and is ready-to-merge. |
if app.Environment.IsDevelopment() then | ||
app.UseDeveloperExceptionPage() |> ignore | ||
|
||
app.MapGet("/", Func<string>(fun () -> "Hello World!")) |> ignore |
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.
Is the explicit Func
construction needed here? Might be able to elide 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.
It seems like it. Without it, I see the following error:
Program.fs(12,34): error FS0001: This expression was expected to have type↔ 'AspNetCore.Http.HttpContext' ↔but here has type↔ 'unit' [C:\dev\dotnet\aspnetcore\src\Http\samples\MinimalSampleFSharp\MinimalSampleFSharp.fsproj]
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 the F# language feature we wanted
} | ||
|
||
app.MapGet("/", (Func<string>)(() => "Hello World!")); |
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 don't like that we still have to explicitly cast to Func<string>
until we can consume the changes in dotnet/roslyn#52448, but I still think this is already a big improvement overall.
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.
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 bits should be lining up for preview 4 to allow this cast to be removed.
src/ProjectTemplates/Web.ProjectTemplates/content/EmptyWeb-CSharp/Program.cs
Show resolved
Hide resolved
|
||
app.MapGet("/", (Func<string>)(() => "Hello World!")); | ||
|
||
await app.RunAsync(); |
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.
Program+Startup before: 66 lines
after: 14 lines.
It's a lot emptier than it used to be 😁.
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.
Make the "empty" project, "really empty"
Go..Go..Go SingleFile 😅😅 |
This plus making Kestrel the default server brings a smile to my face 😄. True modernization. |
3208b1f
to
a295dc3
Compare
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
a295dc3
to
cc57bb8
Compare
@@ -1,9 +1,9 @@ | |||
{ | |||
"sdk": { | |||
"version": "6.0.100-preview.4.21216.8" | |||
"version": "6.0.100-preview.4.21222.6" |
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.
Heads up @dotnet/aspnet-build. I'm updating the preview4 branch SDK version so we can consume the WebApplication
related types from our new "empty" web project templtates.
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.
If these new types come from dotnet/aspnetcore, something is very wrong if they aren't just showing up. Fine if, on the other hand, the main thing we need is @DavidKarlas' dotnet/templating#3078 fix.
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 needed to update this to get EmptyWebTemplateTest.EmptyWebTemplateCSharp EmptyWebTemplateTest.EmptyWebTemplateFSharp passing locally and on helix, so there's definitely room for improvement here. Not sure how common it is to update the templates to use very-newly-added APIs.
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.
My understanding of the fix to templating is that the regression broke the custom hive logic we were using to make our template tests find our updated templates, so that's why stefan had to update the sdk. The templating workaround PR should also fix the tests I would assume
👀 |
Latest `dotnet new` doesn't work with relative path for `--debug:custom-hive`... Hence make it absolute Also switched to using `--debug:disable-sdk-templates` to avoid potential conflict between SDK and tests installed templates.
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.
Looks fine from a build perspective
@@ -1,9 +1,9 @@ | |||
{ | |||
"sdk": { | |||
"version": "6.0.100-preview.4.21216.8" | |||
"version": "6.0.100-preview.4.21222.6" |
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.
If these new types come from dotnet/aspnetcore, something is very wrong if they aren't just showing up. Fine if, on the other hand, the main thing we need is @DavidKarlas' dotnet/templating#3078 fix.
Hello human! Please make sure you've included the Shiproom Template in a comment or (preferably) the PR description. Also, make sure this PR is not marked as a draft and is ready-to-merge. |
Description
Update the "Empty" project templates (used by
dotnet new empty
/dotnet new web
and VS) to use the new "minimal hosting" APIs that were just merged minutes ago for preview4 by #31825.Customer Impact
We're looking to collect feedback on our new "minimal hosting" and "minimal routing" API which we will present at BUILD. This updates the "empty" web project templates to make it easier to customer trying preview4 after BUILD to test out these new APIs.
Regression?
The template behaves as it did before. It does not include all the
usings
/opens
for unused namespace. That might change based on code review feedback.Risk
This is a pretty big change to the empty web project template. It might confuse people. It is just a template change though.
@glennc looked up some usage statistics and this is one of the less popular than the MVC and API templates.
Verification
Packaging changes reviewed?
Addresses #30665