-
Notifications
You must be signed in to change notification settings - Fork 92
[Version 9.0] Feature support for attributes on local functions #1466
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: draft-v9
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -513,7 +513,7 @@ | |||||
|
|
||||||
| #### 23.5.3.1 General | ||||||
|
|
||||||
| The attribute `Conditional` enables the definition of ***conditional method***s and ***conditional attribute class***es. | ||||||
| The attribute `Conditional` enables the definition of ***conditional methods***, ***conditional local function***s, and ***conditional attribute class***es. | ||||||
|
|
||||||
| #### 23.5.3.2 Conditional methods | ||||||
|
|
||||||
|
|
@@ -667,6 +667,12 @@ | |||||
| > | ||||||
| > *end example* | ||||||
|
|
||||||
| #### §conditional-local-function Conditional local functions | ||||||
|
|
||||||
| A static local function may be made conditional in the same sense as a conditional method ([§23.5.3.2](attributes.md#23532-conditional-methods)). | ||||||
|
|
||||||
| A compile time error ocurrs if a non-static local function is made conditional. | ||||||
|
Contributor
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. I'm interested in why this is the case - and maybe readers would be too?
Contributor
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.
Suggested change
|
||||||
|
|
||||||
| #### 23.5.3.3 Conditional attribute classes | ||||||
|
|
||||||
| An attribute class ([§23.2](attributes.md#232-attribute-classes)) decorated with one or more `Conditional` attributes is a conditional attribute class. A conditional attribute class is thus associated with the conditional compilation symbols declared in its `Conditional` attributes. | ||||||
|
|
@@ -836,6 +842,8 @@ | |||||
|
|
||||||
| For invocations that occur within declarations of instance constructors, static constructors, finalizers and operators the member name used is implementation-dependent. | ||||||
|
|
||||||
| For an invocation that occurs within a local function, the name of the member method that calls that local function is used. Consider the following: if member method `M` calls local function `F1`, which in turn calls local function `F2`, and `F2` has a parameter marked with this attribute, the method name passed to `F2` is `M`, because a local function is *not* a function member! | ||||||
|
Contributor
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. We should separate out the normative and informative here (and remove the exclamation mark preferrably...) Showing this as actual example code would be useful too.
Contributor
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. Agreed! My original PR (#994) had a version of this text in an example, but that appears to have been lost. I'll work with Bill to restore it.
Contributor
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. This is resolved by PR #1548.
Contributor
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. Lambdas and anonymous methods are in the same boat as local functions. |
||||||
|
|
||||||
| ### 23.5.7 Code analysis attributes | ||||||
|
|
||||||
| #### 23.5.7.1 General | ||||||
|
|
@@ -956,7 +964,7 @@ | |||||
| > ```csharp | ||||||
| > #nullable enable | ||||||
| > public class X | ||||||
| > { | ||||||
| > private void ThrowIfNull([DoesNotReturnIf(true)] bool isNull, string argumentName) | ||||||
| > { | ||||||
| > if (!isNull) | ||||||
|
|
||||||
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.
Since the original style continues to be followed with the last two items: