StefH/ProxyInterfaceSourceGenerator

Invalid code is generated for some locales (e.g. sv-ES)

rogeralsing opened this issue · 10 comments

How to reproduce:

New empty console app:

Add following Nugets:

  • Akka.Remote
  • ProxyInterfaceGenerator

In Program.cs:

using Akka.Actor;

[ProxyInterfaceGenerator.Proxy(typeof(LocalActorRefProvider))]
public partial interface ILocalActorRefProvider
{
}

This results in the following build errors:

Skärmavbild 2022-12-12 kl  11 32 37

StefH commented

@rogeralsing
When I use your example code, it works just fine?

Can you take a look at this example : https://github.com/StefH/ProxyInterfaceSourceGenerator/tree/akka/src-examples/ProxyInterfaceConsumerForAkka

I get the same error
Skärmavbild 2022-12-12 kl  23 24 35

I do have a hunch on what this is.
dotnet/runtime#26778

The dash there is which is not the same as - minus (see how the first is wider).

StefH commented

@rogeralsing
Can you please go to "dependencies --> analyzers --> ProxyInterfaceSourceGenerator" and copy-paste the generated C# file which causes compile errors?

image

The generated code is full of these invalid variable names:

Skärmavbild 2022-12-13 kl  08 05 06

        public int DefaultValue(int x = 100)
        {
            int x_ = x;
            var result_378509684 = _Instance.DefaultValue(x_);
            return result_−378509684;
        }
StefH commented

I see. Thank you very much for your analysis. I know the cause from this error, I'll keep you up to date here on the progress.

StefH commented

@rogeralsing
Issue is related to this line: https://github.com/StefH/ProxyInterfaceSourceGenerator/blob/main/src/ProxyInterfaceSourceGenerator/Extensions/StringExtensions.cs#L26 , I'll fix this.

Some questions:

  • Do you use Rider or a different visual studio?
  • What is your locale / country on your PC?

Swedish locale.
Mac
Rider

I believe the issue at hand here is Mac (Or even *Nix?) that the minus sign is a different character.
I'm not sure if this is related to specifically Swedish locale.
That is actually the locale used in this bugreport:
dotnet/runtime#26778 (comment)

StefH commented

@rogeralsing
Code is fixed, a new NuGet will be released shortly.

Awesome! thanks