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

Add support for EnableRequestDelegateGenerator flag #29982

Merged
merged 13 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"tools": {
"dotnet": "8.0.100-alpha.1.22579.5",
"dotnet": "8.0.100-alpha.1.23067.5",
"runtimes": {
"dotnet": [
"$(VSRedistCommonNetCoreSharedFrameworkx6480PackageVersion)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ private void WriteETag(HttpContext context)
return string.Format(CultureInfo.InvariantCulture, "W/\"{0}{1}\"", EtagDiscriminator, Deltas[^1].SequenceId);
}

private void AppendDeltas(UpdateDelta[] updateDeltas)
private void AppendDeltas(UpdateDelta[]? updateDeltas)
{
if (updateDeltas.Length == 0)
if (updateDeltas == null || updateDeltas.Length == 0)
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- Intentionally pinned. This feature is supported in projects targeting 3.1 or newer.-->
<TargetFramework>netcoreapp3.1</TargetFramework>
<!-- Intentionally pinned. This feature is supported in projects targeting 6.0 or newer.-->
<TargetFramework>net6.0</TargetFramework>
<StrongNameKeyId>MicrosoftAspNetCore</StrongNameKeyId>

<IsPackable>false</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Microsoft.DotNet.Build.Tasks
/// and then update the stage 0 back.
///
/// Override NETCoreSdkVersion to stage 0 sdk version like 6.0.100-dev
///
///
/// Use a task to override since it was generated as a string literal replace anyway.
/// And using C# can have better error when anything goes wrong.
/// </summary>
Expand Down Expand Up @@ -133,24 +133,6 @@ void CheckAndReplaceAttribute(XAttribute attribute)
CheckAndReplaceAttribute(itemGroup
.Elements(ns + "KnownRuntimePack").First().Attribute("LatestRuntimeFrameworkVersion"));

// TODO: remove this once we're using an SDK that contains KnownILLinkPack: https://github.com/dotnet/installer/pull/15106
{
itemGroup.Add(new XElement(ns + "KnownILLinkPack",
new XAttribute("Include", "Microsoft.NET.ILLink.Tasks"),
new XAttribute("TargetFramework", "net8.0"),
new XAttribute("ILLinkPackVersion", microsoftNETILLinkTasksPackageVersion)));

// Use 7.0 linker when targeting supported RIDS <= net7.0.
var net70Version = "7.0.100-1.22579.2";

foreach (var tfm in new[] { "net7.0", "net6.0", "net5.0", "netcoreapp3.1", "netcoreapp3.0" }) {
itemGroup.Add(new XElement(ns + "KnownILLinkPack",
new XAttribute("Include", "Microsoft.NET.ILLink.Tasks"),
new XAttribute("TargetFramework", tfm),
new XAttribute("ILLinkPackVersion", net70Version)));
}
}

return projectXml.ToString();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(ResolverTargetFramework);net472;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>$(ResolverTargetFramework);net472</TargetFrameworks>
<TargetFrameworks Condition=" '$([MSBuild]::IsOSPlatform(`Windows`))' == 'false' ">$(ResolverTargetFramework)</TargetFrameworks>

<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down
4 changes: 2 additions & 2 deletions src/Tests/HelixTasks/HelixTasks.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net472</TargetFrameworks>
<TargetFrameworks Condition=" '$([MSBuild]::IsOSPlatform(`Windows`))' == 'false' ">netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net6.0;net472</TargetFrameworks>
<TargetFrameworks Condition=" '$([MSBuild]::IsOSPlatform(`Windows`))' == 'false' ">net6.0</TargetFrameworks>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<RootNamespace>Microsoft.DotNet.SDK.Build.Helix</RootNamespace>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,41 @@ public GivenThatWeWantToUseAnalyzers(ITestOutputHelper log) : base(log)
{
}

[Theory]
[InlineData("WebApp", false)]
[InlineData("WebApp", true)]
[InlineData("WebApp", null)]
public void It_resolves_requestdelegategenerator_correctly(string testAssetName, bool? isEnabled)
{
var asset = _testAssetsManager
.CopyTestAsset(testAssetName, identifier: isEnabled.ToString())
.WithSource()
.WithProjectChanges(project =>
{
if (isEnabled != null)
{
var ns = project.Root.Name.Namespace;
project.Root.Add(new XElement(ns + "PropertyGroup", new XElement("EnableRequestDelegateGenerator", isEnabled)));
}
});

var command = new GetValuesCommand(
Log,
asset.Path,
ToolsetInfo.CurrentTargetFramework,
"Analyzer",
GetValuesCommand.ValueType.Item);

command
.WithWorkingDirectory(asset.Path)
.Execute()
.Should().Pass();

var analyzers = command.GetValues();

Assert.Equal(isEnabled ?? false, analyzers.Any(analyzer => analyzer.Contains("Microsoft.AspNetCore.Http.Generators.dll")));
}

[Theory]
[InlineData("C#", "AppWithLibrary")]
[InlineData("VB", "AppWithLibraryVB")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
angular
api
blazorserver
blazorserver-empty
blazorwasm
Expand Down Expand Up @@ -55,4 +56,4 @@ install
list
search
uninstall
update
update
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@ Usage:
dotnet new TestAssets.PostActions.RunScript.Basic [options] [template options]

Options:
-n, --name <name> The name for the output being created. If no name is specified, the name of the output directory is used.
-n, --name <name> The name for the output being created. If no
Copy link
Member

Choose a reason for hiding this comment

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

Is this change supposed to change width of output?
this looks suspicious

Copy link
Contributor

Choose a reason for hiding this comment

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

src/Tests/dotnet-new.Tests/Approvals/DotnetNewHelpTests.CanShowHelpForTemplate_MatchOnLanguage.verified.txt also changed from -f, --framework <net6.0|net7.0|net8.0> to -f, --framework <choice>, i.e. it's not merely a matter of width.

Copy link
Member

Choose a reason for hiding this comment

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

In this example it's just width, and it is a concern.

Copy link
Member Author

Choose a reason for hiding this comment

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

There's a fairly chunky delta between the SDK this PR updates to and the one that we were previously targeting so I'm not sure what exactly caused this change.

I will say that enforcing a consistent line width on the console output seemed like a sensible bug fix to me.

Where is the repo that these code changes are sourced from?

Copy link
Member

Choose a reason for hiding this comment

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

This may be a change in System.CommandLine. @baronfel

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmm, I think there might be an error on my part here. The whitespace inconsistencies replicate on my local machine (where I produced the snapshots), but it looks like the tests on the build machines emit outputs without a wrapped width.

Is there a chance there is an option on my local machine that causes this behavior?

name is specified, the name of the output
directory is used.
-o, --output <output> Location to place the generated output.
--dry-run Displays a summary of what would happen if the given command line were run if it would result in a template creation.
--force Forces content to be generated even if it would change existing files.
--no-update-check Disables checking for the template package updates when instantiating a template.
--project <project> The project that should be used for context evaluation.
--allow-scripts <No|Prompt|Yes> Specifies if post action scripts should run. [default: Prompt]
--dry-run Displays a summary of what would happen if
the given command line were run if it would
result in a template creation.
--force Forces content to be generated even if it
would change existing files.
--no-update-check Disables checking for the template package
updates when instantiating a template.
--project <project> The project that should be used for context
evaluation.
--allow-scripts <No|Prompt|Yes> Specifies if post action scripts should run.
[default: Prompt]

Template options:
(No options)
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ Usage:
dotnet new basic [options] [template options]

Options:
-n, --name <name> The name for the output being created. If no name is specified, the name of the output directory is used.
-n, --name <name> The name for the output being created. If no name is
specified, the name of the output directory is used.
-o, --output <output> Location to place the generated output.
--dry-run Displays a summary of what would happen if the given command line were run if it would result in a template creation.
--force Forces content to be generated even if it would change existing files.
--no-update-check Disables checking for the template package updates when instantiating a template.
--project <project> The project that should be used for context evaluation.
--dry-run Displays a summary of what would happen if the given
command line were run if it would result in a
template creation.
--force Forces content to be generated even if it would
change existing files.
--no-update-check Disables checking for the template package updates
when instantiating a template.
--project <project> The project that should be used for context
evaluation.
-lang, --language <C#> Specifies the template language to instantiate.
--type <item> Specifies the template type to instantiate.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ Usage:
dotnet new basic2 [options] [template options]

Options:
-n, --name <name> The name for the output being created. If no name is specified, the name of the output directory is used.
-n, --name <name> The name for the output being created. If no name is
specified, the name of the output directory is used.
-o, --output <output> Location to place the generated output.
--dry-run Displays a summary of what would happen if the given command line were run if it would result in a template creation.
--force Forces content to be generated even if it would change existing files.
--no-update-check Disables checking for the template package updates when instantiating a template.
--project <project> The project that should be used for context evaluation.
--dry-run Displays a summary of what would happen if the given
command line were run if it would result in a
template creation.
--force Forces content to be generated even if it would
change existing files.
--no-update-check Disables checking for the template package updates
when instantiating a template.
--project <project> The project that should be used for context
evaluation.
-lang, --language <C#> Specifies the template language to instantiate.
--type <item> Specifies the template type to instantiate.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ Usage:
dotnet new TestAssets.TemplateWithConditionalParameters [options] [template options]

Options:
-n, --name <name> The name for the output being created. If no name is specified, the name of the output directory is used.
-n, --name <name> The name for the output being created. If no name is
specified, the name of the output directory is used.
-o, --output <output> Location to place the generated output.
--dry-run Displays a summary of what would happen if the given command line were run if it would result in a template creation.
--force Forces content to be generated even if it would change existing files.
--no-update-check Disables checking for the template package updates when instantiating a template.
--dry-run Displays a summary of what would happen if the given
command line were run if it would result in a template
creation.
--force Forces content to be generated even if it would change
existing files.
--no-update-check Disables checking for the template package updates
when instantiating a template.
--project <project> The project that should be used for context evaluation.

Template options:
Expand All @@ -23,4 +28,4 @@ Template options:
-A, --A_enabled Type: bool
Default: False
-B, --B_enabled Type: bool
Default: False
Default: False
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ Usage:
dotnet new console [options] [template options]

Options:
-n, --name <name> The name for the output being created. If no name is specified, the name of the output directory is used.
-n, --name <name> The name for the output being created. If no name is
specified, the name of the output directory is used.
-o, --output <output> Location to place the generated output.
--dry-run Displays a summary of what would happen if the given command line were run if it would result in a template creation.
--force Forces content to be generated even if it would change existing files.
--no-update-check Disables checking for the template package updates when instantiating a template.
--project <project> The project that should be used for context evaluation.
--dry-run Displays a summary of what would happen if the given
command line were run if it would result in a
template creation.
--force Forces content to be generated even if it would
change existing files.
--no-update-check Disables checking for the template package updates
when instantiating a template.
--project <project> The project that should be used for context
evaluation.
-lang, --language <C#> Specifies the template language to instantiate.
--type <project> Specifies the template type to instantiate.

Expand All @@ -20,12 +26,15 @@ Template options:
Type: choice
net7.0 Target net7.0
Default: net7.0
--langVersion <langVersion> Sets the LangVersion property in the created project file
--langVersion <langVersion> Sets the LangVersion property in the created
project file
Type: text
--no-restore If specified, skips the automatic restore of the project on create.
--no-restore If specified, skips the automatic restore of the
project on create.
Type: bool
Default: false
--use-program-main Whether to generate an explicit Program class and Main method instead of top-level statements.
--use-program-main Whether to generate an explicit Program class
and Main method instead of top-level statements.
Type: bool
Default: false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,32 @@ Usage:
dotnet new console [options] [template options]

Options:
-n, --name <name> The name for the output being created. If no name is specified, the name of the output directory is used.
-n, --name <name> The name for the output being created. If no name is
specified, the name of the output directory is used.
-o, --output <output> Location to place the generated output.
--dry-run Displays a summary of what would happen if the given command line were run if it would result in a template creation.
--force Forces content to be generated even if it would change existing files.
--no-update-check Disables checking for the template package updates when instantiating a template.
--project <project> The project that should be used for context evaluation.
--dry-run Displays a summary of what would happen if the given
command line were run if it would result in a
template creation.
--force Forces content to be generated even if it would
change existing files.
--no-update-check Disables checking for the template package updates
when instantiating a template.
--project <project> The project that should be used for context
evaluation.
-lang, --language <F#> Specifies the template language to instantiate.
--type <project> Specifies the template type to instantiate.

Template options:
-f, --framework <net6.0|net7.0|net8.0> The target framework for the project.
Type: choice
net8.0 Target net8.0
net7.0 Target net7.0
net6.0 Target net6.0
Default: net8.0
--no-restore If specified, skips the automatic restore of the project on create.
Type: bool
Default: false
-f, --framework <choice> The target framework for the project.
Type: choice
net8.0 Target net8.0
net7.0 Target net7.0
net6.0 Target net6.0
Default: net8.0
--no-restore If specified, skips the automatic restore of the
project on create.
Type: bool
Default: false

To see help for other template languages (C#, VB), use --language option:
dotnet new console -h --language C#
Loading