This project is read-only.
1
Vote

#error compiler error to suppress other compiler errors in member body

description

using System;

public class C {
    public string Name {
        get {
            #error TODO
        }
        set {
            #error TODO
        }    
    }
}
With Roslyn produces:
error CS1029: #error: 'Not implemented'
error CS1029: #error: 'Not implemented'
error CS0161: 'C.Name.get': not all code paths return a value
While with native compiler it produces:
error CS1029: #error: 'Not implemented'
error CS1029: #error: 'Not implemented'
While #error directive is very useful for tooling that generates code stubs, can we reduce the 'noise' of other compiler errors produced by Roslyn, bringing back old csc behavior in this case?

comments

AdamSpeight2008 wrote Jun 9, 2014 at 7:13 PM

As I see it the error error CS0161: 'C.Name.get': not all code paths return a value
is correct. The get method doesn't return anything.

The code stub should be corrected to include a value or have it throw an exception.
get
{
  #error ToDo
  Throw NotImplementedException();
}