Code Monkey home page Code Monkey logo

alloverit's Issues

AllOverIt.Extensions.DoubleExtensions remove Epsilon

At current, the DoubleExtensions class has a defined constant const double Epsilon = 1E-07.
I propose removing it to use the build-in double.Epsilon, then adding overloads to allow for custom variance, which seems to be the more modern approach in many other libraries.

This old post on StackOverflow describes that:

The System.Double type can represent values accurate to up to 15 digits. So a simple first order estimate if a double value x is equal to some constant is to use an epsilon of constant * 1E-15

Another post on the same thread suggests their own implementation, should you wish to keep a default variance:

/// <summary>
/// smallest such that 1.0+EpsilonD != 1.0
/// </summary>
public const double EpsilonD = 2.2204460492503131e-016;

AllOverIt.EntityFrameworkCore.Diagrams Does Not Work With The .NET Options Pattern

Describe the bug
.NET uses the Options Pattern to provide configuration.

The D2ErdGenerator constructor requires an "ErdOptions" class. However, it does not accept an IOptions<ErdOptions> or similar. This means that it cannot be instantiated by dependency injection without hacks.

To Reproduce
Steps to reproduce the behavior:

  • Add the AllOverIt.EntityFrameworkCore.Diagrams package.
  • Use the default options: builder.Services.Configure<ErdOptions>(options => {});
  • Register the service builder.Services.AddSingleton(D2ErdGenerator)();
  • Add an endpoint app.MapGet("/DbDiagram", (D2ErdGenerator generator, MyDbContext dbContext) => generator.Generate(dbContext));

Expected behavior
The ERD string is generated.

** Actual behavior**
Crashes.

Additional context
This can be hacked around with the following: builder.Services.AddTransient( serviceProvider => serviceProvider.GetRequiredService<IOptions<ErdOptions>>().Value );

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.