Giter VIP home page Giter VIP logo

Comments (11)

leekelleher avatar leekelleher commented on July 28, 2024

I'm happy with removing the <T> constraint and using properties from the PropertyDescriptor - as you say, it makes sense!

re: Breaking changes... since we're currently following SemVer, we're still on v0.x - so completely within the realm of breaking changes. I know it is a pain in the arse for some devs to deal with these scenarios, but truth is that Ditto is still under active development (pre-release) - so until a v1.0 is released we have freedom to change APIs.

from umbraco-ditto.

Hendy avatar Hendy commented on July 28, 2024

👍

from umbraco-ditto.

JimBobSquarePants avatar JimBobSquarePants commented on July 28, 2024

Wizzzard! I was hoping you'd say that. 😄

from umbraco-ditto.

mattbrailsford avatar mattbrailsford commented on July 28, 2024

I need to get my head back round these as I haven't looked for a while. A couple of comments off the top of my head though.

By supporting generics, we do make this a bit easier in some places, such as using Enumerable.Empty< T>() to return an empty collection of type T, which you couldn't do if we didn't have a generic type. Also, with < T> we are requiring that T is a class, which is a requirement for the type converter to work (i think) so removing the generic type means you'll have to perform any relevant checks manually (if there are any).

Like I say, I'm not sure if any of these are a problem, I just looked through the code at where generics is being used in the current code, and how removing this will affect those.

I think the main original requirement for this was because .As< T> was the only way to use ditto originally, however with the addition of the .As(Type type) method added, it may not be as big a requirement.

from umbraco-ditto.

JimBobSquarePants avatar JimBobSquarePants commented on July 28, 2024

Those are fair points.

Enumerable.Empty is the trickiest of those to deal with, That can be invoked though, I think I need to make an EnumerableInvocator helper class somewhere to store the cached methods since I would have three then. Empty, Cast, and FirstOrDefault.

For the constraints... Type.IsValueType and Type.IsClass should cover that.

from umbraco-ditto.

Hendy avatar Hendy commented on July 28, 2024

Hi @mattbrailsford, perhaps I misunderstand, but can't an Emtpy collection of 'myType' be returned with:

return Enumerable.Empty<object>().Cast(myType);

where Cast(Type type) is an extension:

public static IEnumerable Cast(this IEnumerable iEnumerable, Type type)
{
    MethodInfo methodInfo = typeof(Enumerable).GetMethod("Cast");
    MethodInfo genericMethodInfo = methodInfo.MakeGenericMethod(type);

    return genericMethodInfo.Invoke(null, new[] { iEnumerable }) as IEnumerable;
}

from umbraco-ditto.

mattbrailsford avatar mattbrailsford commented on July 28, 2024

Probably. But now we need a custom Cast method, and IMO the result is less readable.

from umbraco-ditto.

Hendy avatar Hendy commented on July 28, 2024

arh, what @JimBobSquarePants has just said

@mattbrailsford but the end result is simpler syntax for the end consumer

from umbraco-ditto.

mattbrailsford avatar mattbrailsford commented on July 28, 2024

@Hendy fair point.

from umbraco-ditto.

JimBobSquarePants avatar JimBobSquarePants commented on July 28, 2024

We already have the Cast and FirstOrDefault ones. I'm happy to make the changes and I'll keep it as simple as possible.

from umbraco-ditto.

leekelleher avatar leekelleher commented on July 28, 2024

Closing this discussion thread. We can continue (if needed) on PR #55.

from umbraco-ditto.

Related Issues (20)

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.