Code Monkey home page Code Monkey logo

Comments (7)

Prinsn avatar Prinsn commented on May 27, 2024

Okay, so I figured out part of my problem, there's double wrapping so there's an outer type that I wasn't aware of.

However, I don't think IQueryable should be testing as an abstract interface?

from ntypewriter.

NeVeSpl avatar NeVeSpl commented on May 27, 2024

It looks like from the compiler's perspective interface is an abstract type. I do not understand your problem, and the code that you provided definitely does not give the above results. Bool is a primitive type, thus TypescriptModelName will end on the first if.

public IQueryable<bool> Foo()
{
    return null;
}

public bool Foo2()
{
    return false;
}
{{- for method in class.Methods | Symbols.ThatArePublic }}
    {{ method.Name  }}  
    {{ method.ReturnType}}
    {{ Custom.TypescriptModelName method.ReturnType }}
    {{ method.ReturnType.IsAbstract }}
    {{ method.ReturnType.IsInterface }}
    {{ method.ReturnType.IsPrimitive }}
{{- end }}
Foo  
IQueryable<bool>
boolean
true
true
false
Foo2  
bool
boolean
false
false
true

from ntypewriter.

Prinsn avatar Prinsn commented on May 27, 2024

from ntypewriter.

RudeySH avatar RudeySH commented on May 27, 2024

Just because you can't use the abstract keyword when typing an interface, that doesn't mean an interface is not abstract.

Consider this about abstract classes:

  • You can't instantiate abstract classes with new. The same is true for interfaces.
  • When inheriting from an abstract class, you have to implement all abstract methods. This is similar to interfaces, when you implement an interface you have to implement all methods.

Interfaces are abstract.

If you think this is incorrect, then reflection is incorrect. The following writes "True":

Console.WriteLine(typeof(IEnumerable).IsAbstract); // True

from ntypewriter.

Prinsn avatar Prinsn commented on May 27, 2024

from ntypewriter.

NeVeSpl avatar NeVeSpl commented on May 27, 2024

Reflection is not wrong, it is how the C# language was designed. And you will find many more similar cases when you spend more time with static code analysis.

from ntypewriter.

Prinsn avatar Prinsn commented on May 27, 2024

I disagree.

from ntypewriter.

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.