Comments (8)
I'd very much like to see the suggestion by @jongleur1983 implemented.
from exceptionalresharper.
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.
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.
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.
@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.
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.
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.
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)
- Full Guide for manual installation? HOT 8
- Optional exceptions not working HOT 7
- Options in General page are not saved in Visual Studio 2019 HOT 1
- SDK Update to Resharper 2020.2.x HOT 5
- Do not show AsyncConverter.AsyncWait error on finished tasks
- Ignores checked keyword
- Private protected methods ignored
- Inheritdoc with exception bug
- Change exceptional documentation style
- NullReferenceException - Object reference not set to an instance of an object.
- Change format of exception comment (specifically the type)
- 2019.1 Support? HOT 3
- Save problem with Checkboxes in Options HOT 3
- Exceptional not available in Extension Manager HOT 2
- 2019.2.x Support? HOT 14
- New Maintainer? HOT 5
- Autofixes for optional exceptions
- Exclude whole assemblies HOT 3
- 2019.3.x Support? HOT 3
- Nightly Build HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from exceptionalresharper.