microsoft / SimpleStubs

*SimpleStubs* is a simple mocking framework that supports Universal Windows Platform (UWP), .NET Core and .NET framework. SimpleStubs is currently developed and maintained by Microsoft BigPark Studios in Vancouver.
Other
66 stars 29 forks source link

Preprocessing directives in namespace definitions not handled correctly #59

Open mawett opened 5 years ago

mawett commented 5 years ago

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.

nehmebilal commented 5 years ago

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.

mawett commented 5 years ago

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.

nehmebilal commented 5 years ago

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.