It is not possible to configure a mapping between an open generic type and a nongeneric or closed generic type
See original GitHub issueThe problem preventing open generic to nongeneric mappings (e.g. Id<>
to int
) and vice versa:
TypePair.GetOpenGenericTypePair
returns null unless both types are open generic types. Its only usage is in MapperConfiguration.FindClosedGenericTypeMapFor
. Repro for this problem. I think I found a solution to this problem.
To enable mapping an open generic to closed generic (e.g. Id<>
to Value<int>
) and vice versa, another lookup may be required.
Issue Analytics
- State:
- Created 8 years ago
- Comments:32 (23 by maintainers)
Top Results From Across the Web
AutoMapper Open Generics Mapping Not Working
I am trying to setup a map to utilize open generics, but it never works at runtime. I'm using AutoMapper 5.2 in .NET...
Read more >Open Generics
Type version of CreateMap to create your open generic type maps. From there, you can use all of the mapping configuration available and...
Read more >Open and Closed Generic Types in C# | Pluralsight
Types in C# have two main categories: value and reference types. Both may be generic types, which take one or more type parameters....
Read more >Advanced Scenarios — Simple Injector 5 documentation
Registering open generic types and working with partially-closed types; Mixing collections of open-generic and non-generic components; Resolving Covariant/ ...
Read more >Generics: in, out, where
First, generic types in Java are invariant, meaning that List<String> is not a subtype of List<Object> . If List were not invariant, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
And the last part is that it needs to be on NuGet as a non-pre-release package. There’s a deal with NuGet packages that if your package depends on a pre-release, then you have to mark as pre-release.
To be toooooootally transparent here, I’m waiting for .NET Core RC2 - not ASP.NET Core RC2. ASP.NET RC2 does not have a date yet (https://github.com/aspnet/Mvc/milestones). Yes this confused me too.
The reason why I’m waiting is for the new netstandard TFN to be available in VS and all the other tools.