riok / mapperly

A .NET source generator for generating object mappings. No runtime reflection.
https://mapperly.riok.app
Apache License 2.0
2.93k stars 147 forks source link

Configuration apis using enums are broken in visual studio 16.7+ #650

Closed pnquest closed 1 year ago

pnquest commented 1 year ago

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):

latonz commented 1 year ago

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?

pnquest commented 1 year ago

@latonz It works fine in 2.8.0. This behavior only appears when using 3.0.0. Definitely a weird one.

TimothyMakkison commented 1 year ago

As I'm using macOS I don't have access to VS and it works with the cli and in Rider.

Just tried it in rider and it works with 3.0.0

public partial global::ToObject Map(global::FromObject input)
{
    var target = new global::ToObject();
    target.StringField = input.Stringfield;
    return target;
}

I can try VS in a minute

pnquest commented 1 year ago

a bit more digging and I was able to get a stack trace from the generator:

'System.InvalidOperationException: Could not resolve enum reflection type of PropertyNameMappingStrategy or Riok.Mapperly.Abstractions.PropertyNameMappingStrategy is not supported
   at Riok.Mapperly.Configuration.AttributeDataAccessor.GetEnumValue(TypedConstant arg, Type targetType) in /_/src/Riok.Mapperly/Configuration/AttributeDataAccessor.cs:line 137
   at Riok.Mapperly.Configuration.AttributeDataAccessor.BuildArgumentValue(TypedConstant arg, Type targetType) in /_/src/Riok.Mapperly/Configuration/AttributeDataAccessor.cs:line 96
   at Riok.Mapperly.Configuration.AttributeDataAccessor.<Access>d__5`2.MoveNext() in /_/src/Riok.Mapperly/Configuration/AttributeDataAccessor.cs:line 56
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
   at Riok.Mapperly.Configuration.MapperConfiguration..ctor(SymbolAccessor symbolAccessor, ISymbol mapperSymbol) in /_/src/Riok.Mapperly/Configuration/MapperConfiguration.cs:line 16
   at Riok.Mapperly.Descriptors.DescriptorBuilder..ctor(Compilation compilation, ClassDeclarationSyntax mapperSyntax, INamedTypeSymbol mapperSymbol, WellKnownTypes wellKnownTypes, SymbolAccessor symbolAccessor) in /_/src/Riok.Mapperly/Descriptors/DescriptorBuilder.cs:line 36
   at Riok.Mapperly.MapperGenerator.BuildDescriptors(Compilation compilation, ImmutableArray`1 mappers, CancellationToken cancellationToken) in /_/src/Riok.Mapperly/MapperGenerator.cs:line 86
   at Riok.Mapperly.MapperGenerator.<>c.<Initialize>b__4_1(ValueTuple`2 x, CancellationToken cancellationToken) in /_/src/Riok.Mapperly/MapperGenerator.cs:line 32
   at Microsoft.CodeAnalysis.UserFunctionExtensions.<>c__DisplayClass0_0`2.<WrapUserFunction>b__0(TInput input, CancellationToken token)'.

Line numbers seem to have changed a bit, but that looks to be from here. https://github.com/riok/mapperly/blob/main/src/Riok.Mapperly/Configuration/AttributeDataAccessor.cs#L186

So it looks like this is returning null: https://github.com/riok/mapperly/blob/main/src/Riok.Mapperly/Configuration/AttributeDataAccessor.cs#L191

Maybe visual studio is loading libraries into the assembly differently than the cli.

TimothyMakkison commented 1 year ago

Nice digging 👍

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

TimothyMakkison commented 1 year ago

I'm assuming this applies to all Mapperly configurations enums, I'll experiment a little when I get the chance.

@latonz do you have a solution in mind? I'm considering:

latonz commented 1 year ago

I'm wondering what changed between 2.8.0 and 3.0.0 that this doesn't work anymore in VS 🤔 Riok.Mapperly does need a reference to Riok.Mapperly.Abstractions, it references and uses these enums directly.

TimothyMakkison commented 1 year ago

I'm wondering what changed between 2.8.0 and 3.0.0 that this doesn't work anymore in VS 🤔

AttributeDataAccessor was changed to convert types right? This became an issue because Mapperly started to use config objects. i.e. PropertyAccessor -> PropertyAccessorConfig

Riok.Mapperly does need a reference to Riok.Mapperly.Abstractions, it references and uses these enums directly.

I had issues where the benchmarks would fail because of this.

latonz commented 1 year ago

But the way how enum reflection types are resolved didn't change since the initial commit: https://github.com/riok/mapperly/blob/ad539c824a6e2920d49a2fac860d832e3cf269fc/src/Riok.Mapperly/Configuration/AttributeDataAccessor.cs#L61-L65 I'm just not sure what the real root cause is and I'd like to know that before we implement a fix.

TimothyMakkison commented 1 year ago

Did mapperly always convert enums inside the Mapper attribute? I found that the MapEnum attributes caused a conversion issue (causing the benchmarks to end prematurely). I don't think the other enums caused issues?

Around the same time I found the VS couldn't build the Mapperly project. I never knew if it was caused by a VS update or a change in Mapperly (might have been a change to the sln) Edit: related see #486. I had the opposite problem, could resolve Mapperly types but could not resolve foreign types.

This problem makes it difficult for me to find the cause of OPs issue in VS

hoyau commented 1 year ago

I've tested it on a old VS Version (17.5), where the Code Snippet still works. After upgrading to 17,7 I also get that error

TimothyMakkison commented 1 year ago

I've experimented with previous commits and found that Mapperly creates the below message between v2.8.0 and v2.9.0-next.1. I think that the commit 11995f0d support derived tyoe mappings may be the culprit. The error persists after rebuilding and restarting the IDE.

warning CS8785: Generator 'MapperGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'InvalidOperationException' with message 'Type Riok.Mapperly.Abstractions.EnumMappingStrategy, Riok.Mapperly.Abstractions not found'

I'd guess this is caused by the following:

var attrSymbol = compilation.GetTypeByMetadataName(attrFullName); if (attrSymbol == null) yield break;


```C#
var attrType = typeof(TAttribute);
var attrSymbol = compilation.GetTypeByMetadataName($"{attrType.Namespace}.{attrType.Name}");

v2.9.0-next.2 has the error `1>CSC : warning CS8785: Generator 'MapperGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'ArgumentException' with message 'Object of type 'Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel.FieldSymbol' cannot be converted to type 'Riok.Mapperly.Abstractions.EnumMappingStrategy'.' `

v2.9.0-next.3 has the error `1>CSC : warning CS8785: Generator 'MapperGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'InvalidOperationException' with message 'Could not resolve enum reflection type of EnumMappingStrategy or Riok.Mapperly.Abstractions.EnumMappingStrategy is not supported' `

~~This could be an unrelated problem but only impacts VS users ~~

TimothyMakkison commented 1 year ago

Pretty sure adding the following will fix the issue:

private static object? GetEnumValue(TypedConstant arg, Type targetType)
{
    if (arg.Value == null)
        return null;

     if (arg.Type?.ContainingAssembly.Name is "Riok.Mapperly.Abstractions")
         return arg.Value;

This appears to fix the issue on v3.0.0 next 1. I can't verify if it works on the latest commit because d0eb4714 prevents me from building this in Visual Studio.

Edit: I'm wrong. This lets you build and run the sample but the unit tests will fail

latonz commented 1 year ago

I think by directly casting without an assembly name check it should also work. I created #654 implementing this. Can you verify this? However, I still don't fully understand why and what exactly is happening. But without VS it is not really possible to dig into it...

latonz commented 1 year ago

If there seem to be more problems with the source generated polyfills in VS we may need to switch back to manually added polyfills. Otherwise all potential VS contributors would be locked out.

hoyau commented 1 year ago

Findings with VS:

There is also an issue that Debugging the Source Generator in VS is only possible if you downgrade the Riok.Mapperly.Sample project from net7.0 to net6.0 (don't know the reason for that yet).

If i want to build the Sample Project by using the VS msbuild i get the following Output:

msbuild /t:Build =>

MSBuild version 17.7.2+d6990bcfa for .NET Framework Build started 17.08.2023 19:47:34. Project "C:\Users\Justin\source\repos\mapperly\samples\Riok.Mapperly.Sample\Riok.Mapperly.Sample.csproj" on node 1 (Build target(s)). GenerateTargetFrameworkMonikerAttribute: Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files. CoreGenerateAssemblyInfo: Skipping target "CoreGenerateAssemblyInfo" because all output files are up-to-date with respect to the input files. CoreCompile: C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\Roslyn\csc.exe /noconfig /unsafe- /checked- /nowarn:1701,1702,1701,1702 /fullpaths /nostdlib+ /error report:prompt /warn:6 /define:TRACE;DEBUG;NET;NET6_0;NETCOREAPP;NET5_0_OR_GREATER;NET6_0_OR_GREATER;NETCOREAPP1_0_OR_GREATER;NETCOREAPP1_1_OR_GREATER;NETCOREAPP2_0_OR_GREATER;N ETCOREAPP2_1_OR_GREATER;NETCOREAPP2_2_OR_GREATER;NETCOREAPP3_0_OR_GREATER;NETCOREAPP3_1_OR_GREATER /highentropyva+ /nullable:enable /reference:"C:\Program Files\dotnet\packs\Mi crosoft.NETCore.App.Ref\6.0.21\ref\net6.0\Microsoft.CSharp.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\Microsoft.VisualBasic.Core .dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\Microsoft.VisualBasic.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCo re.App.Ref\6.0.21\ref\net6.0\Microsoft.Win32.Primitives.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\Microsoft.Win32.Registry.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\mscorlib.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ ref\net6.0\netstandard.dll" /reference:C:\Users\Justin\.nuget\packages\riok.mapperly\3.0.0\lib\netstandard2.0\Riok.Mapperly.Abstractions.dll /reference:"C:\Program Files\dotnet \packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.AppContext.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Buffers.d ll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Collections.Concurrent.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft .NETCore.App.Ref\6.0.21\ref\net6.0\System.Collections.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Collections.Immutable.dl l" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Collections.NonGeneric.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft. NETCore.App.Ref\6.0.21\ref\net6.0\System.Collections.Specialized.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.ComponentMode l.Annotations.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.ComponentModel.DataAnnotations.dll" /reference:"C:\Program Files \dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.ComponentModel.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\Syste m.ComponentModel.EventBasedAsync.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.ComponentModel.Primitives.dll" /reference:"C: \Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.ComponentModel.TypeConverter.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App .Ref\6.0.21\ref\net6.0\System.Configuration.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Console.dll" /reference:"C:\Progra m Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Core.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.D ata.Common.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Data.DataSetExtensions.dll" /reference:"C:\Program Files\dotnet\pac ks\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Data.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Diagnostics.Contrac ts.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Diagnostics.Debug.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft. NETCore.App.Ref\6.0.21\ref\net6.0\System.Diagnostics.DiagnosticSource.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Diagnost ics.FileVersionInfo.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Diagnostics.Process.dll" /reference:"C:\Program Files\dotn et\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Diagnostics.StackTrace.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\Sy stem.Diagnostics.TextWriterTraceListener.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Diagnostics.Tools.dll" /reference:"C: \Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Diagnostics.TraceSource.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\ 6.0.21\ref\net6.0\System.Diagnostics.Tracing.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.dll" /reference:"C:\Program Files \dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Drawing.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Drawi ng.Primitives.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Dynamic.Runtime.dll" /reference:"C:\Program Files\dotnet\packs\M icrosoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Formats.Asn1.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Globalization.C alendars.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Globalization.dll" /reference:"C:\Program Files\dotnet\packs\Microsof t.NETCore.App.Ref\6.0.21\ref\net6.0\System.Globalization.Extensions.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.IO.Compres sion.Brotli.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.IO.Compression.dll" /reference:"C:\Program Files\dotnet\packs\Micr osoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.IO.Compression.FileSystem.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.IO.Co mpression.ZipFile.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.IO.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft. NETCore.App.Ref\6.0.21\ref\net6.0\System.IO.FileSystem.AccessControl.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.IO.FileSy stem.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.IO.FileSystem.DriveInfo.dll" /reference:"C:\Program Files\dotnet\packs\Mi crosoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.IO.FileSystem.Primitives.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.IO.F ileSystem.Watcher.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.IO.IsolatedStorage.dll" /reference:"C:\Program Files\dotnet\ packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.IO.MemoryMappedFiles.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System. IO.Pipes.AccessControl.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.IO.Pipes.dll" /reference:"C:\Program Files\dotnet\packs \Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.IO.UnmanagedMemoryStream.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.L inq.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Linq.Expressions.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft. NETCore.App.Ref\6.0.21\ref\net6.0\System.Linq.Parallel.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Linq.Queryable.dll" /re ference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Memory.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21 \ref\net6.0\System.Net.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Net.Http.dll" /reference:"C:\Program Files\dotnet\packs \Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Net.Http.Json.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Net.HttpList ener.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Net.Mail.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore .App.Ref\6.0.21\ref\net6.0\System.Net.NameResolution.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Net.NetworkInformation.dl l" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Net.Ping.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Re f\6.0.21\ref\net6.0\System.Net.Primitives.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Net.Requests.dll" /reference:"C:\Pro gram Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Net.Security.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6 .0\System.Net.ServicePoint.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Net.Sockets.dll" /reference:"C:\Program Files\dotne t\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Net.WebClient.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Net.W ebHeaderCollection.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Net.WebProxy.dll" /reference:"C:\Program Files\dotnet\packs \Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Net.WebSockets.Client.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Net. WebSockets.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Numerics.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.N ETCore.App.Ref\6.0.21\ref\net6.0\System.Numerics.Vectors.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.ObjectModel.dll" /ref erence:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Reflection.DispatchProxy.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCo re.App.Ref\6.0.21\ref\net6.0\System.Reflection.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Reflection.Emit.dll" /reference :"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Reflection.Emit.ILGeneration.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore .App.Ref\6.0.21\ref\net6.0\System.Reflection.Emit.Lightweight.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Reflection.Exten sions.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Reflection.Metadata.dll" /reference:"C:\Program Files\dotnet\packs\Micro soft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Reflection.Primitives.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Reflection .TypeExtensions.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Resources.Reader.dll" /reference:"C:\Program Files\dotnet\pack s\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Resources.ResourceManager.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System .Resources.Writer.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Runtime.CompilerServices.Unsafe.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Runtime.CompilerServices.VisualC.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\ 6.0.21\ref\net6.0\System.Runtime.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Runtime.Extensions.dll" /reference:"C:\Progra m Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Runtime.Handles.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6 .0\System.Runtime.InteropServices.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Runtime.InteropServices.RuntimeInformation.d ll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Runtime.Intrinsics.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NET Core.App.Ref\6.0.21\ref\net6.0\System.Runtime.Loader.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Runtime.Numerics.dll" /re ference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Runtime.Serialization.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore .App.Ref\6.0.21\ref\net6.0\System.Runtime.Serialization.Formatters.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Runtime.Ser ialization.Json.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Runtime.Serialization.Primitives.dll" /reference:"C:\Program F iles\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Runtime.Serialization.Xml.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\r ef\net6.0\System.Security.AccessControl.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Security.Claims.dll" /reference:"C:\Pr ogram Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Security.Cryptography.Algorithms.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.Ap p.Ref\6.0.21\ref\net6.0\System.Security.Cryptography.Cng.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Security.Cryptography .Csp.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Security.Cryptography.Encoding.dll" /reference:"C:\Program Files\dotnet\p acks\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Security.Cryptography.OpenSsl.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0 \System.Security.Cryptography.Primitives.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Security.Cryptography.X509Certificate s.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Security.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.Ap p.Ref\6.0.21\ref\net6.0\System.Security.Principal.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Security.Principal.Windows.d ll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Security.SecureString.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft. NETCore.App.Ref\6.0.21\ref\net6.0\System.ServiceModel.Web.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.ServiceProcess.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Text.Encoding.CodePages.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NE TCore.App.Ref\6.0.21\ref\net6.0\System.Text.Encoding.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Text.Encoding.Extensions. dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Text.Encodings.Web.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NE TCore.App.Ref\6.0.21\ref\net6.0\System.Text.Json.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Text.RegularExpressions.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Threading.Channels.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore .App.Ref\6.0.21\ref\net6.0\System.Threading.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Threading.Overlapped.dll" /referen ce:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Threading.Tasks.Dataflow.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.A pp.Ref\6.0.21\ref\net6.0\System.Threading.Tasks.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Threading.Tasks.Extensions.dll " /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Threading.Tasks.Parallel.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft .NETCore.App.Ref\6.0.21\ref\net6.0\System.Threading.Thread.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Threading.ThreadPoo l.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Threading.Timer.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NET Core.App.Ref\6.0.21\ref\net6.0\System.Transactions.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Transactions.Local.dll" /re ference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.ValueTuple.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6. 0.21\ref\net6.0\System.Web.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Web.HttpUtility.dll" /reference:"C:\Program Files\d otnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Windows.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Xml.dll " /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Xml.Linq.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref \6.0.21\ref\net6.0\System.Xml.ReaderWriter.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Xml.Serialization.dll" /reference:" C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Xml.XDocument.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\r ef\net6.0\System.Xml.XmlDocument.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Xml.XmlSerializer.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\System.Xml.XPath.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\Syst em.Xml.XPath.XDocument.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\ref\net6.0\WindowsBase.dll" /debug+ /debug:portable /filealign:512 /gener atedfilesout:obj\Debug\net6.0\/generated /optimize- /out:obj\Debug\net6.0\Riok.Mapperly.Sample.dll /refout:obj\Debug\net6.0\refint\Riok.Mapperly.Sample.dll /target:exe /warnase rror- /utf8output /deterministic+ /langversion:10.0 /analyzerconfig:C:\Users\Justin\source\repos\mapperly\.editorconfig /analyzerconfig:obj\Debug\net6.0\Riok.Mapperly.Sample.Ge neratedMSBuildEditorConfig.editorconfig /analyzerconfig:"C:\Program Files\dotnet\sdk\7.0.400\Sdks\Microsoft.NET.Sdk\analyzers\build\config\analysislevel_6_default.editorconfig" /analyzer:"C:\Program Files\dotnet\sdk\7.0.400\Sdks\Microsoft.NET.Sdk\targets\..\analyzers\Microsoft.CodeAnalysis.CSharp.NetAnalyzers.dll" /analyzer:"C:\Program Files\dotnet\s dk\7.0.400\Sdks\Microsoft.NET.Sdk\targets\..\analyzers\Microsoft.CodeAnalysis.NetAnalyzers.dll" /analyzer:C:\Users\Justin\.nuget\packages\riok.mapperly\3.0.0\analyzers\roslyn4. 5\dotnet\cs\Riok.Mapperly.Abstractions.dll /analyzer:C:\Users\Justin\.nuget\packages\riok.mapperly\3.0.0\analyzers\roslyn4.5\dotnet\cs\Riok.Mapperly.dll /analyzer:"C:\Program F iles\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.21\analyzers/dotnet/cs/System.Text.Json.SourceGeneration.dll" Car.cs CarDto.cs CarMapper.cs Program.cs obj\Debug\net6.0\Riok.Map perly.Sample.GlobalUsings.g.cs "obj\Debug\net6.0\.NETCoreApp,Version=v6.0.AssemblyAttributes.cs" obj\Debug\net6.0\Riok.Mapperly.Sample.AssemblyInfo.cs /warnaserror+:NU1605 CSC : warning CS8785: Generator 'MapperGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of t ype 'InvalidOperationException' with message 'Could not resolve enum reflection type of EnumMappingStrategy or Riok.Mapperly.Abstractions.EnumMappingStrategy is not supported' [C :\Users\Justin\source\repos\mapperly\samples\Riok.Mapperly.Sample\Riok.Mapperly.Sample.csproj] C:\Users\Justin\source\repos\mapperly\samples\Riok.Mapperly.Sample\CarMapper.cs(10,34): error CS8795: Partial method 'CarMapper.MapCarToDto(Car)' must have an implementation part because it has accessibility modifiers. [C:\Users\Justin\source\repos\mapperly\samples\Riok.Mapperly.Sample\Riok.Mapperly.Sample.csproj] CompilerServer: server - server processed compilation - ebf579a2-f10a-470a-ada2-86fb6a75a659 Done Building Project "C:\Users\Justin\source\repos\mapperly\samples\Riok.Mapperly.Sample\Riok.Mapperly.Sample.csproj" (Build target(s)) -- FAILED. Build FAILED. "C:\Users\Justin\source\repos\mapperly\samples\Riok.Mapperly.Sample\Riok.Mapperly.Sample.csproj" (Build target) (1) -> (CoreCompile target) -> CSC : warning CS8785: Generator 'MapperGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'InvalidOperationException' with message 'Could not resolve enum reflection type of EnumMappingStrategy or Riok.Mapperly.Abstractions.EnumMappingStrategy is not supported' [C:\Users\Justin\source\repos\mapperly\samples\Riok.Mapperly.Sample\Riok.Mapperly.Sample.csproj] "C:\Users\Justin\source\repos\mapperly\samples\Riok.Mapperly.Sample\Riok.Mapperly.Sample.csproj" (Build target) (1) -> (CoreCompile target) -> C:\Users\Justin\source\repos\mapperly\samples\Riok.Mapperly.Sample\CarMapper.cs(10,34): error CS8795: Partial method 'CarMapper.MapCarToDto(Car)' must have an implementation pa rt because it has accessibility modifiers. [C:\Users\Justin\source\repos\mapperly\samples\Riok.Mapperly.Sample\Riok.Mapperly.Sample.csproj] 1 Warning(s) 1 Error(s) Time Elapsed 00:00:00.70

Also tried out a dotnet msbuild /t:Build with the latest 7 SDK (7.0.400, MSBuild 17.7.1), which produced following Output:

MSBuild version 17.7.1+971bf70db for .NET Riok.Mapperly.Sample -> C:\Users\Justin\source\repos\mapperly\samples\Riok.Mapperly.Sample\bin\Debug\net6.0\Riok.Mapperly.Sample.dll

Looks like VS MsBuild is doing some magic stuff...

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 3.1.0-next.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

latonz commented 1 year ago

@pnquest could you verify this issue is resolved with 3.1.0-next.2?

pnquest commented 1 year ago

@latonz Yep, that version works! Thanks!

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 3.1.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: