Skip to content
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

Disallow RequiresLocationAttribute in more places in source? #70011

Closed
jjonescz opened this issue Sep 19, 2023 · 1 comment
Closed

Disallow RequiresLocationAttribute in more places in source? #70011

jjonescz opened this issue Sep 19, 2023 · 1 comment
Assignees
Milestone

Comments

@jjonescz
Copy link
Member

Currently, it is an error if user applies RequiresLocationAttribute to a parameter, but it's not an error if user applies it at other places. This is consistent with for example ParamArrayAttribute, but not with for example IsByRefLikeAttribute.

@AlekseyTs says in #68871 (comment):

let's confirm with LDM whether we want proactively prohibit application of the attribute in other contexts in order to preserve future design space.

Example:

SharpLab

using System;
using System.Runtime.CompilerServices;

[RequiresLocation] // currently no error, has no effect here
[ParamArray] // no error, has no effect here
[IsByRefLike] // error, use `ref struct` instead
public struct C
{
    public void M(
        [RequiresLocation] // error, use `ref readonly` instead
        [ParamArray] // error, use `params` instead
        [IsByRefLike] // error, although it has no effect here
        int p)
    {
    }
}

namespace System
{
    class ParamArrayAttribute : Attribute { }
}
namespace System.Runtime.CompilerServices
{
    class RequiresLocationAttribute : Attribute { }
    class IsByRefLikeAttribute : Attribute { }
}
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label Sep 19, 2023
@jaredpar
Copy link
Member

My instinct here is that we should be disallowing in these cases. If we can squeeze this into 17.8 I would prefer that but I don't mind taking this as a small break in 17.9.

@jaredpar jaredpar added Bug and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 25, 2023
@jaredpar jaredpar added this to the 17.8 milestone Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants