Skip to content

Commit b486b58

Browse files
authored
Merge branch 'release/10.0.1xx' into darc-release/10.0.1xx-d089cb0f-fcc5-4d9f-82f8-6c23881f7ba3
2 parents d90795a + 0bab00a commit b486b58

File tree

28 files changed

+565
-152
lines changed

28 files changed

+565
-152
lines changed

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<PackageVersion Include="AwesomeAssertions" Version="$(AwesomeAssertionsVersion)" />
1010
<PackageVersion Include="BenchmarkDotNet" Version="$(BenchmarkDotNetPackageVersion)" />
1111
<PackageVersion Include="AwesomeAssertions.Json" Version="$(AwesomeAssertionsJsonVersion)" />
12+
<PackageVersion Include="MessagePack" Version="2.5.187" />
1213
<PackageVersion Include="MicroBuild.Plugins.SwixBuild.Dotnet" Version="1.1.87-gba258badda" />
1314
<PackageVersion Include="Microsoft.ApplicationInsights" Version="$(MicrosoftApplicationInsightsPackageVersion)" />
1415
<PackageVersion Include="Microsoft.AspNetCore.DeveloperCertificates.XPlat" Version="$(MicrosoftAspNetCoreDeveloperCertificatesXPlatPackageVersion)" />

src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,9 @@ Copyright (c) .NET Foundation. All rights reserved.
8888

8989
<ResolvePublishRelatedStaticWebAssetsDependsOn>
9090
$(ResolvePublishRelatedStaticWebAssetsDependsOn);
91-
_ReplaceFingerprintedBlazorJsForPublish
9291
</ResolvePublishRelatedStaticWebAssetsDependsOn>
9392
<ResolveCompressedFilesForPublishDependsOn>
9493
$(ResolveCompressedFilesForPublishDependsOn);
95-
_ReplaceFingerprintedBlazorJsForPublish
9694
</ResolveCompressedFilesForPublishDependsOn>
9795

9896
<GeneratePublishWasmBootJsonDependsOn>
@@ -159,65 +157,6 @@ Copyright (c) .NET Foundation. All rights reserved.
159157
</ItemGroup>
160158
</Target>
161159

