Git Product home page Git Product logo

Comments (10)

SGStino avatar SGStino commented on June 1, 2024 2

No worries, if only dotnet's ElementAt would have checked for IReadOnlyList instead of IList :)

But, is it breaking? IReadOnlyList implements IReadOnlyCollection, so all code that works now, should remain working?
It might need recompiling, not 100% sure how the CLI handles that at runtime, is the return type part of the signature?

from json-everything.

SGStino avatar SGStino commented on June 1, 2024 1

Doesn't matter, it still doesn't like it:

Unhandled exception. System.MissingMethodException: Method not found: 'System.Collections.Generic.IReadOnlyCollection`1<Char> MethodSignatureTest.Lib.Extensions.GetContents(System.String)'.
   at Program.<Main>$(String[] args)

When i update only the called assembly from:

namespace MethodSignatureTest.Lib
{
    public static class Extensions
    {

        public static IReadOnlyCollection<char> GetContents(this string data)
        {
            return data.ToCharArray();
        }
    }
}

to:

namespace MethodSignatureTest.Lib
{
    public static class Extensions
    {

        public static IReadOnlyList<char> GetContents(this string data)
        {
            return data.ToCharArray();
        }
    }
}

while living the calling assembly intact:

using MethodSignatureTest.Lib;

var bytes = "hello world".GetContents();

Console.WriteLine("Hello, World:" + bytes.Count);

So yes, the return type is not part of the signature for compilation, but once compiled, it does matter.

from json-everything.

gregsdennis avatar gregsdennis commented on June 1, 2024

Yeah, I can update those, but it would be a breaking change, so it could be a bit. For now, feel free to just cast them. I'm not doing any transformations from the keywords, so a direct cast will work.

from json-everything.

gregsdennis avatar gregsdennis commented on June 1, 2024

Return type is part of the signature, but I think you're right. This would be breaking if these methods were on an interface, but not as static methods.

from json-everything.

elgonzo avatar elgonzo commented on June 1, 2024

No, return type is NOT part of the signature. That's why you can't have method overloads that only differ in return type. ;-)

from json-everything.

elgonzo avatar elgonzo commented on June 1, 2024

So yes, the return type is not part of the signature for compilation, but once compiled, it does matter.

Oh dang, you're right.

from json-everything.

gregsdennis avatar gregsdennis commented on June 1, 2024

@SGStino would you like to submit a PR for these changes?

from json-everything.

SGStino avatar SGStino commented on June 1, 2024

Sure, I'll have a look.

Is there any particular reason the enum keyword is build around a collection instead of a list? Shall I take that one with the rest or leave it?

from json-everything.

gregsdennis avatar gregsdennis commented on June 1, 2024

A collection is more general. There's no reason you should need to access them with an index.

They should also all be read-only.

from json-everything.

SGStino avatar SGStino commented on June 1, 2024

Then it should be #707?

from json-everything.

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.