jhewlett / valueobject Goto Github PK
View Code? Open in Web Editor NEWA micro library for easily creating C# classes with value semantics. No need to override Equals, GetHashCode, et all.
License: MIT License
A micro library for easily creating C# classes with value semantics. No need to override Equals, GetHashCode, et all.
License: MIT License
Do you think this enhancement maybe usefull for cases, when same properties refer to different collections, but these collections contain same values?
Hello!
Improve comparisons floating-point numeric types. For example:
bool IsEqualsFloat(float x, float y) =>
Math.Abs(x - y) < 1e-7;
bool IsEqualsDouble(double x, double y) =>
Math.Abs(x - y) < 1e-15;
Hi,
SonarQube is giving out the warning with the following explanation:
When a class implements the IEquatable interface, it enters a contract that states, "I know how to compare two instances of type T or any type derived from T for equality.". However, if that class is derived, it is improbable that the base class will know how to make a meaningful comparison. Therefore that implicit contract is now broken.
Alternatively, IEqualityComparer provides a safer interface and is used by collections or Equals could be made virtual.
This rule raises an issue when an unsealed, public, or protected class implements IEquitable and the Equals are neither virtual nor abstract
I am looking forward to hearing your thoughts on it.
Thanks
bellow doesnt work(test fails) but it shuld imho.
`
using NUnit.Framework;
using Value;
namespace ValueObjectTests
{
[TestFixture]
public class ValueObjectTests
{
[Test]
public void EqualityTests()
{
IMyValueObject a = new MyValueObject();
IMyValueObject b = new MyValueObject();
var actual = a == b;
var expected = true;
Assert.AreEqual(expected, actual);
}
}
public interface IMyValueObject
{
string Val { get; }
}
public class MyValueObject : ValueObject, IMyValueObject
{
public string Val { get; } = "xxx";
}
}`
Is this project no longer maintained?
I will use this Value Object implementation (using #2 #4 #1 ) in my saas toolkit.
我使用了微软的Orleans,默认需要在类加上 [Serializable] 的attribute ,
但是如果我的类继承了: Value.ValueObject,就报错 Value.ValueObject 没有添加 [Serializable] 的attribute
I use Microsoft's Orleans. By default, I need to add [Serializable] attribute to the class.
But if my class inherits: Value.ValueObject, it is wrong that Value.ValueObject did not add the attribute of [Serializable].
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.