You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
New custom attribute required to support C++ inline namespaces #783
Namespaces in .NET are not a first class concept in metadata but are implicit in type names. C++ inline namespaces are namespaces whose contents are implicitly available in the enclosing namespace. E.g.
namespace N {
inline namespace I {
ref class R {};
}
}
The type R is simply name N.I.R in the metadata and upon import the C++ compiler does not know whether I is an inline namespace or not. To help the compiler import this correctly, an assembly-level custom attribute is emitted to the assembly for every inline namespace in the assembly. E.g., for the above we would emit
[CppInlineNamespace("N.I")];
To implement this, we need the attribute System.Runtime.CompilerServices.CppInlineNamespaceAttribute in System.Runtime.CompilerServices.VisualC.dll:
Is this only emitted for assemblies? Can this also be emitted for modules?
C++ inline namespaces are namespaces whose contents are implicitly available in the enclosing namespace.
So when I have a using N; directive (or whatever the C++ equivalent is) I can see R even though it's a nested namespace I? What's the point of having a nested namespace then?
Do you expect other compilers (such as C#) to honor this attribute?
Activity
terrajobst commentedon Dec 12, 2019
Couple of questions.
Is this only emitted for assemblies? Can this also be emitted for modules?
So when I have a
using N;directive (or whatever the C++ equivalent is) I can see R even though it's a nested namespaceI? What's the point of having a nested namespace then?Do you expect other compilers (such as C#) to honor this attribute?
tgani-msft commentedon Dec 12, 2019
In theory, yes, we could build a .netmodule though we don't officially support it.
An explanation of how inline namespaces work is at https://foonathan.net/2018/11/inline-namespaces/
We don't expect other compilers to do anything with this custom attribute, hence its location in VisualC.dll.
terrajobst commentedon Dec 12, 2019
Excellent, that helps!
We're reviewing API requests once a week on Tuesdays. So expect an answer by EOD the upcoming Tuesday.
terrajobst commentedon Jul 16, 2020
Video
tgani commentedon Jul 16, 2020
We went with a different design based on @jkotas feedback. I'll close this issue.