FSharp.UMX
ValueOf
FSharp.UMX | ValueOf | |
---|---|---|
4 | 9 | |
152 | 833 | |
1.3% | - | |
0.0 | 0.0 | |
15 days ago | about 1 year ago | |
F# | C# | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
FSharp.UMX
-
No autocomplete for F# record labels when defining instances?
Note that % Guid.NewGuid() is just syntax for a more strongly typed Guid - see FSharp.UMX for more info.
-
Primitive Obsession
UoM doesn't natively support strings/guids, so I use this library: https://github.com/fsprojects/FSharp.UMX
-
F# Units of Measure
You can define type aliases with units of measure for any existing type using the MeasureAnnotatedAbbreviation attribute, although casting them correctly can be tricky. FSharp.UMX implements aliases and conversions for some standard types; the same technique can be used for BigInt and Complex.
ValueOf
-
Robust Design through Value Objects in C#
As we anticipate advancements in C#, we can still forge ahead with crafting resilient applications by utilizing the "ValueOf" package as a provisional solution. Below, we create a validated EmailAddress class leveraging the package:
-
Check out new C# 12 preview features! - .NET Blog
Probably better to use something like https://github.com/mcintyre321/ValueOf until we get a better solution (if we ever do). I agree that this is a pitfall.
-
Strong typedefs
The problem you’re describing here I think is ‘primitive obsession’, and the solution you’ve described is I think essentially a value object. This library might be useful https://github.com/mcintyre321/ValueOf
-
New Exception helpers in .NET 8
It lacks compile-time validation (though an analyzer that at least detects validation errors in the constructor should be fairly easy; more complicated flow control cases are probably hard), but at runtime, https://github.com/mcintyre321/ValueOf would let you do that.
- The power of OneOf. Unions for C#
-
Class vs Struct
If you want to wrap a small number of properties in a type to avoid primitive obsession, consider using ValueOf.
-
Is there anyway to override default values of the decimal type in c#?
You might be able to create a wrapper type with something like ValueOf.
-
Primitive Obsession
I good library I've found for addressing this issue is https://github.com/mcintyre321/ValueOf
What are some alternatives?
StringlyTyped - A cure for StringlyTyped software and PrimitiveObsession
OneOf - Easy to use F#-like ~discriminated~ unions for C# with exhaustive compile time matching
eShopOnWeb - Sample ASP.NET Core 8.0 reference application, powered by Microsoft, demonstrating a layered application architecture with monolithic deployment model. Download the eBook PDF from docs folder.
EngineeringUnits - Working with units made easy with automatic unit-check and converting between units
coolstore-microservices - A full-stack .NET microservices build on Dapr and Tye
csharplang - The official repo for the design of the C# programming language
UnitsNet - Makes life working with units of measurement just a little bit better.
LikeType - Provides 'typedef' type functionality to C#
Vogen - A semi-opinionated library which is a source generator and a code analyser. It Source generates Value Objects
Rop.OneOfExtensionGenerator - OneOf Helper Extensions Source Generator