162-
<Target Name="_ReplaceFingerprintedBlazorJsForPublish" DependsOnTargets="ProcessPublishFilesForWasm" Condition="'$(WasmBuildingForNestedPublish)' != 'true' and '$(BlazorFingerprintBlazorJs)' == 'true'">
163-
<PropertyGroup>
164-
<_BlazorJSFileNames>;@(_BlazorJSFile->'%(FileName)');</_BlazorJSFileNames>
165-
</PropertyGroup>
166-
<ItemGroup>
167-
<_BlazorJSJSStaticWebAsset Include="@(StaticWebAsset)" Condition="$(_BlazorJSFileNames.Contains(';%(FileName);')) and '%(Extension)' == '.js'" />
168-
<_BlazorJSPublishCandidate Include="%(_BlazorJSJSStaticWebAsset.RelativeDir)%(_BlazorJSJSStaticWebAsset.FileName).%(_BlazorJSJSStaticWebAsset.Fingerprint)%(_BlazorJSJSStaticWebAsset.Extension)" />
169-
<_BlazorJSPublishCandidate Remove="@(_BlazorJSPublishCandidate)" Condition="'%(Extension)' == '.map'" />
170-
<_BlazorJSPublishCandidate>
171-
<RelativePath>_framework/$([System.IO.Path]::GetFileNameWithoutExtension('%(Filename)'))%(Extension)</RelativePath>
172-
</_BlazorJSPublishCandidate>
173-
</ItemGroup>
174-
175-
<DefineStaticWebAssets
176-
CandidateAssets="@(_BlazorJSPublishCandidate)"
177-
FingerprintCandidates="true"
178-
FingerprintPatterns="@(_BlazorJSFingerprintPattern)"
179-
SourceId="$(PackageId)"
180-
SourceType="Computed"
181-
AssetKind="All"
182-
AssetMergeSource="$(StaticWebAssetMergeTarget)"
183-
AssetRole="Primary"
184-
AssetTraitName="WasmResource"
185-
AssetTraitValue="boot"
186-
CopyToOutputDirectory="Never"
187-
CopyToPublishDirectory="PreserveNewest"
188-
ContentRoot="%(_BlazorJSJSStaticWebAsset.ContentRoot)"
189-
BasePath="%(_BlazorJSJSStaticWebAsset.BasePath)"
190-
>
191-
<Output TaskParameter="Assets" ItemName="_BlazorJSJSPublishStaticWebAssets" />
192-
</DefineStaticWebAssets>
193-
<DefineStaticWebAssetEndpoints
194-
CandidateAssets="@(_BlazorJSJSPublishStaticWebAssets)"
195-
ExistingEndpoints="@(StaticWebAssetEndpoint)"
196-
ContentTypeMappings="@(StaticWebAssetContentTypeMapping)"
197-
>
198-
<Output TaskParameter="Endpoints" ItemName="_BlazorJSJSPublishStaticWebAssetsEndpoint" />
199-
</DefineStaticWebAssetEndpoints>
200-
<PropertyGroup>
201-
<_BlazorJSJSStaticWebAssetFullPath>@(_BlazorJSJSStaticWebAsset->'%(FullPath)')</_BlazorJSJSStaticWebAssetFullPath>
202-
</PropertyGroup>
203-
<ItemGroup>
204-
<_BlazorJSJSStaticWebAsset Include="@(StaticWebAsset)" Condition="'%(AssetTraitName)' == 'Content-Encoding' and '%(RelatedAsset)' == '$(_BlazorJSJSStaticWebAssetFullPath)'" />
205-
</ItemGroup>
206-
<FilterStaticWebAssetEndpoints Condition="'@(_BlazorJSJSStaticWebAsset)' != ''"
207-
Endpoints="@(StaticWebAssetEndpoint)"
208-
Assets="@(_BlazorJSJSStaticWebAsset)"
209-
Filters=""
210-
>
211-
<Output TaskParameter="FilteredEndpoints" ItemName="_BlazorJSEndpointsToRemove" />
212-
</FilterStaticWebAssetEndpoints>
213-
<ItemGroup>
214-
<StaticWebAsset Remove="@(_BlazorJSJSStaticWebAsset)" />
215-
<StaticWebAsset Include="@(_BlazorJSJSPublishStaticWebAssets)" />
216-
<StaticWebAssetEndpoint Remove="@(_BlazorJSEndpointsToRemove)" />
217-
<StaticWebAssetEndpoint Include="@(_BlazorJSJSPublishStaticWebAssetsEndpoint)" />
218-
</ItemGroup>
219-
</Target>
220-
221160
<!-- Just print a message here, static web assets takes care of all the copying -->
222161
<Target Name="_BlazorCopyFilesToOutputDirectory" AfterTargets="CopyFilesToOutputDirectory">
223162
<Message Importance="High" Text="$(MSBuildProjectName) (Blazor output) -&gt; $(TargetDir)wwwroot" Condition="'$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)'!='true'" />

src/Cli/dotnet/Commands/Test/MTP/TestApplication.cs

