The special names op_Exponent and op_Exponentiation are not reserved for interop.

Open
#1,302 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Stale
Tech stack
csharp
Domain
documentation

Research direction

Start in standard/classes.md at §15.3.10.6, then compare the reserved-name references in the linked Roslyn and System.Linq.Expressions sources. Update the standard to include op_Exponent as reserved for operators, and confirm the wording covers the behavior described by the example.

Written by the indexing model from the issue text.

Description

Describe the bug
The special name op_Exponent is not reserved for interop, although Roslyn reserves and uses it.
https://github.com/dotnet/roslyn/blob/main/src/Compilers/Core/Portable/Symbols/WellKnownMemberNames.cs

The name is also recognized by System.Linq.Expressions along with op_Exponentiation.

It is missing from section §15.3.10.6 "Method names reserved for operators".

Example
Provide an example that shows the problem in the standard. A small code snippet that should be allowed or disallowed, or code that behaves differently than the standard.

void Main()
{
    var x = new HasExponent();
    var constant = Expression.Constant(x);
    var exponent = Expression.Power(constant, constant);
    Console.WriteLine(exponent.Method.Name);
}

class HasExponent
{
    [SpecialName]
    public static HasExponent op_Exponent(HasExponent left, HasExponent right) => new HasExponent();
}

Expected behavior
What should the standard declare differently?
Include op_Exponent as reserved.

Additional context
System.Linq.Expressions: https://github.com/dotnet/runtime/blob/main/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/BinaryExpression.cs#L2756

Dominant language
C#
Stars
815
Forks
99
Avg merge
1d 14h
Merged PRs (30d)
16

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/csharpstandard

All issues in dotnet/csharpstandard

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.