Skip to content

Commit ce5bc2a

Browse files
authored
Merge pull request #49 from I-RzR-I/feature/NameSpaceConceptChange
Name space concept change
2 parents b18ecc3 + f3dc459 commit ce5bc2a

223 files changed

Lines changed: 9742 additions & 692 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
1-
> **Note** This repository is developed for net40, net45 .netstandard2.0, .netstandard2.1
1+
> **Note** This repository is developed for net40, net45, .netstandard2.0 and .netstandard2.1.
22
33
[![NuGet Version](https://img.shields.io/nuget/v/DomainCommonExtensions.svg?style=flat&logo=nuget)](https://www.nuget.org/packages/DomainCommonExtensions/)
44
[![Nuget Downloads](https://img.shields.io/nuget/dt/DomainCommonExtensions.svg?style=flat&logo=nuget)](https://www.nuget.org/packages/DomainCommonExtensions)
55

6-
This library/ repository was created as a way to simplify the development process. Here were written the usually used methods (extension methods) for some data types like `int, string, DateTime, Enum, bool, byte, Guid`, also there was added extensions for `List, Dictionary, DynamicList` and other collections(`ICollection, IEnumerable, IList, HashSet, IQueryable`).
6+
> **v5 — Namespace reorganisation (BREAKING)**
7+
>
8+
> Starting with **v5**, the library was reorganised with a new namespace (from `DomainCommonExtensions` to `RzR.Extensions.Domain`) and focused into namespace buckets under the new root `RzR.Extensions.Domain.*`
9+
> (`Async`, `Collections`, `Cryptography`, `Data`, `Diagnostics`, `Internal`, `IO`, `Linq`, `Models`, `Primitives`, `Reflection`, `Text`, `Validation`).
10+
> Class names and method signatures are unchanged — only the namespaces moved.
11+
>
12+
> To soften the upgrade, every old (v4) namespace is preserved as `[Obsolete]` forwarder static classes under
13+
> [`src/DomainCommonExtensions/_Legacy/`](src/DomainCommonExtensions/_Legacy/), so existing v4 code keeps compiling
14+
> while the IDE highlights every call-site with the new location.
15+
>
16+
> See the full mapping in [docs/namespace-migration-v5.md](docs/namespace-migration-v5.md).
717
8-
In the repository was added an extension for `cryptography`, encrypting and decrypting string by key with `RSA`, `AES`, `TEA`.
18+
This library/repository was created as a way to simplify the development process. It collects the most used extension methods for primitive data types (`int`, `string`, `DateTime`, `Enum`, `bool`, `byte`, `char`, `Guid`, `TimeSpan`, …) and for the common collection interfaces (`ICollection`, `IEnumerable`, `IList`, `HashSet`, `IQueryable`, `IDictionary`, `ConcurrentDictionary`, `Queue`, `DynamicList`, …).
919

10-
In case you need some get some documentation/comments from `Assembly`, here too are some extensions. Also you can find a async lazy load `AsyncLazy<T>` and `AsyncExpiringLazy<T>`.
20+
It also bundles `cryptography` helpers for encrypting/decrypting strings by key with `RSA`, `AES`, `TEA`, plus a `Base32` encoder and a password generator.
1121

12-
Also here you may find extensions for `SystemData (DbDataReader, DataRecord, DataTable)` lib, `FileStream, MemoryStream, Type`, and a lot other of methods and not the last some `Linq` and `Expression` extensions that can help to make code mode clean.
22+
If you need to extract documentation/comments from an `Assembly`, those extensions are here too. You will also find async lazy-load primitives `AsyncLazy<T>` and `AsyncExpiringLazy<T>`.
23+
24+
Additionally, there are extensions for `System.Data` (`DbDataReader`, `IDataRecord`, `DataTable`), `FileStream`, `MemoryStream`, `Type`, plus `Linq` / `Expression` extensions and a `PredicateBuilder` to keep call-sites clean.
1325

1426
As previously, I said here are collected the most relevant and used extension methods in the life cycle of application development that allow us to improve our code, and writing speed, and use more efficiently dev team time during this period for more complex functionality.
1527
The list of helpful methods and extensions list isn't finished, I think in a short period I'll complete it with more fun things.
@@ -25,5 +37,6 @@ I hope I'm on the right way to providing all these things to all who saw or sear
2537
2638
## Content
2739
1. [USING](docs/usage.md)
28-
1. [CHANGELOG](docs/CHANGELOG.md)
29-
1. [BRANCH-GUIDE](docs/branch-guide.md)
40+
2. [CHANGELOG](docs/CHANGELOG.md)
41+
3. [BRANCH-GUIDE](docs/branch-guide.md)
42+
4. [V5 NAMESPACE MIGRATION](docs/namespace-migration-v5.md)

docs/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
### **v5.0.0.7637** [[RzR](mailto:108324929+I-RzR-I@users.noreply.github.com)] 24-04-2026
2+
* **BREAKING:** Repository reorganized into 11 stable namespace buckets (`Async`, `Collections`, `Cryptography`, `Data`, `Diagnostics`, `Internal`, `IO`, `Linq`, `Models`, `Primitives`, `Reflection`, `Text`, `Validation`). Class names and method signatures are unchanged; only the namespaces moved. See [namespace-migration-v5.md](namespace-migration-v5.md) for the full mapping.
3+
* **Backward-compat shim layer** (`_Legacy/` folder): `[Obsolete]` static methods preserve the v4 namespaces so existing user code still compiles. Each call site lights up with the new v5 location.
4+
* New file extensions in `IO`: `SafeWriteAllText`, `SafeWriteAllBytes` (atomic write via temp + replace), `Sha256HexFromFile`.
5+
* New byte / string checksum helpers in `Primitives` / `Text`: `byte[].ToHexString`, `byte[].Sha256Hex`, `string.Sha256Hex`.
6+
* New `string` extensions in `Text`: `ToBase64Url`, `FromBase64Url`, `ToSlug`, `Mask`.
7+
18
### **v4.6.0.8232** [[RzR](mailto:108324929+I-RzR-I@users.noreply.github.com)] 20-03-2026
29
* [5503224] (RzR) -> Auto commit uncommited files
310
* [e9aa417] (RzR) -> Add small improvements

docs/namespace-migration-v5.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Namespace migration guide (v5)
2+
3+
The repository was reorganized into 11 stable namespace buckets. This is a
4+
**breaking change**: every user should update its `using` directives. The
5+
class names and method signatures themselves did not change, only the
6+
namespaces they live in. Also, one more important thing is that the namespace was changed from `DomainCommonExtensions` to `RzR.Extensions.Domain`.
7+
8+
## Backward-compatibility shims (`_Legacy/` folder)
9+
10+
To soften the upgrade, every old namespace still exists via auto-generated
11+
forwarder static classes under [`src/DomainCommonExtensions/_Legacy/`](../src/DomainCommonExtensions/_Legacy).
12+
Each shim type is marked `[Obsolete]` with a message telling you the new
13+
location, so existing v4 code keeps compiling but every call site lights up
14+
in your IDE pointing to its v5 replacement.
15+
16+
## Namespace map
17+
18+
Update old `using` directives as follows:
19+
20+
| Old namespace | New namespace(s) | Notes |
21+
|---|---|---|
22+
| `DomainCommonExtensions.ArraysExtensions` | `RzR.Extensions.Domain.Collections`, `RzR.Extensions.Domain.Linq` | LinqExtensions split out to `Linq`; everything else → `Collections` |
23+
| `DomainCommonExtensions.Collections` (supporting types: `IndexableEnumerable`, `MutableIndexableEnumerable`, `ObservableEnumerator`, `DisposableStackCollection`, `InsensitiveCaseHashtable`) | `RzR.Extensions.Domain.Collections.Types` | Containers separated from extension methods |
24+
| `DomainCommonExtensions.CommonExtensions` | `RzR.Extensions.Domain.Async`, `RzR.Extensions.Domain.Cryptography`, `RzR.Extensions.Domain.Data`, `RzR.Extensions.Domain.Diagnostics`, `RzR.Extensions.Domain.IO`, `RzR.Extensions.Domain.Linq`, `RzR.Extensions.Domain.Primitives` | This was the catch-all; split per concern. `FilesExtensions`, `DirectoryInfoExtensions`, `MemoryStreamExtensions``IO`; `CryptoExtensions`, `AESEncryptionExtensions``Cryptography`; `ExpressionExtensions`, `PredicateBuilderExtensions``Linq`; `TaskExtensions`, `FuncExtensions``Async`; `ExceptionExtensions`, `DocumentationExtensions``Diagnostics`; `ExpandoObjectExtensions``Data`; `NumbersExtensions`, `NullExtensions`, `RandomExtensions``Primitives` |
25+
| `DomainCommonExtensions.CommonExtensions.Encryption` | `RzR.Extensions.Domain.Cryptography.Rsa`, `RzR.Extensions.Domain.Cryptography.Tea` | AES extensions moved up to `Cryptography` (no `.Aes` sub-namespace because it shadows `System.Security.Cryptography.Aes`) |
26+
| `DomainCommonExtensions.CommonExtensions.Reflection` | `RzR.Extensions.Domain.Reflection` | |
27+
| `DomainCommonExtensions.CommonExtensions.SystemData` | `RzR.Extensions.Domain.Data` | |
28+
| `DomainCommonExtensions.CommonExtensions.TypeParam` | `RzR.Extensions.Domain.Reflection.TypeParam` | |
29+
| `DomainCommonExtensions.ConvertExtensions.DataReader` | `RzR.Extensions.Domain.Data.DataReader` | |
30+
| `DomainCommonExtensions.DataTypeExtensions` | `RzR.Extensions.Domain.Primitives`, `RzR.Extensions.Domain.Text`, `RzR.Extensions.Domain.Diagnostics` | `StringExtensions`, `StringInjectExtension``Text`; `SocketExtensions``Diagnostics`; everything else → `Primitives` |
31+
| `DomainCommonExtensions.Helpers` | `RzR.Extensions.Domain.IO`, `RzR.Extensions.Domain.IO.Ini`, `RzR.Extensions.Domain.Async`, `RzR.Extensions.Domain.Cryptography`, `RzR.Extensions.Domain.Primitives` | `DirectoryHelper``IO`; `IniFileHelper``IO.Ini`; `TaskRunnerHelper``Async`; `TinyEncryptionAlgorithmHelper``Cryptography.Tea`; `RandomHelper``Primitives` |
32+
| `DomainCommonExtensions.Helpers.Internal` | `RzR.Extensions.Domain.Internal`, `RzR.Extensions.Domain.Cryptography` | `Base32EncodingHelper``Cryptography` (no `.Encoding` sub-namespace because it shadows `System.Text.Encoding`) |
33+
| `DomainCommonExtensions.Helpers.Internal.AnonymousSelect[.Base|.Factory]` | `RzR.Extensions.Domain.Internal.AnonymousSelect[.Base|.Factory]` | |
34+
| `DomainCommonExtensions.Resources` (`RegularExpressions`) | `RzR.Extensions.Domain.Text` | |
35+
| `DomainCommonExtensions.Resources.Enums` | `RzR.Extensions.Domain.Collections` (`OrderType`), `RzR.Extensions.Domain.Validation` (`ExceptionType`) | |
36+
| `DomainCommonExtensions.Utilities` | `RzR.Extensions.Domain.Collections`, `RzR.Extensions.Domain.Cryptography` | `EnumerateUtils`, `GeneralUtils``Collections`; `PasswordGenerateUtils``Cryptography` |
37+
| `DomainCommonExtensions.Utilities.Ensure` | `RzR.Extensions.Domain.Validation` | `DomainEnsure`, `DomainEnsureExtensions` |
38+
| `DomainCommonExtensions.Utilities.LazyLoad` | `RzR.Extensions.Domain.Async.LazyLoad` | `AsyncLazy<T>`, `AsyncExpiringLazy<T>` |
39+
40+
`RzR.Extensions.Domain.Models` is unchanged.
41+
42+
## How to migrate your code
43+
44+
Use a single project-wide find-and-replace for each row in the table above.
45+
For namespaces that split, you may need to add multiple `using` directives —
46+
your IDE's "Remove and sort usings" / `dotnet format` will trim the unused
47+
ones automatically.
48+
49+
## Folder layout
50+
51+
The folder tree under `src/DomainCommonExtensions/` now mirrors the namespaces
52+
exactly (folder name = last segment of namespace). `.editorconfig` enforces
53+
this with `dotnet_diagnostic.IDE0130 = warning`.
54+
55+
```
56+
DomainCommonExtensions/
57+
├── Async/ (TaskExtensions, FuncExtensions, TaskRunnerHelper)
58+
│ └── LazyLoad/ (AsyncLazy, AsyncExpiringLazy)
59+
├── Collections/ (Array/List/Dictionary/Queue/Hash/Concurrent... + utils)
60+
│ └── Types/ (IndexableEnumerable, ObservableEnumerator, ...)
61+
├── Cryptography/ (AES, Crypto, Base32, Password... )
62+
│ ├── Rsa/
63+
│ └── Tea/ (TEA + TinyEncryptionAlgorithmHelper)
64+
├── Data/ (DataReader/Record/Table, ExpandoObject)
65+
│ └── DataReader/ (To* converters)
66+
├── Diagnostics/ (Exception, Documentation, Socket)
67+
├── Internal/ (private impl details)
68+
│ └── AnonymousSelect/
69+
├── IO/ (Files, Directory, MemoryStream)
70+
│ └── Ini/ (IniFileHelper)
71+
├── Linq/ (LinqExtensions, Expression, PredicateBuilder)
72+
├── Models/ (unchanged)
73+
├── Primitives/ (int/long/bool/byte/char/Guid/TimeSpan/Random/...)
74+
├── Reflection/ (Type/Assembly/PropertyInfo/Reflection)
75+
│ └── TypeParam/ (TypeParam* extensions)
76+
├── Text/ (StringExtensions, StringInject, RegularExpressions)
77+
└── Validation/ (DomainEnsure, ExceptionType)
78+
```

docs/usage.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
# USING
22

3-
I think using these methods is no need for any explanations. Here you may find a lot of extensions that help in projects development.
3+
Most of these extension methods are self-explanatory. Browse the source for the full surface; this document focuses on the more involved primitives.
44

5-
The source code is open, so you can check what are available and what you can find useful and can use in your project.
5+
The source code is open, so you can check what is available and pick what is useful for your project.
6+
7+
> **Namespaces (v5).** Since v5 the library is with a new namespace (from `DomainCommonExtensions` to `RzR.Extensions.Domain`), and split into focused buckets under `RzR.Extensions.Domain.*`
8+
> (`Async`, `Collections`, `Cryptography`, `Data`, `Diagnostics`, `Internal`, `IO`, `Linq`, `Models`, `Primitives`,
9+
> `Reflection`, `Text`, `Validation`). The old (v4) namespaces still resolve via `[Obsolete]` forwarders
10+
> in [`src/DomainCommonExtensions/_Legacy/`](../src/DomainCommonExtensions/_Legacy/) — see
11+
> [namespace-migration-v5.md](namespace-migration-v5.md) for the full mapping.
612
713
---
814

9-
## Async lazy load `AsyncLazy<T>` and `AsyncExpiringLazy<T>`
15+
## Async lazy load — `AsyncLazy<T>` and `AsyncExpiringLazy<T>`
16+
17+
> Namespace: `RzR.Extensions.Domain.Async.LazyLoad`
18+
>
19+
> ```csharp
20+
> using RzR.Extensions.Domain.Async.LazyLoad;
21+
> ```
1022
1123
## **`AsyncLazy<T>`**
1224

src/DomainCommonExtensions/CommonExtensions/FuncExtensions.cs renamed to src/DomainCommonExtensions/Async/FuncExtensions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ***********************************************************************
1+
// ***********************************************************************
22
// Assembly : RzR.Shared.Extensions.DomainCommonExtensions
33
// Author : RzR
44
// Created On : 2025-07-11 12:38
@@ -18,12 +18,12 @@
1818

1919
using System;
2020
using System.Threading.Tasks;
21-
using DomainCommonExtensions.DataTypeExtensions;
22-
using DomainCommonExtensions.Utilities.Ensure;
21+
using RzR.Extensions.Domain.Primitives;
22+
using RzR.Extensions.Domain.Validation;
2323

2424
#endregion
2525

26-
namespace DomainCommonExtensions.CommonExtensions
26+
namespace RzR.Extensions.Domain.Async
2727
{
2828
/// <summary>
2929
/// A function extensions.
@@ -93,4 +93,4 @@ public static bool IsFalse(this Func<Task<bool>> func)
9393
return func.IsTrue().IsFalse();
9494
}
9595
}
96-
}
96+
}

src/DomainCommonExtensions/Utilities/LazyLoad/AsyncExpiringLazy.cs renamed to src/DomainCommonExtensions/Async/LazyLoad/AsyncExpiringLazy.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if NET45_OR_GREATER || NET || NETSTANDARD1_0_OR_GREATER
1+
#if NET45_OR_GREATER || NET || NETSTANDARD1_0_OR_GREATER
22

33
// ***********************************************************************
44
// Assembly : RzR.Shared.Extensions.DomainCommonExtensions
@@ -18,15 +18,15 @@
1818

1919
#region U S A G E S
2020

21+
using RzR.Extensions.Domain.Primitives;
2122
using System;
2223
using System.Runtime.CompilerServices;
2324
using System.Threading;
2425
using System.Threading.Tasks;
25-
using DomainCommonExtensions.CommonExtensions;
2626

2727
#endregion
2828

29-
namespace DomainCommonExtensions.Utilities.LazyLoad
29+
namespace RzR.Extensions.Domain.Async.LazyLoad
3030
{
3131
/// -------------------------------------------------------------------------------------------------
3232
/// <summary>
@@ -361,4 +361,4 @@ public Entry(Task<T> task, DateTimeOffset expiration)
361361
}
362362
}
363363