Lines changed: 60 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ internal sealed class TestApplication(
2020
TerminalTestReporter output,
2121
Action<CommandLineOptionMessages> onHelpRequested) : IDisposable
2222
{
23+
private readonly Lock _requestLock = new();
2324
private readonly BuildOptions _buildOptions = buildOptions;
2425
private readonly Action<CommandLineOptionMessages> _onHelpRequested = onHelpRequested;
2526
private readonly TestApplicationHandler _handler = new(output, module, testOptions);
@@ -199,63 +200,69 @@ private async Task WaitConnectionAsync(CancellationToken token)
199200

200201
private Task<IResponse> OnRequest(NamedPipeServer server, IRequest request)
201202
{
202-
try
203+
// We need to lock as we might be called concurrently when test app child processes all communicate with us.
204+
// For example, in a case of a sharding extension, we could get test result messages concurrently.
205+
// To be the most safe, we lock the whole OnRequest.
206+
lock (_requestLock)
203207
{
204-
switch (request)
208+
try
205209
{
206-
case HandshakeMessage handshakeMessage:
207-
_handshakes.Add(server, handshakeMessage);
208-
string negotiatedVersion = GetSupportedProtocolVersion(handshakeMessage);
209-
OnHandshakeMessage(handshakeMessage, negotiatedVersion.Length > 0);
210-
return Task.FromResult((IResponse)CreateHandshakeMessage(negotiatedVersion));
211-
212-
case CommandLineOptionMessages commandLineOptionMessages:
213-
OnCommandLineOptionMessages(commandLineOptionMessages);
214-
break;
215-
216-
case DiscoveredTestMessages discoveredTestMessages:
217-
OnDiscoveredTestMessages(discoveredTestMessages);
218-
break;
219-
220-
case TestResultMessages testResultMessages:
221-
OnTestResultMessages(testResultMessages);
222-
break;
223-
224-
case FileArtifactMessages fileArtifactMessages:
225-
OnFileArtifactMessages(fileArtifactMessages);
226-
break;
227-
228-
case TestSessionEvent sessionEvent:
229-
OnSessionEvent(sessionEvent);
230-
break;
231-
232-
// If we don't recognize the message, log and skip it
233-
case UnknownMessage unknownMessage:
234-
Logger.LogTrace($"Request '{request.GetType()}' with Serializer ID = {unknownMessage.SerializerId} is unsupported.");
235-
return Task.FromResult((IResponse)VoidResponse.CachedInstance);
236-
237-
default:
238-
// If it doesn't match any of the above, throw an exception
239-
throw new NotSupportedException(string.Format(CliCommandStrings.CmdUnsupportedMessageRequestTypeException, request.GetType()));
210+
switch (request)
211+
{
212+
case HandshakeMessage handshakeMessage:
213+
_handshakes.Add(server, handshakeMessage);
214+
string negotiatedVersion = GetSupportedProtocolVersion(handshakeMessage);
215+
OnHandshakeMessage(handshakeMessage, negotiatedVersion.Length > 0);
216+
return Task.FromResult((IResponse)CreateHandshakeMessage(negotiatedVersion));
217+
218+
case CommandLineOptionMessages commandLineOptionMessages:
219+
OnCommandLineOptionMessages(commandLineOptionMessages);
220+
break;
221+
222+
case DiscoveredTestMessages discoveredTestMessages:
223+
OnDiscoveredTestMessages(discoveredTestMessages);
224+
break;
225+
226+
case TestResultMessages testResultMessages:
227+
OnTestResultMessages(testResultMessages);
228+
break;
229+
230+
case FileArtifactMessages fileArtifactMessages:
231+
OnFileArtifactMessages(fileArtifactMessages);
232+
break;
233+
234+
case TestSessionEvent sessionEvent:
235+
OnSessionEvent(sessionEvent);
236+
break;
237+
238+
// If we don't recognize the message, log and skip it
239+
case UnknownMessage unknownMessage:
240+
Logger.LogTrace($"Request '{request.GetType()}' with Serializer ID = {unknownMessage.SerializerId} is unsupported.");
241+
return Task.FromResult((IResponse)VoidResponse.CachedInstance);
242+
243+
default:
244+
// If it doesn't match any of the above, throw an exception
245+
throw new NotSupportedException(string.Format(CliCommandStrings.CmdUnsupportedMessageRequestTypeException, request.GetType()));
246+
}
247+
}
248+
catch (Exception ex)
249+
{
250+
// BE CAREFUL:
251+
// When handling some of the messages, we may throw an exception in unexpected state.
252+
// (e.g, OnSessionEvent may throw if we receive TestSessionEnd without TestSessionStart).
253+
// (or if we receive help-related messages when not in help mode)
254+
// In that case, we FailFast.
255+
// The lack of FailFast *might* have unintended consequences, such as breaking the internal loop of pipe server.
256+
// In that case, maybe MTP app will continue waiting for response, but we don't send the response and are waiting for
257+
// MTP app process exit (which doesn't happen).
258+
// So, we explicitly FailFast here.
259+
string exAsString = ex.ToString();
260+
Logger.LogTrace(exAsString);
261+
Environment.FailFast(exAsString);
240262
}
241-
}
242-
catch (Exception ex)
243-
{
244-
// BE CAREFUL:
245-
// When handling some of the messages, we may throw an exception in unexpected state.
246-
// (e.g, OnSessionEvent may throw if we receive TestSessionEnd without TestSessionStart).
247-
// (or if we receive help-related messages when not in help mode)
248-
// In that case, we FailFast.
249-
// The lack of FailFast *might* have unintended consequences, such as breaking the internal loop of pipe server.
250-
// In that case, maybe MTP app will continue waiting for response, but we don't send the response and are waiting for
251-
// MTP app process exit (which doesn't happen).
252-
// So, we explicitly FailFast here.
253-
string exAsString = ex.ToString();
254-
Logger.LogTrace(exAsString);
255-
Environment.FailFast(exAsString);
256-
}
257263

258-
return Task.FromResult((IResponse)VoidResponse.CachedInstance);
264+
return Task.FromResult((IResponse)VoidResponse.CachedInstance);
265+
}
259266
}
260267

261268
private static string GetSupportedProtocolVersion(HandshakeMessage handshakeMessage)

src/Cli/dotnet/Commands/Test/VSTest/TestCommand.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,16 @@ internal static int RunArtifactPostProcessingIfNeeded(string testSessionCorrelat
298298

299299
private static bool ContainsBuiltTestSources(string[] args)
300300
{
301-
foreach (string arg in args)
301+
for (int i = 0; i < args.Length; i++)
302302
{
303-
if (!arg.StartsWith("-") &&
304-
(arg.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) || arg.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)))
303+
string arg = args[i];
304+
if (arg.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) || arg.EndsWith(".exe", StringComparison.OrdinalIgnoreCase))
305305
{
306+
var previousArg = i > 0 ? args[i - 1] : null;
307+
if (previousArg != null && CommonOptions.PropertiesOption.Aliases.Contains(previousArg))
308+
{
309+
return false;
310+
}
306311
return true;
307312
}
308313
}

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.NetCore.Analyzers/Runtime/CSharpDetectPreviewFeatureAnalyzer.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,30 @@
22

33
using System.Collections.Immutable;
44
using System.Diagnostics.CodeAnalysis;
5+
using Analyzer.Utilities.Lightup;
56
using Microsoft.CodeAnalysis;
7+
using Microsoft.CodeAnalysis.CSharp;
68
using Microsoft.CodeAnalysis.CSharp.Syntax;
79
using Microsoft.CodeAnalysis.Diagnostics;
10+
using Microsoft.CodeAnalysis.Operations;
811
using Microsoft.NetCore.Analyzers.Runtime;
912

