The ProjectItem.FileCodeModel and conditional compilation
Recently I was playing with the FileCodeModel of a ProjectItem that used conditional compilation to provide some methods in "Debug" configuration (but not in "Release" configuration) such as:
Public Sub Method1()
#If DEBUG Then
Public Sub Method2()
Public Sub Method3
Which code elements (methods) would return the FileCodeModel in such case when the active configuration is "Release"? It would honor the conditional compilation? It happens that yes, for the "Release" configuration the FileCodeModel returns methods #1 and #3, but not method #2. Is that good or bad? I tend to think that most of the time you will want that behavior. For example, if you are writing an add-in to review code elements (for dead code, etc.), you only want to deal with code elements that actually exist for your current configuration. In other scenarios this is not so good. For example, if you are writing a feature to sort code elements (by name, scope, etc.) you don't want to leave methods out. But overall I think that Microsoft did it right honoring the conditional compilation.