feat(csharp): do not consider namespace a definition, consider file namespace a scope
What does this MR do and why?
This MR refactors the C# parser to treat file-scoped namespaces as scoping mechanisms instead of definitions. For the following C# code:
namespace MyFileScopedNamespace;
class MyClass {
void MyMethod() {}
}
The resulting FQN for MyMethod will be MyFileScopedNamespace.MyClass.MyMethod when previously it was MyClass.MyMethod.
The key changes are:
-
Namespaces are no longer definitions: The
CSharpDefinitionType::Namespacetype was removed. Namespaces are now treated purely as scoping constructs and are excluded from the list of definitions. - File-scoped namespaces define the root FQN: File-scoped namespaces are now correctly identified as the root of the Fully Qualified Name (FQN) for all symbols within the file.
Related Issues
Testing
A test was created to ensure namespace resolution.
Performance Analysis
Performance Checklist
-
Have you reviewed your memory allocations to ensure you're optimizing correctly? Are you cloning or copying unnecessary data? -
Have you profiled with cargo benchorcriterionto measure performance impact? -
Are you using zero-copy operations where possible (e.g., &strinstead ofString, slice references)? -
Have you considered using Cow<'_, T>for conditional ownership to avoid unnecessary clones? -
Are iterator chains and lazy evaluation being used effectively instead of intermediate collections? -
Are you reusing allocations where possible (e.g., Vec::clear()and reuse vs new allocation)? -
Have you considered using SmallVecor similar for small, stack-allocated collections? -
Are async operations properly structured to avoid blocking the executor? -
Have you reviewed unsafecode blocks for both safety and performance implications? -
Are you using appropriate data structures (e.g., HashMapvsBTreeMapvsIndexMap)? -
Have you considered compile-time optimizations (e.g., const fn, generics instead of trait objects)? -
Are debug assertions ( debug_assert!) used instead of runtime checks where appropriate?
Edited by Bohdan Parkhomchuk