1013
namespace Microsoft.NetCore.CSharp.Analyzers.Runtime
1114
{
1215
[DiagnosticAnalyzer(LanguageNames.CSharp)]
1316
public class CSharpDetectPreviewFeatureAnalyzer : DetectPreviewFeatureAnalyzer
1417
{
18+
protected override ISymbol? SymbolFromAwaitOperation(IAwaitOperation operation)
19+
{
20+
if (operation.Syntax is not AwaitExpressionSyntax awaitSyntax)
21+
{
22+
return null;
23+
}
24+
25+
var awaitableInfo = operation.SemanticModel.GetAwaitExpressionInfo(awaitSyntax);
26+
return awaitableInfo.RuntimeAwaitMethod;
27+
}
28+
1529
protected override SyntaxNode? GetPreviewSyntaxNodeForFieldsOrEvents(ISymbol fieldOrEventSymbol, ISymbol previewSymbol)
1630
{
1731
ImmutableArray<SyntaxReference> fieldOrEventReferences = fieldOrEventSymbol.DeclaringSyntaxReferences;

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.NetAnalyzers/Microsoft.NetCore.Analyzers/Runtime/DetectPreviewFeatureAnalyzer.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ public override void Initialize(AnalysisContext context)
269269
OperationKind.ArrayCreation,
270270
OperationKind.CatchClause,
271271
OperationKind.TypeOf,
272-
OperationKind.EventAssignment
272+
OperationKind.EventAssignment,
273+
OperationKind.Await
273274
);
274275

275276
// Handle preview symbol definitions
@@ -809,7 +810,7 @@ private bool OperationUsesPreviewFeatures(OperationAnalysisContext context,
809810
return false;
810811
}
811812

812-
private static ISymbol? GetOperationSymbol(IOperation operation)
813+
private ISymbol? GetOperationSymbol(IOperation operation)
813814
=> operation switch
814815
{
815816
IInvocationOperation iOperation => iOperation.TargetMethod,
@@ -824,6 +825,7 @@ private bool OperationUsesPreviewFeatures(OperationAnalysisContext context,
824825
ICatchClauseOperation catchClauseOperation => catchClauseOperation.ExceptionType,
825826
ITypeOfOperation typeOfOperation => typeOfOperation.TypeOperand,
826827
IEventAssignmentOperation eventAssignment => GetOperationSymbol(eventAssignment.EventReference),
828+
IAwaitOperation awaitOperation => SymbolFromAwaitOperation(awaitOperation),
827829
_ => null,
828830
};
829831

@@ -838,6 +840,8 @@ private bool OperationUsesPreviewFeatures(OperationAnalysisContext context,
838840
return ret;
839841
}
840842

843+
protected abstract ISymbol? SymbolFromAwaitOperation(IAwaitOperation operation);
844+
841845
private bool TypeParametersHavePreviewAttribute(ISymbol namedTypeSymbolOrMethodSymbol,
842846
ImmutableArray<ITypeParameterSymbol> typeParameters,
843847
ConcurrentDictionary<ISymbol, (bool isPreview, string? message, string? url)> requiresPreviewFeaturesSymbols,

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.VisualBasic.NetAnalyzers/Microsoft.NetCore.Analyzers/Runtime/BasicDetectPreviewFeatureAnalyzer.vb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
Imports Microsoft.CodeAnalysis
44
Imports Microsoft.CodeAnalysis.Diagnostics
5+
Imports Microsoft.CodeAnalysis.Operations
56
Imports Microsoft.NetCore.Analyzers.Runtime
67
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
78

@@ -16,6 +17,10 @@ Namespace Microsoft.NetCore.VisualBasic.Analyzers.Runtime
1617
Return identifier.ValueText.Equals(previewInterfaceSymbol.Name, StringComparison.OrdinalIgnoreCase)
1718
End Function
1819

20+
Protected Overrides Function SymbolFromAwaitOperation(operation As IAwaitOperation) As ISymbol
21+
Return Nothing
22+
End Function
23+
1924
Private Shared Function GetElementTypeForNullableAndArrayTypeNodes(parameterType As TypeSyntax) As TypeSyntax
2025
Dim ret As TypeSyntax = parameterType
2126
Dim loopVariable = TryCast(parameterType, NullableTypeSyntax)
@@ -334,4 +339,4 @@ Namespace Microsoft.NetCore.VisualBasic.Analyzers.Runtime
334339
End Function
335340
End Class
336341

337-
End Namespace
342+
End Namespace

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Utilities/Compiler.CSharp/Analyzer.CSharp.Utilities.projitems

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<ItemGroup>
1111
<Compile Include="$(MSBuildThisFileDirectory)Extensions\SyntaxGeneratorExtensions.cs" />
1212
<Compile Include="$(MSBuildThisFileDirectory)Extensions\SyntaxNodeExtensions.cs" />
13+
<Compile Include="$(MSBuildThisFileDirectory)Lightup\AwaitExpressionInfoWrapper.cs" />
1314
<Compile Include="$(MSBuildThisFileDirectory)Lightup\SyntaxKindEx.cs" />
1415
</ItemGroup>
15-
</Project>
16+
</Project>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.
2+
3+
using Microsoft.CodeAnalysis;
4+
using Microsoft.CodeAnalysis.CSharp;
5+
6+
namespace Analyzer.Utilities.Lightup
7+
{
8+
internal static class AwaitExpressionInfoWrapper
9+
{
10+
private static Func<AwaitExpressionInfo, IMethodSymbol?>? s_RuntimeAwaitMethodAccessor;
11+
12+
extension(AwaitExpressionInfo info)
13+
{
14+
public IMethodSymbol? RuntimeAwaitMethod
15+
{
16+
get
17+
{
18+
LazyInitializer.EnsureInitialized(ref s_RuntimeAwaitMethodAccessor, () =>
19+
{
20+
return LightupHelpers.CreatePropertyAccessor<AwaitExpressionInfo, IMethodSymbol?>(
21+
typeof(AwaitExpressionInfo),
22+
"info",
23+
"RuntimeAwaitMethod",
24+
fallbackResult: null);
25+
});
26+
27+
RoslynDebug.Assert(s_RuntimeAwaitMethodAccessor is not null);
28+
return s_RuntimeAwaitMethodAccessor(info);
29+
}
30+
}
31+
}
32+
}
33+
}

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Utilities/Compiler/Lightup/LightupHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ internal static Func<TSymbol, TProperty> CreateSymbolPropertyAccessor<TSymbol, T
5353
where TSymbol : ISymbol
5454
=> CreatePropertyAccessor<TSymbol, TProperty>(type, "symbol", propertyName, fallbackResult);
5555

56-
private static Func<T, TProperty> CreatePropertyAccessor<T, TProperty>(Type? type, string parameterName, string propertyName, TProperty fallbackResult)
56+
internal static Func<T, TProperty> CreatePropertyAccessor<T, TProperty>(Type? type, string parameterName, string propertyName, TProperty fallbackResult)
5757
{
5858
if (!TryGetProperty<T, TProperty>(type, propertyName, out var property))
5959
{

0 commit comments

Comments
 (0)