Giter VIP home page Giter VIP logo

Comments (8)

cmeeren avatar cmeeren commented on June 23, 2024 2

I'd very much like to see the suggestion by @jongleur1983 implemented.

from exceptionalresharper.

cmeeren avatar cmeeren commented on June 23, 2024 1

Is there any chance of the suggestion by @jongleur1983 being implemented? As it currently stands, Exceptional is more or less useless when making heavy use of interfaces (e.g. for DI), which is a shame, because it's a great extension.

from exceptionalresharper.

jongleur1983 avatar jongleur1983 commented on June 23, 2024 1

Additional hint for the topic (got the idea just now): In case the interface in question is marked internal (thus visible inside the project only), we could assume to find all implementations inside the project, because classes outside the project can't see - and thus not implement the interface.

A minor exception to this are external projects marked as "friends" by the InternalsVisibleTo attribute (see https://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute(v=vs.110).aspx defined in the AssemblyInfo of the interfaces project (thanks @oopbase for your blogpost).
Main usage for this attribute is, I think, testing (to make internal classes visible to test projects), where it may not be that important that Exceptional can't enforce guidelines.

from exceptionalresharper.

jongleur1983 avatar jongleur1983 commented on June 23, 2024

I'm not sure if it's useful to warn on the interface itself, as that may be implemented outside of the accessible code by other implementations throwing arbitrary exceptions.

A slightly different approach might be to discover exceptions on interface usage transparently:
When a method is called on an interface, a warning could be emitted for any exception type any known implementation throws.

from exceptionalresharper.

jongleur1983 avatar jongleur1983 commented on June 23, 2024

@cmeeren I'm happy to assist with anything if there's a reasonable proposal on how this might work.
Biggest showstopper for now (conceptually) seems to be that exceptions are not declared on interfaces and the implementing classes might not be known.

Let's consider an interface A and classes A1, A2, A3 implementing A.
Let's assume, A1 throws Exceptions of type E1, A2 throws Exceptions of type E2 and A3 throws exceptions of type E3.

First question: What's the expected behaviour of Exceptional now?
To work reliably, Exceptional would have to demand for documentation of all three types on the interface (that is, E1, E2 and E3), because as any of the implementations may be used for A, any can be thrown.

So far from a technical point of view this would be possible to implement if - and only if - all possible implementations of the A are known to Exceptional: Any implementation in external code or libraries may be hidden in binary files representing compiled code, so that Exceptional even in theory can't get the required information.

What might be possible is the other way around, something that may help when coding:

  • When writing/editing a class C that implements an interface IC, check if that interface documents all thrown exceptions, and warn if not.
  • Code completions given to the developer in class C could be "add exception documentation for exception type E to interface IC", adding the comment.

The overall issue to find all missing exceptions on the other hand might be a different thing, e.g. be used by a roslyn compiler step returning issues for any missing documentation on interfaces, but not sure how that would work exactly.

from exceptionalresharper.

cmeeren avatar cmeeren commented on June 23, 2024

So far from a technical point of view this would be possible to implement if - and only if - all possible implementations of the A are known to Exceptional

Since ReSharper can do solution-wide analysis, I guess this is not a problem?

from exceptionalresharper.

ManticSic avatar ManticSic commented on June 23, 2024

Better late than never... Thanks for that great idea.
This would be a larger change, so first we will fix some smaller ones and than look at this again.

from exceptionalresharper.

JeremyMorton avatar JeremyMorton commented on June 23, 2024

In general, I consider the exceptions thrown to be a part of an interface's contract, so it would be good to have Exceptional let me know when I have an implementation of an interface that throws more than the interface's contract says it can so that I can expand the interface's contract or not throw different types than the existing contract.

from exceptionalresharper.

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.