CreateSolution.Shared.Common
1.0.2
dotnet add package CreateSolution.Shared.Common --version 1.0.2
NuGet\Install-Package CreateSolution.Shared.Common -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CreateSolution.Shared.Common" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CreateSolution.Shared.Common" Version="1.0.2" />
<PackageReference Include="CreateSolution.Shared.Common" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CreateSolution.Shared.Common --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CreateSolution.Shared.Common, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CreateSolution.Shared.Common@1.0.2
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CreateSolution.Shared.Common&version=1.0.2
#tool nuget:?package=CreateSolution.Shared.Common&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Shared.Common
Cross-cutting primitives and utilities used by all solutions (framework-agnostic).
Includes (suggested folders)
- Enums/
- StatusTypes, InformationTypes, FilterOperationTypes
- Models/
- BaseAddress, BaseCommunication, BaseDefinition, BaseDimension, BaseDocument, BaseEntity, BaseModel, BasePrice, BaseUser, CustomResult, ResultInformation, SearchFilter, SearchValue, SoftDeleteModel, SystemInformationModel, AuditLog (TableLog), TokenValidationModel
- Extensions/
- DateTimeExtensions, EnumExtensions, CultureExtensions (for NumberFormatInfo), ObjectExtensions, StringExtensions, QueryableExtensions
- Attributes/
- Validation attributes (e.g., RequiredIfAttribute)
- Helpers/
- ReflectionHelper, XmlHelper
- (optional) Security/
- JwtClaims helper for reading claims from JWT payloads
Install
dotnet add package Shared.Common
Target Frameworks
- net8.0
Namespace
Shared.Common.* (e.g., Shared.Common.Models.CustomResult, Shared.Common.Extensions.QueryableExtensions)
Example: CustomResult
namespace Shared.Common.Models;
public sealed record ResultInformation(string Code, string Message);
public sealed class CustomResult<T>
{
public bool Success { get; init; }
public T? Data { get; init; }
public ResultInformation? Info { get; init; }
public static CustomResult<T> Ok(T data, string? message = null)
=> new() { Success = true, Data = data, Info = message is null ? null : new ResultInformation("OK", message) };
public static CustomResult<T> Fail(string code, string message)
=> new() { Success = false, Info = new ResultInformation(code, message) };
}
Example: QueryableExtensions (minimal)
using System.Linq.Expressions;
namespace Shared.Common.Extensions;
public static class QueryableExtensions
{
public static IQueryable<T> WhereIf<T>(this IQueryable<T> query, bool condition, Expression<Func<T, bool>> predicate)
=> condition ? query.Where(predicate) : query;
public static IOrderedQueryable<T> OrderByIf<T, TKey>(this IQueryable<T> query, bool condition, Expression<Func<T, TKey>> keySelector)
=> condition ? query.OrderBy(keySelector) : query.OrderBy(_ => 0);
}
Example: JwtClaims helper (optional)
using System.Text.Json;
namespace Shared.Common.Security;
public static class JwtClaims
{
public static string? GetClaim(string jwt, string claim)
{
if (string.IsNullOrWhiteSpace(jwt)) return null;
var parts = jwt.Split('.');
if (parts.Length < 2) return null;
static byte[] Parse(string s){ return System.Convert.FromBase64String(s + "==="[(s.Length + 3) % 4..]); }
var payload = System.Text.Encoding.UTF8.GetString(Parse(parts[1]));
var doc = JsonDocument.Parse(payload);
return doc.RootElement.TryGetProperty(claim, out var el) ? el.ToString() : null;
}
}
Packing tips
- Keep this package free of ASP.NET/EF/MAUI dependencies.
- If a type starts referencing a framework, move it to a framework-specific package (e.g., Shared.WebApi.Server).
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- Newtonsoft.Json (>= 13.0.3)
- PluralizeService.Core (>= 1.2.21147.2)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on CreateSolution.Shared.Common:
| Package | Downloads |
|---|---|
|
CreateSolution.Shared.Blazor
Reusable Blazor components, auth helpers, JS interops. |
|
|
CreateSolution.Shared.WebApiClient
HTTP client helpers, base client, and DI configuration for typed Web API clients. |
|
|
CreateSolution.Shared.WebApi.Server
Server-side shared Web API utilities: BaseApiController, authentication config, middleware, helpers. |
GitHub repositories
This package is not used by any popular GitHub repositories.