364-
#endif
364+
#endif

src/DomainCommonExtensions/Utilities/LazyLoad/AsyncLazy.cs renamed to src/DomainCommonExtensions/Async/LazyLoad/AsyncLazy.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if NET45_OR_GREATER ||NET || NETSTANDARD1_0_OR_GREATER
1+
#if NET45_OR_GREATER || NET || NETSTANDARD1_0_OR_GREATER
22

33
// ***********************************************************************
44
// Assembly : RzR.Shared.Extensions.DomainCommonExtensions
@@ -18,15 +18,15 @@
1818

1919
#region U S A G E S
2020

21+
using RzR.Extensions.Domain.Primitives;
2122
using System;
2223
using System.Runtime.CompilerServices;
2324
using System.Threading;
2425
using System.Threading.Tasks;
25-
using DomainCommonExtensions.CommonExtensions;
2626

2727
#endregion
2828

29-
namespace DomainCommonExtensions.Utilities.LazyLoad
29+
namespace RzR.Extensions.Domain.Async.LazyLoad
3030
{
3131
/// -------------------------------------------------------------------------------------------------
3232
/// <summary>
@@ -356,4 +356,4 @@ public LazyState(Task<T> task, CancellationTokenSource cancelTokenSource)
356356
}
357357
}
358358

