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

Weird long #3361

Closed
CreateAndInject opened this issue Jan 4, 2025 · 1 comment
Closed

Weird long #3361

CreateAndInject opened this issue Jan 4, 2025 · 1 comment
Labels
Bug Decompiler The decompiler engine itself

Comments

@CreateAndInject
Copy link
Contributor

CreateAndInject commented Jan 4, 2025

Original:

using System;

internal class Program
{
    static void Main(string[] args)
    {
        My my = new My();
        switch (my)
        {
            case 1:
                Console.WriteLine(1);
                break;
            case 2:
                Console.WriteLine(2);
                break;
            case 3:
                Console.WriteLine(3);
                break;
        }
        Console.WriteLine("Hello World!");
    }

}

public class My
{
    public static implicit operator int(My my)
    {
        return 0;
    }
}

ILSpy

private static void Main(string[] args)
{
	My my = new My();
	switch (my)
	{
	case 1L: // Compiler Error CS0266, why is it a long?
		Console.WriteLine(1);
		break;
	case 2L:
		Console.WriteLine(2);
		break;
	case 3L:
		Console.WriteLine(3);
		break;
	}
	Console.WriteLine("Hello World!");
}
@CreateAndInject CreateAndInject added Bug Decompiler The decompiler engine itself labels Jan 4, 2025
@CreateAndInject
Copy link
Contributor Author

VisionLib.zip

@siegfriedpammer Add this reference, and code this:

using HalconDotNet;
using System;

internal class Program
{
    static void Main(string[] args)
    {
        HTuple tuple = new HTuple();
        switch ((int)tuple) // ILSpy doesn't generate (int) here, can't compile
        {
            case 1:
                Console.WriteLine(1);
                break;
            case 2:
                Console.WriteLine(2);
                break;
            case 3:
                Console.WriteLine(3);
                break;
        }
        Console.WriteLine("Hello World!");
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Decompiler The decompiler engine itself
Projects
None yet
Development

No branches or pull requests

1 participant