I suggest you ...

Compile to throw Doesn't Not Compile

Let's say you have a method
public void Foo()
{
SomeMethodThatDoesntExist();
}

Right Now this will not produce a dll, as it won't compile. Which will causes lot's of false positives and prevents me from testing other pieces of code until I fix that method.

I would like to suggest it DOES compile, but instead compiles to a method that throws a DOES NOT COMPILE exception.

Effectively:

public void Foo()
{
throw new DoesNotCompileException("[Insert Actually compilation message here"]);
}

This would allow me more freedom to work and test things as I go, plus would prevent a false run against an out of date dll.

10 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    llewellyn falcollewellyn falco shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    2 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • PhilippePhilippe commented  ·   ·  Flag as inappropriate

        The IDE already write thrown new NotImplementedException() in most method it generate when generating stub. Just do the same. And you can always add a code snippet like tni that would write the above code with 4 keystrokes...

      • QwertieQwertie commented  ·   ·  Flag as inappropriate

        I have had the same idea myself. IMO the compiler should have a mode where it replaces errors (whenever possible) with exceptions, and deals with errors outside function bodies in whatever way is most appropriate. e.g. syntax error in a class? Just ignore the error. A class contains a member with an unrecognized data type? Just omit that member from the emitted assembly, and throw an exception from any code that tries to access it.

      Feedback and Knowledge Base