359-
#endif
359+
#endif

src/DomainCommonExtensions/CommonExtensions/TaskExtensions.cs renamed to src/DomainCommonExtensions/Async/TaskExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ***********************************************************************
1+
// ***********************************************************************
22
// Assembly : RzR.Shared.Extensions.DomainCommonExtensions
33
// Author : RzR
44
// Created On : 2022-08-10 21:39
@@ -20,7 +20,7 @@
2020

2121
#endregion
2222

23-
namespace DomainCommonExtensions.CommonExtensions
23+
namespace RzR.Extensions.Domain.Async
2424
{
2525
/// <summary>
2626
/// Task extensions
@@ -51,4 +51,4 @@ public static void ExecuteAsync(this Task task)
5151
}
5252
#endif
5353
}
54-
}
54+
}

src/DomainCommonExtensions/Helpers/TaskRunnerHelper.cs renamed to src/DomainCommonExtensions/Async/TaskRunnerHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ***********************************************************************
1+
// ***********************************************************************
22
// Assembly : RzR.Shared.Extensions.DomainCommonExtensions
33
// Author : RzR
44
// Created On : 2025-11-05 16:11
@@ -22,7 +22,7 @@
2222

2323
#endregion
2424

25-
namespace DomainCommonExtensions.Helpers
25+
namespace RzR.Extensions.Domain.Async
2626
{
2727
/// -------------------------------------------------------------------------------------------------
2828
/// <summary>
@@ -80,4 +80,4 @@ public static Task Run(Action delegateAction, CancellationToken cancellationToke
8080
#endif
8181
}
8282
}
83-
}
83+
}

src/DomainCommonExtensions/ArraysExtensions/ArrayExtensions.cs renamed to src/DomainCommonExtensions/Collections/ArrayExtensions.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ***********************************************************************
1+
// ***********************************************************************
22
// Assembly : RzR.Shared.Extensions.DomainCommonExtensions
33
// Author : RzR
44
// Created On : 2022-12-08 09:12
@@ -16,14 +16,13 @@
1616

1717
#region U S A G E S
1818

19-
using DomainCommonExtensions.CommonExtensions;
20-
using DomainCommonExtensions.DataTypeExtensions;
2119
using System;
2220
using System.Linq;
21+
using RzR.Extensions.Domain.Primitives;
2322

2423
#endregion
2524

26-
namespace DomainCommonExtensions.ArraysExtensions
25+
namespace RzR.Extensions.Domain.Collections
2726
{
2827
/// -------------------------------------------------------------------------------------------------
2928
/// <summary>
@@ -238,4 +237,4 @@ public static T[] NotNull<T>(this T[] array)
238237
return array ?? new T[] { };
239238
}
240239
}
241-
}
240+
}

0 commit comments

Comments
 (0)