question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Configuration apis using enums are broken in visual studio 16.7+

See original GitHub issue

Describe the bug Starting with 3.0.0 the generator fails when using PropertyNameMappingStrategy.CaseInsensitive with error message.

Could not resolve enum reflection type of PropertyNameMappingStrategy or Riok.Mapperly.Abstractions.PropertyNameMappingStrategy is not supported.

Cleaning and rebuilding as well as cleaning, closing VS and deleting the .vs folder and reopening did not resolve the issue. Everything seems to build fine using the dotnet cli.

To Reproduce Try to build the sample code below from visual studio 2022.

Expected behavior The generator should complete without error and Stringfield should be mapped to StringField

Code snippets

using Riok.Mapperly.Abstractions;

namespace ConsoleApp1
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var mapper = new Mapper();
            var from = new FromObject
            {
                Stringfield = "test"
            };

            var to = mapper.Map(from);

            Console.WriteLine(to.StringField);
        }
    }

    public class FromObject
    {
        public string Stringfield { get; set; }
    }

    public class ToObject
    {
        public string StringField { get; set; }
    }

    [Mapper(PropertyNameMappingStrategy = PropertyNameMappingStrategy.CaseInsensitive)]
    public partial class Mapper
    {
        public partial ToObject Map(FromObject input);
    }
}

Environment (please complete the following information):

  • Mapperly Version: 3.0.0
  • .NET Version: 6.0.411
  • Target Framework: net6.0
  • IDE: Visual studio 17.6.2
  • OS: Windows 10

Issue Analytics

  • State:closed
  • Created a month ago
  • Comments:20 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
TimothyMakkisoncommented, Aug 15, 2023

Nice digging 👍

I can recreate the issue, VS doesn’t run for me. Even after restarting

2reactions
latonzcommented, Aug 15, 2023

As I’m using macOS I don’t have access to VS and it works with the cli and in Rider. Does it work again if you downgrade to 2.8.0?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swagger C# Enum generation - underlying int values do ...
My server is running using AspNetCore.App 2.2.0. It's configured in Startup.cs with swashbuckle aspnetcore 4.0.1 to generate a swagger json file ...
Read more >
Visual Studio 2019 version 16.10 Release Notes
Get the latest features, bug fixes, and support for Visual Studio 2019 v16.10. ... Graphics Debugger - Shader-Debugging broken after update to 16.10.3?...
Read more >
When are enums NOT a code smell?
IMHO, when transmitting data using enums to indicate that a field can have a value from a restricted (seldom changing) set of values...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found