Comments (4)
A first, library copies fields, not properties. It conception of library. E.g. we have such pseudo code
public int A
{
get
{
return Database.Read("A");
}
set
{
Database.Write("A", value);
}
In this code we do not have real properties, but have complex logic which can cause strange behavior on copying.
Also, there are can be next situation with virtual methods which have different implementations in derived types.
pubic abstract void ValidateStructure();
public int A
{
get
{
return _a;
}
set
{
ValidateStructure(value);
value = _a;
}
As result we can receive object in acceptable state.
I understand, that for simple situations dumb decision can work without problem, but many people uses this library to copy complex objects and situation when after copying in rare cases code can fail - seem really bad. It hard to debug and understand situation.
from deepcloner.
Currently, it forbidden in code due possible unstable behavior. I'll think about ability to enable this functionality, if I found, that it won't cause strange runtime errors due inconsistent object state.
from deepcloner.
Upvoted.
Why it would cause strange runtime errors? Do I sense correctly some old/bad memories from C++ days? ;-)
Background info: my scenario is like this, I try to keep my code as KISS as possible, so for data transfer types and DB types I keep common core type. To copy data from one to other such method would do this in one call.
from deepcloner.
Thank you for detailed explanation, those are valid points for sure.
But also partial copy for POCO types is valid need. So just thinking aloud, until something better appear (or idea will be burried) -- when the exception is thrown for inheritance reason, this part of code does not affect current valid uses. So there could be additional step just before exception to check if the types have any custom method. If no -- it is a POCO type and it could be copied (new feature), if it has custom methods -- exception as today.
from deepcloner.
Related Issues (20)
- This exception is occasionally thrown in clones βmust be writeable (Parameter 'left')β HOT 4
- Request for info (country of origin) HOT 4
- HashSet contains method return false after deep clone HOT 8
- Support for cloning child to parent type HOT 2
- the program crashed when i deepclone opencvsahrp Mat HOT 3
- Latest change has not been published to NuGet HOT 1
- Why version 0.X? HOT 3
- Exception: An instance of the __ComObject type cannot be created unless the type has been obtained using GetTypeFromProgID or GetTypeFromCLSID. HOT 4
- program crashed when deepclone multidimensional zero-length array HOT 1
- Dependency on BinaryFormatter? HOT 1
- Possible Heap Corruption and Garbage Collection Interference... HOT 4
- When Object have navigation property, DeepClone throw exception. HOT 5
- Better error reporting HOT 1
- No stable cloning of `System.Drawing.Font` object HOT 6
- Memory corruption and program crash when cloning TaskCancelledException
- NHibernate Invalid cast exception
- Can't clone dictionary HOT 4
- Clone Action<T> delegate is incorrect
- Netstandard upgrade HOT 1
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 deepcloner.