Comments (6)
I would like to keep mapping rules quite obvious and "detect slight variation in property name" could result in complicated logic and the outcome could be far away from expected for different use cases. The second option with not overriding entire method requires add some merging logic. I was thinking about adding option to assign default value for unmapped target fields which could help to spot places with naming discrepancy or missing fields. For now to avoid complete method overriding you can write line with assigning source to destination
public override void Convert(T1 source, T2 destination)
{
destination = source;
}
and try to apply another code fix which comes with MaggingGenerator that create conversion (the bulb should appear in line with the assignment).
from mappinggenerator.
Ok, but the problem is maintainability. No way you generate the mapping once and never change it. Some properties will be added, some will be removed.
I can't imagine having to remove the code, writing target = source,, alt-enter, Generate, each time to update the mapping.
I know the problem is not trivial, but I need a tool to quickly generate mapping code and also, update the mapping efficiently.
What do you think?
from mappinggenerator.
I don't see the problem with maintainability. In most cases you add or remove single field, so it's not big effort to apply this simple modification manually instead of regenerating the whole mapping. What if in the meantime somebody add custom, non-trivial mapping logic? How am I supposed to detect that and perform merging during regeneration? How to decide if this modification is still valid and should survive the regeneration?
from mappinggenerator.
If the target or source property is already used, skip it?
from mappinggenerator.
sounds simple, and if the method flow is simple (no conditional or loop statements) it could work. Anyway I think it should be registered as separated code fix - with the update purpose.
from mappinggenerator.
I'm not going to implement a synchronization mechanism. If you need a mapping code that is continuously synchronized with models, please take a look at OnBuild
plugin (#79) that generates mapping code during the build.
from mappinggenerator.
Related Issues (20)
- NullReferenceException on omitted type parameter HOT 4
- Source Generators HOT 4
- Mapping properties of one type on another HOT 1
- Inconsistent behaviour HOT 17
- Implement Clone Method refactoring has issues with arrow functions
- Allow different spellings for comparison HOT 6
- Use the existing instance instead of creating a new one HOT 9
- Generate unit tests HOT 3
- Suggestion: Scaffold invocation on multiple lines. HOT 2
- Suggestion: Varying sample data HOT 3
- Could not load type 'MappingGenerator.Features.CodeFixes.ExplicitConversionCodeFixProvider' HOT 12
- How do I "Verify your Roslyn integration option in case you are using R#."? HOT 2
- VSCode extention ? HOT 1
- ValueCollection appears to cause crash on Quick Action HOT 3
- UnitTest generator? HOT 2
- Visual Studio Performance slowing down HOT 1
- Fix NuGet package OnBuildGenerator HOT 4
- Improve interaction with `[InitRequired]` HOT 6
- Mapping from nullable structs to simple value handled incorrectly
- Generating mapping expression for C# 9 positional records HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mappinggenerator.