dotnet/roslyn

Compiler missing namespace symbols seem to not implment IsGlobalNamespace properly.

開放

#44,767 建立於 2020年6月1日

 (0 則留言) (0 個反應) (0 位負責人)C# (4,257 個分叉)batch import
Area-CompilersBughelp wanted

倉庫指標

星標
 (20,414 顆星)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 256 個 PR)

描述

Found in https://github.com/dotnet/roslyn/pull/44713

Say you have a project with no references (not even corlib or anything like that):

class C  { public int i; }

the i field will have an ErrorTypeSymbol for it's return type with name "Int32" contained in a missing namespace "" . "System". i.e. it is parented by two namespaces (expected), the empty named one, and the System named one. The empty named namespace is not marked as a global namespace though. i.e. IsGlobalNamespace returns false. Indeed, the empty named namespace is itself then parented by an actual empty-named-global-namespace.

This feel very unintentional and odd. IDE worked around this simply by checking if we have an error type and special casing our processing of this namespace chain. So this is nbd, but potentially something that someone coudl fix (including community) in the future if they were so inclined.

貢獻者指南