Youness Kafia
Youness Kafia

Reputation: 183

Xamarin Resource.Designer.cs generating const instead of static

I have on .NET 6 project using xamarin.android where the resource designer file generated with an error CS0131 : The left-hand side of an assignment must be a variable, property or indexer:

public static void UpdateIdValues()
{
    global::MyGame.Resource.Color.alignment_marker_color = global::MyGame.Resource.Color.alignment_marker_color;
    global::MyGame.Resource.Color.white_transparent = global::MyGame.Resource.Color.white_transparent;
    global::MyGame.Resource.Dimension.alignment_marker_height = global::MyGame.Resource.Dimension.alignment_marker_height;
    // ...
}

with values generated like so :


public partial class Color
{
            
    // aapt resource value: 0x7F010000
    public const int alignment_marker_color = 2130771968;

    // aapt resource value: 0x7F010001
    public const int white_transparent = 2130771969;
    // ...

}

Is it an issue with the xamarin dependency ? If so, is it something i can solve through nuget ? dotnet workload ?

Upvotes: 2

Views: 374

Answers (1)

Stuart
Stuart

Reputation: 267

I had this issue myself, and after much trial and error, I found that the issue was caused by me having two assemblies, both containing Resources which had the same "Default Namespace" in their project properties.

After changing the namespace in one of them, deleting the bin and obj folders, running a Clean (overkill) I was able to successfully rebuild the project without error.

Upvotes: 4

Related Questions