I'm trying to create a DiagnosticAnalyzer
that detects when a namespace declaration is different from the directory location in a project in VS.
Example:
Solution
- Project
- ProjectFolder
- MyClass.cs
namespace Project.ProjectFolder // Good
namespace Project.OtherSubNamespace // Bad, different from the location
The problem I'm facing right now, is to find the source path (relative to the project) from the current SymbolAnalysisContext in the analyzer. In a codefix provider, you would use the Document
class, but I'm not sure if it's possible from a SymbolAnalysisContext
.