diff options
author | Matt Mitchell <mmitche@microsoft.com> | 2022-10-14 19:21:03 +0300 |
---|---|---|
committer | Matt Mitchell <mmitche@microsoft.com> | 2022-10-14 19:21:03 +0300 |
commit | cd70d81d2114e404a73d09d01e996251515c7387 (patch) | |
tree | 8f3c250cd35357034a218b45d4457d79d8fa2342 | |
parent | 869e85fdd952be9a68956cbc53dfcb25061e425c (diff) | |
parent | e01db30f8631d8bc6612453fb44792384ec9fa21 (diff) |
Merge remote-tracking branch 'upstream/release/6.0' into merge-internal/release/6.0
-rw-r--r-- | NuGet.config | 5 | ||||
-rw-r--r-- | eng/Version.Details.xml | 80 | ||||
-rw-r--r-- | eng/Versions.props | 30 | ||||
-rw-r--r-- | eng/common/build.ps1 | 5 | ||||
-rw-r--r-- | eng/common/init-tools-native.ps1 | 1 | ||||
-rw-r--r-- | global.json | 12 | ||||
-rw-r--r-- | src/libraries/Common/src/Roslyn/SyntaxValueProvider_ForAttributeWithSimpleName.cs | 148 |
7 files changed, 170 insertions, 111 deletions
diff --git a/NuGet.config b/NuGet.config index 84d82e112ad..8ed75e08693 100644 --- a/NuGet.config +++ b/NuGet.config @@ -10,6 +10,11 @@ <!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.--> <!-- Begin: Package sources from dotnet-emsdk --> <add key="darc-pub-dotnet-emsdk-c3fc739" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-c3fc739c/nuget/v3/index.json" /> + <add key="darc-pub-dotnet-emsdk-c3fc739-5" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-c3fc739c-5/nuget/v3/index.json" /> + <add key="darc-pub-dotnet-emsdk-c3fc739-4" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-c3fc739c-4/nuget/v3/index.json" /> + <add key="darc-pub-dotnet-emsdk-c3fc739-3" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-c3fc739c-3/nuget/v3/index.json" /> + <add key="darc-pub-dotnet-emsdk-c3fc739-2" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-c3fc739c-2/nuget/v3/index.json" /> + <add key="darc-pub-dotnet-emsdk-c3fc739-1" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-c3fc739c-1/nuget/v3/index.json" /> <!-- End: Package sources from dotnet-emsdk --> <!-- Begin: Package sources from dotnet-wcf --> <!-- End: Package sources from dotnet-wcf --> diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 864108ee147..f75b478e687 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -26,77 +26,81 @@ </Dependency> </ProductDependencies> <ToolsetDependencies> - <Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="6.0.0-beta.22463.7"> + <Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="6.0.0-beta.22512.3"> <Uri>https://github.com/dotnet/arcade</Uri> - <Sha>2fbe602d12256bf82de53791ddcbb964c1541b4e</Sha> + <Sha>bb1e72113a7eaf8bebda940beba8cf8bee1b453f</Sha> </Dependency> - <Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="6.0.0-beta.22463.7"> + <Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="6.0.0-beta.22512.3"> <Uri>https://github.com/dotnet/arcade</Uri> - <Sha>2fbe602d12256bf82de53791ddcbb964c1541b4e</Sha> + <Sha>bb1e72113a7eaf8bebda940beba8cf8bee1b453f</Sha> </Dependency> - <Dependency Name="Microsoft.DotNet.ApiCompat" Version="6.0.0-beta.22463.7"> + <Dependency Name="Microsoft.DotNet.ApiCompat" Version="6.0.0-beta.22512.3"> <Uri>https://github.com/dotnet/arcade</Uri> - <Sha>2fbe602d12256bf82de53791ddcbb964c1541b4e</Sha> + <Sha>bb1e72113a7eaf8bebda940beba8cf8bee1b453f</Sha> </Dependency> - <Dependency Name="Microsoft.DotNet.GenAPI" Version="6.0.0-beta.22463.7"> + <Dependency Name="Microsoft.DotNet.GenAPI" Version="6.0.0-beta.22512.3"> <Uri>https://github.com/dotnet/arcade</Uri> - <Sha>2fbe602d12256bf82de53791ddcbb964c1541b4e</Sha> + <Sha>bb1e72113a7eaf8bebda940beba8cf8bee1b453f</Sha> </Dependency> - <Dependency Name="Microsoft.DotNet.GenFacades" Version="6.0.0-beta.22463.7"> + <Dependency Name="Microsoft.DotNet.GenFacades" Version="6.0.0-beta.22512.3"> <Uri>https://github.com/dotnet/arcade</Uri> - <Sha>2fbe602d12256bf82de53791ddcbb964c1541b4e</Sha> + <Sha>bb1e72113a7eaf8bebda940beba8cf8bee1b453f</Sha> </Dependency> - <Dependency Name="Microsoft.DotNet.XUnitExtensions" Version="6.0.0-beta.22463.7"> + <Dependency Name="Microsoft.DotNet.XUnitExtensions" Version="6.0.0-beta.22512.3"> <Uri>https://github.com/dotnet/arcade</Uri> - <Sha>2fbe602d12256bf82de53791ddcbb964c1541b4e</Sha> + <Sha>bb1e72113a7eaf8bebda940beba8cf8bee1b453f</Sha> </Dependency> - <Dependency Name="Microsoft.DotNet.XUnitConsoleRunner" Version="2.5.1-beta.22463.7"> + <Dependency Name="Microsoft.DotNet.XUnitConsoleRunner" Version="2.5.1-beta.22512.3"> <Uri>https://github.com/dotnet/arcade</Uri> - <Sha>2fbe602d12256bf82de53791ddcbb964c1541b4e</Sha> + <Sha>bb1e72113a7eaf8bebda940beba8cf8bee1b453f</Sha> </Dependency> - <Dependency Name="Microsoft.DotNet.Build.Tasks.Archives" Version="6.0.0-beta.22463.7"> + <Dependency Name="Microsoft.DotNet.Build.Tasks.Archives" Version="6.0.0-beta.22512.3"> <Uri>https://github.com/dotnet/arcade</Uri> - <Sha>2fbe602d12256bf82de53791ddcbb964c1541b4e</Sha> + <Sha>bb1e72113a7eaf8bebda940beba8cf8bee1b453f</Sha> </Dependency> - <Dependency Name="Microsoft.DotNet.Build.Tasks.Packaging" Version="6.0.0-beta.22463.7"> + <Dependency Name="Microsoft.DotNet.Build.Tasks.Packaging" Version="6.0.0-beta.22512.3"> <Uri>https://github.com/dotnet/arcade</Uri> - <Sha>2fbe602d12256bf82de53791ddcbb964c1541b4e</Sha> + <Sha>bb1e72113a7eaf8bebda940beba8cf8bee1b453f</Sha> </Dependency> - <Dependency Name="Microsoft.DotNet.Build.Tasks.Installers" Version="6.0.0-beta.22463.7"> + <Dependency Name="Microsoft.DotNet.Build.Tasks.Installers" Version="6.0.0-beta.22512.3"> <Uri>https://github.com/dotnet/arcade</Uri> - <Sha>2fbe602d12256bf82de53791ddcbb964c1541b4e</Sha> + <Sha>bb1e72113a7eaf8bebda940beba8cf8bee1b453f</Sha> </Dependency> - <Dependency Name="Microsoft.DotNet.Build.Tasks.Templating" Version="6.0.0-beta.22463.7"> + <Dependency Name="Microsoft.DotNet.Build.Tasks.Templating" Version="6.0.0-beta.22512.3"> <Uri>https://github.com/dotnet/arcade</Uri> - <Sha>2fbe602d12256bf82de53791ddcbb964c1541b4e</Sha> + <Sha>bb1e72113a7eaf8bebda940beba8cf8bee1b453f</Sha> </Dependency> - <Dependency Name="Microsoft.DotNet.Build.Tasks.Workloads" Version="6.0.0-beta.22463.7"> + <Dependency Name="Microsoft.DotNet.Build.Tasks.Workloads" Version="6.0.0-beta.22512.3"> <Uri>https://github.com/dotnet/arcade</Uri> - <Sha>2fbe602d12256bf82de53791ddcbb964c1541b4e</Sha> + <Sha>bb1e72113a7eaf8bebda940beba8cf8bee1b453f</Sha> </Dependency> - <Dependency Name="Microsoft.DotNet.CodeAnalysis" Version="6.0.0-beta.22463.7"> + <Dependency Name="Microsoft.DotNet.CodeAnalysis" Version="6.0.0-beta.22512.3"> <Uri>https://github.com/dotnet/arcade</Uri> - <Sha>2fbe602d12256bf82de53791ddcbb964c1541b4e</Sha> + <Sha>bb1e72113a7eaf8bebda940beba8cf8bee1b453f</Sha> </Dependency> - <Dependency Name="Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk" Version="6.0.0-beta.22463.7"> + <Dependency Name="Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk" Version="6.0.0-beta.22512.3"> <Uri>https://github.com/dotnet/arcade</Uri> - <Sha>2fbe602d12256bf82de53791ddcbb964c1541b4e</Sha> + <Sha>bb1e72113a7eaf8bebda940beba8cf8bee1b453f</Sha> </Dependency> - <Dependency Name="Microsoft.DotNet.RemoteExecutor" Version="6.0.0-beta.22463.7"> + <Dependency Name="Microsoft.DotNet.RemoteExecutor" Version="6.0.0-beta.22512.3"> <Uri>https://github.com/dotnet/arcade</Uri> - <Sha>2fbe602d12256bf82de53791ddcbb964c1541b4e</Sha> + <Sha>bb1e72113a7eaf8bebda940beba8cf8bee1b453f</Sha> </Dependency> - <Dependency Name="Microsoft.DotNet.Build.Tasks.Feed" Version="6.0.0-beta.22463.7"> + <Dependency Name="Microsoft.DotNet.Build.Tasks.Feed" Version="6.0.0-beta.22512.3"> <Uri>https://github.com/dotnet/arcade</Uri> - <Sha>2fbe602d12256bf82de53791ddcbb964c1541b4e</Sha> + <Sha>bb1e72113a7eaf8bebda940beba8cf8bee1b453f</Sha> </Dependency> - <Dependency Name="Microsoft.DotNet.VersionTools.Tasks" Version="6.0.0-beta.22463.7"> + <Dependency Name="Microsoft.DotNet.VersionTools.Tasks" Version="6.0.0-beta.22512.3"> <Uri>https://github.com/dotnet/arcade</Uri> - <Sha>2fbe602d12256bf82de53791ddcbb964c1541b4e</Sha> + <Sha>bb1e72113a7eaf8bebda940beba8cf8bee1b453f</Sha> </Dependency> - <Dependency Name="Microsoft.DotNet.SharedFramework.Sdk" Version="6.0.0-beta.22463.7"> + <Dependency Name="Microsoft.DotNet.SharedFramework.Sdk" Version="6.0.0-beta.22512.3"> <Uri>https://github.com/dotnet/arcade</Uri> - <Sha>2fbe602d12256bf82de53791ddcbb964c1541b4e</Sha> + <Sha>bb1e72113a7eaf8bebda940beba8cf8bee1b453f</Sha> + </Dependency> + <Dependency Name="Microsoft.NET.Test.Sdk" Version="16.9.0-preview-20201201-01"> + <Uri>https://github.com/microsoft/vstest</Uri> + <Sha>140434f7109d357d0158ade9e5164a4861513965</Sha> </Dependency> <Dependency Name="System.ComponentModel.TypeConverter.TestData" Version="6.0.0-beta.21518.1"> <Uri>https://github.com/dotnet/runtime-assets</Uri> @@ -214,9 +218,9 @@ <Uri>https://github.com/dotnet/xharness</Uri> <Sha>e9669dc84ecd668d3bbb748758103e23b394ffef</Sha> </Dependency> - <Dependency Name="Microsoft.DotNet.PackageTesting" Version="6.0.0-beta.22463.7"> + <Dependency Name="Microsoft.DotNet.PackageTesting" Version="6.0.0-beta.22512.3"> <Uri>https://github.com/dotnet/arcade</Uri> - <Sha>2fbe602d12256bf82de53791ddcbb964c1541b4e</Sha> + <Sha>bb1e72113a7eaf8bebda940beba8cf8bee1b453f</Sha> </Dependency> <Dependency Name="optimization.windows_nt-x64.MIBC.Runtime" Version="1.0.0-prerelease.21416.5"> <Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-optimization</Uri> diff --git a/eng/Versions.props b/eng/Versions.props index 7c289a41c54..51fa824d029 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -41,21 +41,21 @@ <!-- SDK dependencies --> <MicrosoftDotNetCompatibilityVersion>1.1.0-preview.22164.17</MicrosoftDotNetCompatibilityVersion> <!-- Arcade dependencies --> - <MicrosoftDotNetApiCompatVersion>6.0.0-beta.22463.7</MicrosoftDotNetApiCompatVersion> - <MicrosoftDotNetBuildTasksFeedVersion>6.0.0-beta.22463.7</MicrosoftDotNetBuildTasksFeedVersion> - <MicrosoftDotNetCodeAnalysisVersion>6.0.0-beta.22463.7</MicrosoftDotNetCodeAnalysisVersion> - <MicrosoftDotNetGenAPIVersion>6.0.0-beta.22463.7</MicrosoftDotNetGenAPIVersion> - <MicrosoftDotNetGenFacadesVersion>6.0.0-beta.22463.7</MicrosoftDotNetGenFacadesVersion> - <MicrosoftDotNetXUnitExtensionsVersion>6.0.0-beta.22463.7</MicrosoftDotNetXUnitExtensionsVersion> - <MicrosoftDotNetXUnitConsoleRunnerVersion>2.5.1-beta.22463.7</MicrosoftDotNetXUnitConsoleRunnerVersion> - <MicrosoftDotNetBuildTasksArchivesVersion>6.0.0-beta.22463.7</MicrosoftDotNetBuildTasksArchivesVersion> - <MicrosoftDotNetBuildTasksInstallersVersion>6.0.0-beta.22463.7</MicrosoftDotNetBuildTasksInstallersVersion> - <MicrosoftDotNetBuildTasksPackagingVersion>6.0.0-beta.22463.7</MicrosoftDotNetBuildTasksPackagingVersion> - <MicrosoftDotNetBuildTasksTemplatingVersion>6.0.0-beta.22463.7</MicrosoftDotNetBuildTasksTemplatingVersion> - <MicrosoftDotNetBuildTasksWorkloadsPackageVersion>6.0.0-beta.22463.7</MicrosoftDotNetBuildTasksWorkloadsPackageVersion> - <MicrosoftDotNetRemoteExecutorVersion>6.0.0-beta.22463.7</MicrosoftDotNetRemoteExecutorVersion> - <MicrosoftDotNetVersionToolsTasksVersion>6.0.0-beta.22463.7</MicrosoftDotNetVersionToolsTasksVersion> - <MicrosoftDotNetPackageTestingVersion>6.0.0-beta.22463.7</MicrosoftDotNetPackageTestingVersion> + <MicrosoftDotNetApiCompatVersion>6.0.0-beta.22512.3</MicrosoftDotNetApiCompatVersion> + <MicrosoftDotNetBuildTasksFeedVersion>6.0.0-beta.22512.3</MicrosoftDotNetBuildTasksFeedVersion> + <MicrosoftDotNetCodeAnalysisVersion>6.0.0-beta.22512.3</MicrosoftDotNetCodeAnalysisVersion> + <MicrosoftDotNetGenAPIVersion>6.0.0-beta.22512.3</MicrosoftDotNetGenAPIVersion> + <MicrosoftDotNetGenFacadesVersion>6.0.0-beta.22512.3</MicrosoftDotNetGenFacadesVersion> + <MicrosoftDotNetXUnitExtensionsVersion>6.0.0-beta.22512.3</MicrosoftDotNetXUnitExtensionsVersion> + <MicrosoftDotNetXUnitConsoleRunnerVersion>2.5.1-beta.22512.3</MicrosoftDotNetXUnitConsoleRunnerVersion> + <MicrosoftDotNetBuildTasksArchivesVersion>6.0.0-beta.22512.3</MicrosoftDotNetBuildTasksArchivesVersion> + <MicrosoftDotNetBuildTasksInstallersVersion>6.0.0-beta.22512.3</MicrosoftDotNetBuildTasksInstallersVersion> + <MicrosoftDotNetBuildTasksPackagingVersion>6.0.0-beta.22512.3</MicrosoftDotNetBuildTasksPackagingVersion> + <MicrosoftDotNetBuildTasksTemplatingVersion>6.0.0-beta.22512.3</MicrosoftDotNetBuildTasksTemplatingVersion> + <MicrosoftDotNetBuildTasksWorkloadsPackageVersion>6.0.0-beta.22512.3</MicrosoftDotNetBuildTasksWorkloadsPackageVersion> + <MicrosoftDotNetRemoteExecutorVersion>6.0.0-beta.22512.3</MicrosoftDotNetRemoteExecutorVersion> + <MicrosoftDotNetVersionToolsTasksVersion>6.0.0-beta.22512.3</MicrosoftDotNetVersionToolsTasksVersion> + <MicrosoftDotNetPackageTestingVersion>6.0.0-beta.22512.3</MicrosoftDotNetPackageTestingVersion> <!-- NuGet dependencies --> <NuGetBuildTasksPackVersion>6.0.0-preview.1.102</NuGetBuildTasksPackVersion> <!-- Installer dependencies --> diff --git a/eng/common/build.ps1 b/eng/common/build.ps1 index 8943da242f6..33a6f2d0e24 100644 --- a/eng/common/build.ps1 +++ b/eng/common/build.ps1 @@ -26,6 +26,7 @@ Param( [string] $runtimeSourceFeed = '', [string] $runtimeSourceFeedKey = '', [switch] $excludePrereleaseVS, + [switch] $nativeToolsOnMachine, [switch] $help, [Parameter(ValueFromRemainingArguments=$true)][String[]]$properties ) @@ -67,6 +68,7 @@ function Print-Usage() { Write-Host " -warnAsError <value> Sets warnaserror msbuild parameter ('true' or 'false')" Write-Host " -msbuildEngine <value> Msbuild engine to use to run build ('dotnet', 'vs', or unspecified)." Write-Host " -excludePrereleaseVS Set to exclude build engines in prerelease versions of Visual Studio" + Write-Host " -nativeToolsOnMachine Sets the native tools on machine environment variable (indicating that the script should use native tools on machine)" Write-Host "" Write-Host "Command line arguments not listed above are passed thru to msbuild." @@ -146,6 +148,9 @@ try { $nodeReuse = $false } + if ($nativeToolsOnMachine) { + $env:NativeToolsOnMachine = $true + } if ($restore) { InitializeNativeTools } diff --git a/eng/common/init-tools-native.ps1 b/eng/common/init-tools-native.ps1 index 7428ef88084..6c7a851a808 100644 --- a/eng/common/init-tools-native.ps1 +++ b/eng/common/init-tools-native.ps1 @@ -112,6 +112,7 @@ try { $ToolPath = Convert-Path -Path $BinPath Write-Host "Adding $ToolName to the path ($ToolPath)..." Write-Host "##vso[task.prependpath]$ToolPath" + $env:PATH = "$ToolPath;$env:PATH" $InstalledTools += @{ $ToolName = $ToolDirectory.FullName } } } diff --git a/global.json b/global.json index bc2ea855f26..2949501f896 100644 --- a/global.json +++ b/global.json @@ -1,21 +1,21 @@ { "sdk": { - "version": "6.0.109", + "version": "6.0.110", "allowPrerelease": true, "rollForward": "major" }, "tools": { - "dotnet": "6.0.109" + "dotnet": "6.0.110" }, "native-tools": { "cmake": "3.16.4", "python3": "3.7.1" }, "msbuild-sdks": { - "Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk": "6.0.0-beta.22463.7", - "Microsoft.DotNet.Arcade.Sdk": "6.0.0-beta.22463.7", - "Microsoft.DotNet.Helix.Sdk": "6.0.0-beta.22463.7", - "Microsoft.DotNet.SharedFramework.Sdk": "6.0.0-beta.22463.7", + "Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk": "6.0.0-beta.22512.3", + "Microsoft.DotNet.Arcade.Sdk": "6.0.0-beta.22512.3", + "Microsoft.DotNet.Helix.Sdk": "6.0.0-beta.22512.3", + "Microsoft.DotNet.SharedFramework.Sdk": "6.0.0-beta.22512.3", "Microsoft.Build.NoTargets": "3.1.0", "Microsoft.Build.Traversal": "3.0.23", "Microsoft.NET.Sdk.IL": "6.0.0-rc.1.21415.6" diff --git a/src/libraries/Common/src/Roslyn/SyntaxValueProvider_ForAttributeWithSimpleName.cs b/src/libraries/Common/src/Roslyn/SyntaxValueProvider_ForAttributeWithSimpleName.cs index 03ab7371863..3e6f947065a 100644 --- a/src/libraries/Common/src/Roslyn/SyntaxValueProvider_ForAttributeWithSimpleName.cs +++ b/src/libraries/Common/src/Roslyn/SyntaxValueProvider_ForAttributeWithSimpleName.cs @@ -215,7 +215,7 @@ internal static partial class SyntaxValueProviderExtensions try { - recurse(compilationUnit, ref localAliases, ref seenNames, ref results, ref attributeTargets); + processCompilationUnit(compilationUnit, ref localAliases, ref seenNames, ref results, ref attributeTargets); if (results.Length == 0) return ImmutableArray<SyntaxNode>.Empty; @@ -229,7 +229,21 @@ internal static partial class SyntaxValueProviderExtensions seenNames.Dispose(); } - void recurse( + void processCompilationUnit( + SyntaxNode compilationUnit, + ref Aliases localAliases, + ref ValueListBuilder<string> seenNames, + ref ValueListBuilder<SyntaxNode> results, + ref ValueListBuilder<SyntaxNode> attributeTargets) + { + cancellationToken.ThrowIfCancellationRequested(); + + syntaxHelper.AddAliases(compilationUnit, ref localAliases, global: false); + + processCompilationOrNamespaceMembers(compilationUnit, ref localAliases, ref seenNames, ref results, ref attributeTargets); + } + + void processCompilationOrNamespaceMembers( SyntaxNode node, ref Aliases localAliases, ref ValueListBuilder<string> seenNames, @@ -238,70 +252,100 @@ internal static partial class SyntaxValueProviderExtensions { cancellationToken.ThrowIfCancellationRequested(); - if (node is ICompilationUnitSyntax) + foreach (var child in node.ChildNodesAndTokens()) { - syntaxHelper.AddAliases(node, ref localAliases, global: false); - - recurseChildren(node, ref localAliases, ref seenNames, ref results, ref attributeTargets); + if (child.IsNode) + { + var childNode = child.AsNode()!; + if (syntaxHelper.IsAnyNamespaceBlock(childNode)) + processNamespaceBlock(childNode, ref localAliases, ref seenNames, ref results, ref attributeTargets); + else + processMember(childNode, ref localAliases, ref seenNames, ref results, ref attributeTargets); + } } - else if (syntaxHelper.IsAnyNamespaceBlock(node)) - { - var localAliasCount = localAliases.Length; - syntaxHelper.AddAliases(node, ref localAliases, global: false); + } + + void processNamespaceBlock( + SyntaxNode namespaceBlock, + ref Aliases localAliases, + ref ValueListBuilder<string> seenNames, + ref ValueListBuilder<SyntaxNode> results, + ref ValueListBuilder<SyntaxNode> attributeTargets) + { + cancellationToken.ThrowIfCancellationRequested(); - recurseChildren(node, ref localAliases, ref seenNames, ref results, ref attributeTargets); + var localAliasCount = localAliases.Length; + syntaxHelper.AddAliases(namespaceBlock, ref localAliases, global: false); - // after recursing into this namespace, dump any local aliases we added from this namespace decl itself. - localAliases.Length = localAliasCount; - } - else if (syntaxHelper.IsAttributeList(node)) + processCompilationOrNamespaceMembers( + namespaceBlock, ref localAliases, ref seenNames, ref results, ref attributeTargets); + + // after recursing into this namespace, dump any local aliases we added from this namespace decl itself. + localAliases.Length = localAliasCount; + } + + void processMember( + SyntaxNode member, + ref Aliases localAliases, + ref ValueListBuilder<string> seenNames, + ref ValueListBuilder<SyntaxNode> results, + ref ValueListBuilder<SyntaxNode> attributeTargets) + { + cancellationToken.ThrowIfCancellationRequested(); + + // nodes can be arbitrarily deep. Use an explicit stack over recursion to prevent a stack-overflow. + var nodeStack = new ValueListBuilder<SyntaxNode>(Span<SyntaxNode>.Empty); + nodeStack.Append(member); + + try { - foreach (var attribute in syntaxHelper.GetAttributesOfAttributeList(node)) + while (nodeStack.Length > 0) { - // Have to lookup both with the name in the attribute, as well as adding the 'Attribute' suffix. - // e.g. if there is [X] then we have to lookup with X and with XAttribute. - var simpleAttributeName = syntaxHelper.GetUnqualifiedIdentifierOfName( - syntaxHelper.GetNameOfAttribute(attribute)).ValueText; - if (matchesAttributeName(ref localAliases, ref seenNames, simpleAttributeName, withAttributeSuffix: false) || - matchesAttributeName(ref localAliases, ref seenNames, simpleAttributeName, withAttributeSuffix: true)) - { - attributeTargets.Length = 0; - syntaxHelper.AddAttributeTargets(node, ref attributeTargets); + var node = nodeStack.Pop(); - foreach (var target in attributeTargets.AsSpan()) + if (syntaxHelper.IsAttributeList(node)) + { + foreach (var attribute in syntaxHelper.GetAttributesOfAttributeList(node)) { - if (predicate(target, cancellationToken)) - results.Append(target); + // Have to lookup both with the name in the attribute, as well as adding the 'Attribute' suffix. + // e.g. if there is [X] then we have to lookup with X and with XAttribute. + var simpleAttributeName = syntaxHelper.GetUnqualifiedIdentifierOfName( + syntaxHelper.GetNameOfAttribute(attribute)).ValueText; + if (matchesAttributeName(ref localAliases, ref seenNames, simpleAttributeName, withAttributeSuffix: false) || + matchesAttributeName(ref localAliases, ref seenNames, simpleAttributeName, withAttributeSuffix: true)) + { + attributeTargets.Length = 0; + syntaxHelper.AddAttributeTargets(node, ref attributeTargets); + + foreach (var target in attributeTargets.AsSpan()) + { + if (predicate(target, cancellationToken)) + results.Append(target); + } + + break; + } } - return; + // attributes can't have attributes inside of them. so no need to recurse when we're done. + } + else + { + // For any other node, just keep recursing deeper to see if we can find an attribute. Note: we cannot + // terminate the search anywhere as attributes may be found on things like local functions, and that + // means having to dive deep into statements and expressions. + foreach (var child in node.ChildNodesAndTokens().Reverse()) + { + if (child.IsNode) + nodeStack.Append(child.AsNode()!); + } } - } - // attributes can't have attributes inside of them. so no need to recurse when we're done. - } - else - { - // For any other node, just keep recursing deeper to see if we can find an attribute. Note: we cannot - // terminate the search anywhere as attributes may be found on things like local functions, and that - // means having to dive deep into statements and expressions. - recurseChildren(node, ref localAliases, ref seenNames, ref results, ref attributeTargets); + } } - - return; - - void recurseChildren( - SyntaxNode node, - ref Aliases localAliases, - ref ValueListBuilder<string> seenNames, - ref ValueListBuilder<SyntaxNode> results, - ref ValueListBuilder<SyntaxNode> attributeTargets) + finally { - foreach (var child in node.ChildNodesAndTokens()) - { - if (child.IsNode) - recurse(child.AsNode()!, ref localAliases, ref seenNames, ref results, ref attributeTargets); - } + nodeStack.Dispose(); } } |