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
Expose System.Runtime.CompilerServices.SkipLocalsInitAttribute
#25850
Comments
Questions:
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeUsage.All, Inherited = false)]
public sealed class SkipLocalsInitAttribute : Attribute
{
public SkipLocalsInitAttribute(bool isEnabled);
public bool IsEnabled { get; }
}
} |
This is a compiler, not a language, feature. So i doubt any language support will be added (see dotnet/csharplang#1223).
Yes, that is the workaround today.
Right, it should only matter for Methods (including constructors/properties/etc) and things which can contain methods (Types, Modules, Assemblies).
This seems like a reasonable thing to support. @jcouv ? |
Talked to @agocke and confirmed that we do not intend allowing the feature to be turned off per-member when applied to a container.
You're correct. The attribute should be applied to constructors in such case.
Also confirmed with him that
No. Per speclet: This is explicitly a compiler feature and not a language feature :-) Tagging @VSadov in case anything to add. |
@tannergooding |
Yes. All the above is correct. In particular - the "override/on/off" behavior was discussed at least two times and both times dropped due to being unnecessary complication for too little gain. It is expected that the attribute will be used either on the whole module (most likely) or on select leaf methods (distant second). It is highly unlikely that user will want an elaborate system of mix and match behavior. It is still possible by attributing every piece, if needed, but we did not think it was worth the trouble to make this scenario easy. |
Yes, adding an attribute to the S.R.C that is shipping would be a good idea. |
@jcouv, right. Hence the comment |
This is linked to the compiler feature: dotnet/csharplang#1738 |
Updated the OP with the correct
Assembly isn't included because you can have multiple modules from different sources Enum and Interface aren't included because you can't implement methods on them today. We will need to revisit if such functionality becomes possible (both are currently tracked as language proposals) Field, Parameter, Delegate, ReturnValue, and GenericParameter don't make sense as valid targets (they can't have any code that would end up with a |
@tannergooding, what's the status of this? Is it still for 3.0? Is the compiler feature moving along accordingly? |
AFAIK, the feature is basically implemented in https://github.com/dotnet/roslyn/tree/features/localsinit, but it requires additional review and merging back into master. @jaredpar or @agocke might be able to comment more about timeline |
@agocke, it looks like the feature was merged into Roslyn, correct? If so, we should go ahead with exposing it and using it in coreclr/corefx. |
I believe it is still in the |
Yup we have to do a feature review before we merge it. Hope to get that done in the next week or so. |
Rationale
C# is exposing new functionality which allows you to drop the
init
flag from a method's.local
directive (see dotnet/roslyn#25780 for more details).It would be beneficial if CoreFX/NetStandard exposed this standard type so that users are not required to always manually define this type themselves.
Proposed API
The text was updated successfully, but these errors were encountered: