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.

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)

1 answer

+1
−0

I have not found a way of doing what I asked for in the question.

However, from looking at Microsoft.Extensions.[...] packages, it seems .NET follows a different approach:

  • For ease of development, things are put into different projects/NuGet packages
  • For ease of consumption, things are put under the same namespace, even though they might be in different project.

For example, IConfigurationBuilder from the NuGet package Microsoft.Extensions.Configuration.Abstractions is available in the namespace Microsoft.Extensions.Configuration.

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

0 comment threads

Sign up to answer this question »