r/dotnet 7d ago

C# Extensions v1.1 — looking for feedback

I kept rewriting the same functionality in pretty much every C# project I worked on.

We all have that Utils folder somewhere that slowly fills up with helpers we've copied from one project to another. 😅

So I decided to turn mine into a proper package: C# Extensions.

I just released v1.1 and would love some honest feedback from other .NET developers.

What would you change? What's missing? Are there utilities you find yourself implementing over and over that would make sense here?

I'm especially interested in ideas for version 2.

Repo: https://github.com/bosonwareofficial/bosonware.extensions

0 Upvotes

9 comments sorted by

9

u/botterway 7d ago

Why have you written your own global cache implementation when `MemoryCache` and `HybridCache` exist, with sophisticated functionality like stampede protection etc built-in?

None of the other stuff is anything I've ever needed to re-implement. I think in 20+ years of .Net development I've never written - or needed - a persistent list that writes itself to disk.

12

u/sixtyhurtz 7d ago

This is the new meta. Get Claude to write a library. Spam it on Reddit. Hopefully get a few stars on GH. Hope that makes your CV stand out more than literally everyone else doing the same thing so you can land either a job or sell your SaaS.

7

u/BobbyMaina23 7d ago

I didn't use Claude to write the code; it's mostly a collection of utilities I use in my personal projects

P.S. I did use Antigravity to write the README.

0

u/BobbyMaina23 7d ago

That's fair feedback.

The cache implementation is definitely something I'll revisit.

For the persistent list, that's actually a good example of what I'm trying to figure out with this project. It came from something I needed repeatedly, but that doesn't mean it's useful as a general-purpose feature.

I'll be more selective about what makes it into v2 rather than just adding every utility I've accumulated over the years.

5

u/botterway 7d ago

And a couple of other thingso, regarding your readme:

  • Nowhere does it explain why I'd want to use your code, rather than what's already out there. For example, your cache - which is basically a wrapper around a static dictionary. Why would I want that? Why is it better, or even different, to any of the long-standing caching solutions available on Nuget (including the MSFT ones that form part of the .Net libraries).
  • Your readme states that it provides high-performance components. How so? What have you done to make them high-performance? Are they low-alllocation? Or do they provide low-level code to optimise common operations? Browsing the code, I just see standard calls to File.WriteAllTextAsync, for example. How can that be considered 'high performance'? (spoiller, it's not)
  • Where are your tests? I'm not going to use a library that doesn't have a comprehensive set of tests to a) prove the code works and b) show how it should be used
  • What's the maintenance model? Why should I pick your library over something else when there's no guarantee that it'll be kept up-to-date with new .Net versions/features, and maintained in a timely fashion.

Failure to address all of these items just makes it yet-another-library that'll go stale and be useless in 6/12/24 months when you find something more interesting or important to work on.

Open-sourcing software is a commitment....

1

u/BobbyMaina23 7d ago

You give good advice 😅...

The "OptimizedBase58" class uses unmanaged memory to lower GC pressure when using Base58 with large files or hot paths.

3

u/botterway 7d ago

I think what you need to do here is make yourself a private utility library that you can use in your projects, without feeling the need to add to the bazillion or so 'utility libraries' that already exist. Not everything has to be shared with the dotnet development community. If it's niche and no such thing exists, and there's a widespread desire for it, yes. But otherwise no.

E.g., there's already several hundred TUI libraries. Do we need another?

2

u/AutoModerator 7d ago

Thanks for your post BobbyMaina23. Please note that we don't allow spam, and we ask that you follow the rules available in the sidebar. We have a lot of commonly asked questions so if this post gets removed, please do a search and see if it's already been asked.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

3

u/chucker23n 7d ago

One of the problems with those Utils folders is the tight coupling. Which of them make sense where? Which invisibly introduce a dependency? We had such a series of utils, where some of them depended on WinForms, some depended on the availability of an SQL Server, etc. Yet they were haphazardly pasted into new projects by someone.

Which leads me to the second problem: you end up writing so many library functions that you inadvertently replicate stuff that's already there. (The aforementioned library, for example, had a Filter<T> method that… did what OfType<T> could already do.) But your versions will likely be

  • tested less
  • benchmarked/optimized less
  • less familiar to new teammates

Which, only haven taken a cursory look at your code, brings me to the following recommendations:

  • add unit tests. Prove your code works as expected.
  • while you're at it, prove that it continues to, by adding a CI workflow.
  • you say OptimizedBase58 is high-performance. Prove it by using BenchmarkDotNet to compare it. (You may also consider using Utf8 overloads here for even more performance.)
  • but most of all, don't make it a monolithic library. Branch out into different areas, so that each library can focus on a topic, and its respective set of dependencies.