Skip to content

Commit fc26337

Browse files
committed
Merge branch 'main' into fix-51646
2 parents c3c4368 + d498fbc commit fc26337

File tree

15 files changed

+578
-296
lines changed

15 files changed

+578
-296
lines changed

eng/Build.props

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,12 @@
254254
<InstallerProject Include="$(RepoRoot)src\Installers\Windows\WindowsHostingBundle\WindowsHostingBundle.wixproj" AdditionalProperties="Platform=x86" />
255255
</ItemGroup>
256256

257-
<!-- In a vertical build, only build the MSIs for the current vertical in the first pass and build the hosting bundle in the second pass -->
257+
<!--
258+
In a vertical build, only build the MSIs for the current vertical that aren't used in the hosting bundle in the first pass
259+
and build the hosting bundle and its dependencies in the second pass.
260+
-->
258261
<ItemGroup Condition="'$(DotNetBuild)' == 'true' and ('$(DotNetBuildPass)' == '' or '$(DotNetBuildPass)' == '1') and '$(_BuildWindowsInstallers)' == 'true'">
259-
<!-- Build the ANCM custom action -->
260-
<InstallerProject Include="$(RepoRoot)src\Installers\Windows\AspNetCoreModule-Setup\CustomAction\aspnetcoreCA.vcxproj" AdditionalProperties="Platform=$(_VcxTargetPlatform)" />
261-
<!-- Build the ANCM msis -->
262262
<InstallerProject Include="$(RepoRoot)src\Installers\Windows\AspNetCoreModule-Setup\ANCMIISExpressV2\AncmIISExpressV2.wixproj" AdditionalProperties="Platform=$(TargetArchitecture)" />
263-
<InstallerProject Include="$(RepoRoot)src\Installers\Windows\AspNetCoreModule-Setup\ANCMV2\ANCMV2.wixproj" AdditionalProperties="Platform=$(TargetArchitecture)" />
264263
</ItemGroup>
265264

266265
<ItemGroup>

eng/Signing.props

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@
6363
<FileExtensionSignInfo Include=".vsix" CertificateName="VsixSHA2" />
6464
<FileExtensionSignInfo Include=".zip" CertificateName="None" />
6565
<FileExtensionSignInfo Include=".cab" CertificateName="None" />
66-
<!-- If doing post build sign, explicitly give MSIs a cert. If doing in build signing,
67-
this is handled by the wix targets, and .msi should be "None" -->
68-
<FileExtensionSignInfo Include=".msi" CertificateName="MicrosoftDotNet500" Condition="'$(PostBuildSign)' == 'true'" />
69-
<FileExtensionSignInfo Include=".msi" CertificateName="None" Condition="'$(PostBuildSign)' != 'true'" />
66+
<FileExtensionSignInfo Include=".msi" CertificateName="MicrosoftDotNet500" />
7067

7168
<!-- Native .dll's. These don't have a public key token, but are from Microsoft and should be signed. -->
7269
<FileSignInfo Include="aspnetcore.dll" CertificateName="MicrosoftDotNet500" />

eng/Version.Details.xml

Lines changed: 180 additions & 180 deletions
Large diffs are not rendered by default.

eng/Versions.props

Lines changed: 87 additions & 87 deletions
Large diffs are not rendered by default.

