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

Rename LifetimeAnnotationAttribute to ScopedRefAttribute and remove unnecessary members #6325

Merged
merged 5 commits into from
Jul 27, 2022

Conversation

jcouv
Copy link
Member

@jcouv jcouv commented Jul 27, 2022

Relates to issue dotnet/roslyn#62838

@jcouv jcouv self-assigned this Jul 27, 2022
@jcouv jcouv marked this pull request as ready for review July 27, 2022 19:00
@jcouv jcouv requested a review from a team as a code owner July 27, 2022 19:00
@jcouv
Copy link
Member Author

jcouv commented Jul 27, 2022

@cston for review

### LifetimeAnnotationAttribute
The `scoped` and `unscoped` annotations will be emitted into metadata via the type `System.Runtime.CompilerServices.LifetimeAttribute` attribute. This attribute will be matched by name meaning it does not need to appear in any specific assembly.
### ScopedRefAttribute
The `scoped` and `unscoped` annotations will be emitted into metadata via the type `System.Runtime.CompilerServices.ScopedRefAttribute` attribute. This attribute will be matched by name meaning it does not need to appear in any specific assembly.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and unscoped

Remove?

}
}
```

The attribute uses `int` instead of `bool` to allow for future lifetime expansions in this space.

The compiler will emit this attribute on the element targeted by the `scoped` or `unscoped` syntax. This is true for types, methods and parameters. This will only be emitted when the syntax causes the value to differ from its default state. For example `scoped out` will cause no attribute to be emitted.
The compiler will emit this attribute on the element targeted by the `scoped` syntax. This is true for types, methods and parameters. This will only be emitted when the syntax causes the value to differ from its default state. For example `scoped out` will cause no attribute to be emitted.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compiler will emit this attribute on the element targeted by the scoped syntax. This is true for types, methods and parameters.

The second sentence is incorrect since this only applies to parameters. Perhaps change the first two sentences to: "The compiler will emit this attribute on the scoped parameter."


public LifetimeAnnotationAttribute(int value)
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
public sealed class ScopedRefAttribute : Attribute
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

internal

}
}
```

The attribute uses `int` instead of `bool` to allow for future lifetime expansions in this space.

The compiler will emit this attribute on the element targeted by the `scoped` or `unscoped` syntax. This is true for types, methods and parameters. This will only be emitted when the syntax causes the value to differ from its default state. For example `scoped out` will cause no attribute to be emitted.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only be emitted when the syntax causes the value to differ from its default state.

Consider keeping this sentence. (Sorry if my previous comment was confusing.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants