question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Document C# extension: [return: attribute] on accessor that returns void

See original GitHub issue

The Roslyn C# compiler allows a return attribute_target_specifier in the following contexts, where ECMA-334 5th edition § 22.3 (Attribute specification) does not allow it:

  • add accessor of an event
  • remove accessor of an event
  • set accessor of a property
  • set accessor of an indexer

Please document this extension, to comply with ECMA-334 5th edition chapter 2:

A conforming implementation of C# shall be accompanied by a document that defines all implementation-defined characteristics, and all extensions.

The feature used to be documented at https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/attributes#attribute-specification, but it was not marked as an extension, and anyway has been removed from that document, which now comes from an ECMA C# draft.

I imagine the extension could be documented in https://github.com/dotnet/roslyn/tree/main/docs/compilers/CSharp, which already describes some other extensions (if a directory can be considered “a document”), or perhaps in https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/attributes/.

Split from https://github.com/dotnet/csharpstandard/issues/340.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jcouvcommented, Jul 7, 2022

A conforming implementation of C# shall be accompanied by a document that defines all implementation-defined characteristics, and all extensions.

@BillWagner Based on this, I think the document should live in the roslyn repo (ie. the implementation). What do you think?

0reactions
jcouvcommented, Nov 9, 2022

Good catch. We do need to keep this open for a Roslyn change.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Properties in C# | Microsoft Learn
Because a property set accessor must have a void return type, you report errors in the set accessor by throwing an exception. You...
Read more >
accessor function in class type not returning proper values ...
I have a class called Card and my constructor is working properly but I am not sure if I am accessing my private...
Read more >
2. Defining Extension Types: Tutorial
Python allows the writer of a C extension module to define new types that can be manipulated from Python code, much like the...
Read more >
Declared Properties
Declared Properties. The Objective-C declared properties feature provides a simple way to declare and implement an object's accessor methods ...
Read more >
Attributes - Documentation - Swift.org
Write accessor as the first argument to this attribute. ... The type must provide a main type function that doesn't take any arguments...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found