Code Monkey home page Code Monkey logo

projection-tools's Issues

Figure out how make ContinuousIntegrationBuild work

image

dotnet validate package local ProjectionTools.1.0.11.nupkg 
Validating /home/dookie/Documents/projects/ProjectionTools/ProjectionTools.1.0.11.nupkg
• Source Link: ✅ Valid

• Deterministic (dll/exe): ❌ Non deterministic
    Ensure that the following property is enabled for CI builds
    and you're using at least the 2.1.300 SDK:
    <ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
    The following assemblies have not been compiled with deterministic settings:
    lib\netstandard2.0\ProjectionTools.dll

• Compiler Flags: ✅ Valid

dotnet/sdk#16325

Using NuGetPackageExplorer:

dotnet validate package local ProjectionTools.1.0.XX.nupkg

Add optional flag to force eager evaluation

Some errors may be observed only in runtime, we can add a flag to trigger eager evaluation and get immediate feedback on start. For example, it can be enabled only in debug mode.

Optional/Conditional mapping

Sometimes we may want to control when fields should be mapped.

    Projection<DepartmentEntity, DepartmentDto> DepartmentDtoProjection = new (
        (x, context) => new DepartmentDto
        {
            Name = x.Name,
             // marker compatible with delegates, can we keep original Description value?
            Description = context.When(context.WithDescription, x.Description /* default value? */)
        }
    );

dotnet/csharplang#5588

Rewrite extension methods

Custom extension methods break EF translation, but we can rewrite them.

public static readonly Projection<DepartmentEntity, DepartmentDto> DepartmentDtoProjection = new (
    x => new DepartmentDto
    {
        Name = x.Name,
        Status = x.Status.ToDtoStatus()
    }
);
public static StatusDto ToDtoStatus(this Status status)
{
    return StatusDtoProjection.Project(status);
}

Can be translated to:

public static readonly Projection<DepartmentEntity, DepartmentDto> DepartmentDtoProjection = new (
    x => new DepartmentDto
    {
        Name = x.Name,
        Status = StatusDtoProjection.Project(x.Status)
    }
);

Try source generators to avoid runtime compilation/decompilation

public static partial class Specifications
{
    private static readonly Specification<string> MySpec1Generate = new Specification<string>(x => x.Length > 0);

    private static readonly Specification<string> MySpec2Generate = new Specification<string>(x => x.Length > 5) && MySpec1Generate;

    private static readonly Specification<string> MySpec3Generate = new (x => MySpec2Generate.IsSatisfiedBy(x));
}

public static partial class SpecificationsGenerated
{
    public static readonly Specification<string> MySpec1 = new (x => x.Length > 0, x => x.Length > 0);

    public static readonly Specification<string> MySpec2 = new (x => x.Length > 5 && x.Length > 0, x => x.Length > 5 && x.Length > 0);

    public static readonly Specification<string> MySpec3 = new (x => x.Length > 5 && x.Length > 0, x => x.Length > 5 && x.Length > 0);
}

This can eliminate all expression machinery, delegate compilation and de-compilation.

How can we handle more complex cases when we reuse specification objects?

https://www.thinktecture.com/net/roslyn-source-generators-introduction/

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.