-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
[Compat] Unhandled ArgumentException: operatorToken Parameter System.Half.explicit_operator checked byte (System.Half) #77101
Comments
@dotnet/area-infrastructure-libraries a new issue has been filed in the ApiCompat area, please triage |
Got a simple repro using ApiDiff. See the description. It seems we don't have any specialized if branch for a method of type "conversion". We only handle method of type "constructor". For everything else, we fallback to |
The sdk tools use net8.0 as target framework. I wonder if this is a case of a static explicit checked operator conversion not being available in that .NET version. This is the code that throws: public readonly struct Half
: IComparable,
ISpanFormattable,
IComparable<Half>,
IEquatable<Half>,
IBinaryFloatingPointIeee754<Half>,
IMinMaxValue<Half>,
IUtf8SpanFormattable,
IBinaryFloatParseAndFormatInfo<Half>
{
...
public static explicit operator byte(Half value) => (byte)(float)value;
public static explicit operator checked byte(Half value) => checked((byte)(float)value);
... This is where we should probably be handling a conversion method: But we end up falling to the try catch here, then throwing: |
I fed all runtime APIs to the tool and I found that the first |
@333fred was |
The exception comes from this method when the roslyn/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs Lines 303 to 308 in 1cf42ac
private static SyntaxKind GetOperatorSyntaxKind(string operatorName)
{
var operatorKind = CSharp.SyntaxFacts.GetOperatorKind(operatorName);
if (operatorKind == SyntaxKind.None)
{
throw new ArgumentException("Unknown operator kind."); |
This isn't the |
It was added in C# 11, .NET 7.0, but as Eric says, TFM isn't relevant for this type of question. |
Yeah, I found the bug was in OperatorDeclarationSyntax.OperatorToken in Syntax.xml. Working on a fix @333fred can you transfer this to Roslyn? |
Describe the bug
@ericstj and I saw this bug earlier last week when testing GenAPI.
I am now seeing it being hit by the ApiDiff implementation too, as the code that hits the bug is shared by this tool as well.
To Reproduce
Exceptions (if any)
Output message:
Further technical details
dotnet --info
I'm using VS Code.
The text was updated successfully, but these errors were encountered: