https://github.com/pkg-dot-zip/radovancommonextensions
Set of extension methods widely used accross the C# eco-system. From collections to reflection!
https://github.com/pkg-dot-zip/radovancommonextensions
collections csharp csharp-library extension-methods extensions net-standard net-standard-2 nuget-package reflection
Last synced: 5 months ago
JSON representation
Set of extension methods widely used accross the C# eco-system. From collections to reflection!
- Host: GitHub
- URL: https://github.com/pkg-dot-zip/radovancommonextensions
- Owner: pkg-dot-zip
- License: mit
- Created: 2025-01-18T13:32:36.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-01-20T11:16:49.000Z (over 1 year ago)
- Last Synced: 2025-05-09T01:46:55.453Z (about 1 year ago)
- Topics: collections, csharp, csharp-library, extension-methods, extensions, net-standard, net-standard-2, nuget-package, reflection
- Language: C#
- Homepage: https://www.nuget.org/packages/RadovanCommonExtensions
- Size: 15.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RadovanCommonExtensions
Simple class library created to avoid duplicate code in projects.
I noticed that I kept writing the same extension methods in each project. This library was created to avoid that.
## Features
- Added methods for [`ICollection`](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.icollection-1), such as `IsEmpty()` & `AddAll(params)` !
- Utility methods for [reflection](https://learn.microsoft.com/en-us/dotnet/fundamentals/reflection/reflection-and-generic-types) operations. See Examples for details.
And WAY more to come!
## Examples
Some basic [`ICollection`](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.icollection-1) methods.
```cs
public void Example(IList list)
{
if (list.IsEmpty()) return; // New IsEmpty() method!
// Logic here!
}
public void Example(ICollection collection, ICollection secondCollection)
{
collection.AddAll(true, false, true); // Adding using params!
collection.AddAll(secondCollection); // Adding other IEnumerables!
}
```
Invoking methods with [generics](https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/types/generics) dynamically so you can pass [Type](https://learn.microsoft.com/en-us/dotnet/api/system.type) as a parameter!
```cs
public class ExampleClass
{
public bool DoSomethingWithGeneric() => false;
}
public void Example(ExampleClass inst, Type genericType)
{
inst.InvokeObjWithGenerics(nameof(ExampleClass.DoSomethingWithGeneric), [genericType]);
}
```
## What to expect in the feature
*Technically* any extension method can be added, as long as it:
- Needed in two or more projects I am working on.
- Unit tested in the unit test project of this solution.
If you are using this package, feel free to add suggestions if you need something.