SimpleStubs icon indicating copy to clipboard operation
SimpleStubs copied to clipboard

Preprocessing directives in namespace definitions not handled correctly

Open mawett opened this issue 6 years ago • 3 comments

#endif is always missing in generated stubs, when the interface has namespace definition with preprocessor directives. Example:

namespace myProject.sublibrary
{
    using System;
    using System.Collections.Generic;
    using System.IO;
#if WinIoT
    using System.Threading.Tasks;
#else
    using myProject.ThreadingLib
#endif

In this case the generated stubs contain the #if statement, but no #else or #endif and therefore no build is possible.

mawett avatar Jul 22 '19 08:07 mawett

Sounds like a bug. I don't think preprocessor definitions are not handled at all (see here for how usings are being carried over to stubs). We would need to explicitly handle preprocessor definitions.

Please take a look at developers documentation for how to get started and it shouldn't be too hard to add handling for preprocessor definitions. I am happy to answer any questions.

nehmebilal avatar Sep 05 '19 10:09 nehmebilal

Ok, thanks for the hint where to start. I will take a look. However, it might take some time until I get around to it. Additionally, I have not yet worked with the Roslyn Code Analysers, so I'll have to look into that as well. I'll get back to you if I have any concrete questions.

mawett avatar Sep 09 '19 08:09 mawett

Sounds good @mawett. It's a bit tricky because preprocessor definitions can be around anything, not just usings, and they are not being handled at the moment.

nehmebilal avatar Sep 09 '19 10:09 nehmebilal