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 7 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
@@ -1,43 +1,44 @@
Warning: use of 'dotnet new --list' is deprecated. Use 'dotnet new list' instead.
For more information, run:
For more information, run:
dotnet new list -h

These templates matched your input:
These templates matched your input:

Template Name Short Name Language Tags
Template Name Short Name Language Tags
-------------------------------------------- -------------------------- ---------- --------------------------------
ASP.NET Core Empty web [C#],F# Web/Empty
ASP.NET Core gRPC Service grpc [C#] Web/gRPC
ASP.NET Core Web API webapi [C#],F# Web/WebAPI
ASP.NET Core Web App webapp,razor [C#] Web/MVC/Razor Pages
ASP.NET Core Web App (Model-View-Controller) mvc [C#],F# Web/MVC
ASP.NET Core with Angular angular [C#] Web/MVC/SPA
ASP.NET Core with React.js react [C#] Web/MVC/SPA
Blazor Server App blazorserver [C#] Web/Blazor
Blazor Server App Empty blazorserver-empty [C#] Web/Blazor/Empty
Blazor WebAssembly App blazorwasm [C#] Web/Blazor/WebAssembly/PWA
ASP.NET Core API api [C#] Web/API
ASP.NET Core Empty web [C#],F# Web/Empty
ASP.NET Core gRPC Service grpc [C#] Web/gRPC
ASP.NET Core Web API webapi [C#],F# Web/WebAPI
ASP.NET Core Web App webapp,razor [C#] Web/MVC/Razor Pages
ASP.NET Core Web App (Model-View-Controller) mvc [C#],F# Web/MVC
ASP.NET Core with Angular angular [C#] Web/MVC/SPA
ASP.NET Core with React.js react [C#] Web/MVC/SPA
Blazor Server App blazorserver [C#] Web/Blazor
Blazor Server App Empty blazorserver-empty [C#] Web/Blazor/Empty
Blazor WebAssembly App blazorwasm [C#] Web/Blazor/WebAssembly/PWA
Blazor WebAssembly App Empty blazorwasm-empty [C#] Web/Blazor/WebAssembly/PWA/Empty
Class Library classlib [C#],F#,VB Common/Library
Console App console [C#],F#,VB Common/Console
dotnet gitignore file gitignore,.gitignore Config
Dotnet local tool manifest file tool-manifest Config
EditorConfig file editorconfig,.editorconfig Config
global.json file globaljson,global.json Config
MSBuild Directory.Build.props file buildprops MSBuild/props
MSBuild Directory.Build.targets file buildtargets MSBuild/props
MSTest Playwright Test Project mstest-playwright [C#] Test/MSTest/Playwright
MSTest Test Project mstest [C#],F#,VB Test/MSTest
MVC ViewImports viewimports [C#] Web/ASP.NET
MVC ViewStart viewstart [C#] Web/ASP.NET
NuGet Config nugetconfig,nuget.config Config
NUnit 3 Test Item nunit-test [C#],F#,VB Test/NUnit
NUnit 3 Test Project nunit [C#],F#,VB Test/NUnit
NUnit Playwright Test Project nunit-playwright [C#] Test/NUnit/Playwright
Protocol Buffer File proto Web/gRPC
Razor Class Library razorclasslib [C#] Web/Razor/Library
Razor Component razorcomponent [C#] Web/ASP.NET
Razor Page page [C#] Web/ASP.NET
Solution File sln,solution Solution
Web Config webconfig Config
Worker Service worker [C#],F# Common/Worker/Web
xUnit Test Project xunit [C#],F#,VB Test/xUnit
Class Library classlib [C#],F#,VB Common/Library
Console App console [C#],F#,VB Common/Console
dotnet gitignore file gitignore,.gitignore Config
Dotnet local tool manifest file tool-manifest Config
EditorConfig file editorconfig,.editorconfig Config
global.json file globaljson,global.json Config
MSBuild Directory.Build.props file buildprops MSBuild/props
MSBuild Directory.Build.targets file buildtargets MSBuild/props
MSTest Playwright Test Project mstest-playwright [C#] Test/MSTest/Playwright
MSTest Test Project mstest [C#],F#,VB Test/MSTest
MVC ViewImports viewimports [C#] Web/ASP.NET
MVC ViewStart viewstart [C#] Web/ASP.NET
NuGet Config nugetconfig,nuget.config Config
NUnit 3 Test Item nunit-test [C#],F#,VB Test/NUnit
NUnit 3 Test Project nunit [C#],F#,VB Test/NUnit
NUnit Playwright Test Project nunit-playwright [C#] Test/NUnit/Playwright
Protocol Buffer File proto Web/gRPC
Razor Class Library razorclasslib [C#] Web/Razor/Library
Razor Component razorcomponent [C#] Web/ASP.NET
Razor Page page [C#] Web/ASP.NET
Solution File sln,solution Solution
Web Config webconfig Config
Worker Service worker [C#],F# Common/Worker/Web
xUnit Test Project xunit [C#],F#,VB Test/xUnit
Loading