-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Move ArrayBuilder.GetInstance helpers to Microsoft.CodeAnalysis.PooledObjects package #76971
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
M:System.IO.Path.GetTempPath(); Cannot be used safely in APIs or compiler server as underlying environment variables can change during build. | ||
P:System.Environment.CurrentDirectory; Cannot be used safely in APIs or compiler server as underlying environment variables can change during build. | ||
P:System.Environment.CurrentDirectory; Cannot be used safely in APIs or compiler server as underlying environment variables can change during build. | ||
M:Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1.GetInstance(Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder{`0}@)"; Explicitly free ArrayBuilder instance instead. Implicit try-finally blocks might negatively affect performance. | ||
M:Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1.GetInstance(System.Int32,Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder{`0}@)"; Explicitly free ArrayBuilder instance instead. Implicit try-finally blocks might negatively affect performance. | ||
M:Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1.GetInstance(System.Int32,`0,Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder{`0}@)"; Explicitly free ArrayBuilder instance instead. Implicit try-finally blocks might negatively affect performance. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
|
||
namespace Microsoft.CodeAnalysis.PooledObjects; | ||
|
||
internal readonly partial struct PooledDisposer<TPoolable>(TPoolable instance) : IDisposable | ||
where TPoolable : class, IPooled | ||
{ | ||
void IDisposable.Dispose() | ||
=> instance?.Free(); | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,9 +8,7 @@ | |
namespace Microsoft.CodeAnalysis.PooledObjects; | ||
|
||
[NonCopyable] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adds There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about just requiring the consumer to provide this attribute in all cases? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't the analyzer Roslyn specific? I would rather not impose more requirements on consumers of this source package. That said, I'm working on another source package (say We can include NonCopyable there. It's a contract after all, so it would fit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #76997 (Add Microsoft.CodeAnalysis.Contracts source package) |
||
internal readonly struct PooledDisposer<TPoolable>(TPoolable instance) : IDisposable | ||
internal partial struct PooledDisposer<TPoolable> | ||
where TPoolable : class, IPooled | ||
{ | ||
void IDisposable.Dispose() | ||
=> instance?.Free(); | ||
} |
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.
Definitely need compiler sign off here. This will maje some unusable members show up in completion for a very common type.
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.
Why is this an unusable member?
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.
Perhaps instead of banning the API we can wrap these in
#if !COMPILERCORE
. If we do, it'd be better to rename the symbol to something more descriptive, e.g.ROSLYN_COMPILER_CORE
as it would appear in any repo consuming the source package.@dotnet/roslyn-compiler Which approach do you prefer?