Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Comments on Is it possible to re-export types similar to JS?

Post

Is it possible to re-export types similar to JS?

+4
−0

I'm writing a library "MyLibrary".

In there, I group code into sections that make sense.
Let's say I have a folder "Reports" and a folder "Helpers".

I would like to have my code separated while working on it, but would like my users to just import "MyLibrary" and have all the important stuff together there.

In JS, I would be able to roughly do this:

import ReportFactory from './Reports/ReportFactory';
import StringHelper from './Helpers/StringHelper';

export {ReportFactory, StringHelper}

Is something like this possible in C#?

I know I could keep the files under that path, while letting them have a different namespace, but that's very hacky and I'd rather not, then.

So far I have stumbled on type forwarding, but that redirects to another assembly while keeping the namespace the same.

Is there a way to make such a "summary" namespace for the users of my library?

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

Clarify the purpose (1 comment)
Clarify the purpose
Alexei‭ wrote about 1 year ago

Ref. to "I would like to have my code separated while working on it, but would like my users to just import "MyLibrary" and have all the important stuff together there."

Is it supposed to be a convenience for the library consumer? I am asking because both Visual Studio and AFAIK Rider can automatically add using based on used types, so the user does not have to know the namespaces, as long as the library is referenced.