-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Consolidate StackGuard implementations into Common #123680
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
base: main
Are you sure you want to change the base?
Conversation
…nd Microsoft.Extensions.DependencyInjection into Common Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
| var t = (Tuple<Func<T1, T2, T3, R>, T1, T2, T3>)s; | ||
| return t.Item1(t.Item2, t.Item3, t.Item4); | ||
| }, Tuple.Create(action, arg1, arg2, arg3)); | ||
| #else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot, can we not use the valuetuple-based code (the else block) on .NET Framework and .NET Standard?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 146267b. Removed the Tuple-based conditional compilation and now use ValueTuple on all targets. Added System.ValueTuple package reference to Microsoft.Extensions.DependencyInjection.csproj for net462.
| <ItemGroup> | ||
| <Compile Include="**\*.cs" /> | ||
| <Compile Remove="ServiceLookup\ILEmit\**\*.cs" /> | ||
| <Compile Remove="ServiceLookup\StackGuard.cs" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot why do we need both this StackGuard.cs and the Common StackGuard.cs? The goal here is to consolidate to just one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right - the <Compile Remove> line was leftover from when I excluded the file before deleting it. Since the file is deleted, that line is unnecessary. Removed it in 840c01d.
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
|
Tagging subscribers to this area: @agocke, @VSadov |
Description
Multiple
StackGuardimplementations existed in the repo (System.Linq.Expressions and Microsoft.Extensions.DependencyInjection) with nearly identical code. This PR consolidates them into a single shared implementation.Changes
src/libraries/Common/src/System/Threading/StackGuard.cswith the unified implementation$(CommonPath)includeStackGuard.csfilesusing System.Threading;to files referencing the typeSystem.ValueTuplepackage reference to Microsoft.Extensions.DependencyInjection for net462 supportILLink.RoslynAnalyzer StackGuard (NOT consolidated)
The
src/tools/illink/src/ILLink.RoslynAnalyzer/DataFlow/StackGuard.csis intentionally not consolidated. It has a fundamentally different design:Implementation notes
The shared
StackGuarduses:TryEnterOnCurrentStack(): Uses try/catch withEnsureSufficientExecutionStack()onNETFRAMEWORK || NETSTANDARD2_0, andTryEnsureSufficientExecutionStack()on newer frameworksRunOnEmptyStackmethods on all targets (withSystem.ValueTuplepackage reference for older frameworks that need it)Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.