eng/common/sdk-task.sh

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#!/usr/bin/env bash
2+
3+
show_usage() {
4+
echo "Common settings:"
5+
echo " --task <value> Name of Arcade task (name of a project in SdkTasks directory of the Arcade SDK package)"
6+
echo " --restore Restore dependencies"
7+
echo " --verbosity <value> Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]"
8+
echo " --help Print help and exit"
9+
echo ""
10+
echo "Command line arguments not listed above are passed thru to msbuild."
11+
}
12+
13+
source="${BASH_SOURCE[0]}"
14+
15+
# resolve $source until the file is no longer a symlink
16+
while [[ -h "$source" ]]; do
17+
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
18+
source="$(readlink "$source")"
19+
# if $source was a relative symlink, we need to resolve it relative to the path where the
20+
# symlink file was located
21+
[[ $source != /* ]] && source="$scriptroot/$source"
22+
done
23+
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
24+
25+
Build() {
26+
local target=$1
27+
local log_suffix=""
28+
[[ "$target" != "Execute" ]] && log_suffix=".$target"
29+
local log="$log_dir/$task$log_suffix.binlog"
30+
local output_path="$toolset_dir/$task/"
31+
32+
MSBuild "$taskProject" \
33+
/bl:"$log" \
34+
/t:"$target" \
35+
/p:Configuration="$configuration" \
36+
/p:RepoRoot="$repo_root" \
37+
/p:BaseIntermediateOutputPath="$output_path" \
38+
/v:"$verbosity" \
39+
$properties
40+
}
41+
42+
configuration="Debug"
43+
verbosity="minimal"
44+
restore=false
45+
help=false
46+
properties=''
47+
48+
while (($# > 0)); do
49+
lowerI="$(echo $1 | tr "[:upper:]" "[:lower:]")"
50+
case $lowerI in
51+
--task)
52+
task=$2
53+
shift 2
54+
;;
55+
--restore)
56+
restore=true
57+
shift 1
58+
;;
59+
--verbosity)
60+
verbosity=$2
61+
shift 2
62+
;;
63+
--help)
64+
help=true
65+
shift 1
66+
;;
67+
*)
68+
properties="$properties $1"
69+
shift 1
70+
;;
71+
esac
72+
done
73+
74+
ci=true
75+
binaryLog=true
76+
warnAsError=true
77+
78+
if $help; then
79+
show_usage
80+
exit 0
81+
fi
82+
83+
. "$scriptroot/tools.sh"
84+
InitializeToolset
85+
86+
if [[ -z "$task" ]]; then
87+
Write-PipelineTelemetryError -Category 'Task' -Name 'MissingTask' -Message "Missing required parameter '-task <value>'"
88+
ExitWithExitCode 1
89+
fi
90+
91+
taskProject=$(GetSdkTaskProject "$task")
92+
if [[ ! -e "$taskProject" ]]; then
93+
Write-PipelineTelemetryError -Category 'Task' -Name 'UnknownTask' -Message "Unknown task: $task"
94+
ExitWithExitCode 1
95+
fi
96+
97+
if $restore; then
98+
Build "Restore"
99+
fi
100+
101+
Build "Execute"
102+
103+
104+
ExitWithExitCode 0

eng/common/tools.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,12 @@ function GetDarc {
528528
"$eng_root/common/darc-init.sh" --toolpath "$darc_path" $version
529529
}
530530

531+
# Returns a full path to an Arcade SDK task project file.
532+
function GetSdkTaskProject {
533+
taskName=$1
534+
echo "$(dirname $_InitializeToolset)/SdkTasks/$taskName.proj"
535+
}
536+
531537
ResolvePath "${BASH_SOURCE[0]}"
532538
_script_dir=`dirname "$_ResolvePath"`
533539

global.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
"jdk": "latest"
2828
},
2929
"msbuild-sdks": {
30-
"Microsoft.DotNet.Arcade.Sdk": "10.0.0-beta.25080.7",
31-
"Microsoft.DotNet.Helix.Sdk": "10.0.0-beta.25080.7",
32-
"Microsoft.DotNet.SharedFramework.Sdk": "10.0.0-beta.25080.7",
30+
"Microsoft.DotNet.Arcade.Sdk": "10.0.0-beta.25106.4",
31+
"Microsoft.DotNet.Helix.Sdk": "10.0.0-beta.25106.4",
32+
"Microsoft.DotNet.SharedFramework.Sdk": "10.0.0-beta.25106.4",
3333
"Microsoft.Build.NoTargets": "3.7.0",
3434
"Microsoft.Build.Traversal": "3.4.0"
3535
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
#nullable enable
2+
virtual Microsoft.AspNetCore.Components.Routing.NavLink.ShouldMatch(string! currentUriAbsolute) -> bool

src/Components/Web/src/Routing/NavLink.cs

Lines changed: 76 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System.Diagnostics;
54
using System.Globalization;
65
using Microsoft.AspNetCore.Components.Rendering;
76

@@ -13,6 +12,9 @@ namespace Microsoft.AspNetCore.Components.Routing;
1312
/// </summary>
1413
public class NavLink : ComponentBase, IDisposable
1514
{
15+
private const string DisableMatchAllIgnoresLeftUriPartSwitchKey = "Microsoft.AspNetCore.Components.Routing.NavLink.DisableMatchAllIgnoresLeftUriPart";
16+
private static readonly bool _disableMatchAllIgnoresLeftUriPart = AppContext.TryGetSwitch(DisableMatchAllIgnoresLeftUriPartSwitchKey, out var switchValue) && switchValue;
17+
1618
private const string DefaultActiveClass = "active";
1719

1820
private bool _isActive;
@@ -106,14 +108,21 @@ private void OnLocationChanged(object? sender, LocationChangedEventArgs args)
106108
}
107109
}
108110

109-
private bool ShouldMatch(string currentUriAbsolute)
111+
/// <summary>
112+
/// Determines whether the current URI should match the link.
113+
/// </summary>
114+
/// <param name="currentUriAbsolute">The absolute URI of the current location.</param>
115+
/// <returns>True if the link should be highlighted as active; otherwise, false.</returns>
116+
protected virtual bool ShouldMatch(string currentUriAbsolute)
110117
{
111118
if (_hrefAbsolute == null)
112119
{
113120
return false;
114121
}
115122

116-
if (EqualsHrefExactlyOrIfTrailingSlashAdded(currentUriAbsolute))
123+
var currentUriAbsoluteSpan = currentUriAbsolute.AsSpan();
124+
var hrefAbsoluteSpan = _hrefAbsolute.AsSpan();
125+
if (EqualsHrefExactlyOrIfTrailingSlashAdded(currentUriAbsoluteSpan, hrefAbsoluteSpan))
117126
{
118127
return true;
119128
}
@@ -124,19 +133,62 @@ private bool ShouldMatch(string currentUriAbsolute)
124133
return true;
125134
}
126135

127-
return false;
136+
if (_disableMatchAllIgnoresLeftUriPart || Match != NavLinkMatch.All)
137+
{
138+
return false;
139+
}
140+
141+
var uriWithoutQueryAndFragment = GetUriIgnoreQueryAndFragment(currentUriAbsoluteSpan);
142+
if (EqualsHrefExactlyOrIfTrailingSlashAdded(uriWithoutQueryAndFragment, hrefAbsoluteSpan))
143+
{
144+
return true;
145+
}
146+
hrefAbsoluteSpan = GetUriIgnoreQueryAndFragment(hrefAbsoluteSpan);
147+
return EqualsHrefExactlyOrIfTrailingSlashAdded(uriWithoutQueryAndFragment, hrefAbsoluteSpan);
128148
}
129149

130-
private bool EqualsHrefExactlyOrIfTrailingSlashAdded(string currentUriAbsolute)
150+
private static ReadOnlySpan<char> GetUriIgnoreQueryAndFragment(ReadOnlySpan<char> uri)
131151
{
132-
Debug.Assert(_hrefAbsolute != null);
152+
if (uri.IsEmpty)
153+
{
154+
return ReadOnlySpan<char>.Empty;
155+
}
133156

134-
if (string.Equals(currentUriAbsolute, _hrefAbsolute, StringComparison.OrdinalIgnoreCase))
157+
var queryStartPos = uri.IndexOf('?');
158+
var fragmentStartPos = uri.IndexOf('#');
159+
160+
if (queryStartPos < 0 && fragmentStartPos < 0)
161+
{
162+
return uri;
163+
}
164+
165+
int minPos;
166+
if (queryStartPos < 0)
167+
{
168+
minPos = fragmentStartPos;
169+
}
170+
else if (fragmentStartPos < 0)
171+
{
172+
minPos = queryStartPos;
173+
}
174+
else
175+
{
176+
minPos = Math.Min(queryStartPos, fragmentStartPos);
177+
}
178+
179+
return uri.Slice(0, minPos);
180+
}
181+
182+
private static readonly CaseInsensitiveCharComparer CaseInsensitiveComparer = new CaseInsensitiveCharComparer();
183+
184+
private static bool EqualsHrefExactlyOrIfTrailingSlashAdded(ReadOnlySpan<char> currentUriAbsolute, ReadOnlySpan<char> hrefAbsolute)
185+
{
186+
if (currentUriAbsolute.SequenceEqual(hrefAbsolute, CaseInsensitiveComparer))
135187
{
136188
return true;
137189
}
138190

139-
if (currentUriAbsolute.Length == _hrefAbsolute.Length - 1)
191+
if (currentUriAbsolute.Length == hrefAbsolute.Length - 1)
140192
{
141193
// Special case: highlight links to http://host/path/ even if you're
142194
// at http://host/path (with no trailing slash)
@@ -146,8 +198,8 @@ private bool EqualsHrefExactlyOrIfTrailingSlashAdded(string currentUriAbsolute)
146198
// which in turn is because it's common for servers to return the same page
147199
// for http://host/vdir as they do for host://host/vdir/ as it's no
148200
// good to display a blank page in that case.
149-
if (_hrefAbsolute[_hrefAbsolute.Length - 1] == '/'
150-
&& _hrefAbsolute.StartsWith(currentUriAbsolute, StringComparison.OrdinalIgnoreCase))
201+
if (hrefAbsolute[hrefAbsolute.Length - 1] == '/' &&
202+
currentUriAbsolute.SequenceEqual(hrefAbsolute.Slice(0, hrefAbsolute.Length - 1), CaseInsensitiveComparer))
151203
{
152204
return true;
153205
}
@@ -199,7 +251,7 @@ private static bool IsStrictlyPrefixWithSeparator(string value, string prefix)
199251

200252
private static bool IsUnreservedCharacter(char c)
201253
{
202-
// Checks whether it is an unreserved character according to
254+
// Checks whether it is an unreserved character according to
203255
// https://datatracker.ietf.org/doc/html/rfc3986#section-2.3
204256
// Those are characters that are allowed in a URI but do not have a reserved
205257
// purpose (e.g. they do not separate the components of the URI)
@@ -209,4 +261,17 @@ private static bool IsUnreservedCharacter(char c)
209261
c == '_' ||
210262
c == '~';
211263
}
264+
265+
private class CaseInsensitiveCharComparer : IEqualityComparer<char>
266+
{
267+
public bool Equals(char x, char y)
268+
{
269+
return char.ToLowerInvariant(x) == char.ToLowerInvariant(y);
270+
}
271+
272+
public int GetHashCode(char obj)
273+
{
274+
return char.ToLowerInvariant(obj).GetHashCode();
275+
}
276+
}
212277
}

0 commit comments

Comments
 (0)