Keywordify 0.0.1
dotnet add package Keywordify --version 0.0.1
NuGet\Install-Package Keywordify -Version 0.0.1
<PackageReference Include="Keywordify" Version="0.0.1" />
<PackageVersion Include="Keywordify" Version="0.0.1" />
<PackageReference Include="Keywordify" />
paket add Keywordify --version 0.0.1
#r "nuget: Keywordify, 0.0.1"
#:package Keywordify@0.0.1
#addin nuget:?package=Keywordify&version=0.0.1
#tool nuget:?package=Keywordify&version=0.0.1
Keywordify
Keywordify is a small, focused C# utility library that provides convenient extension methods for safely casting and converting object values. It is designed to make common casting patterns explicit, safe, and easy to read.
Features
As<T>(this object?) where T : class— Equivalent to the C#asoperator; returnsnullon failure.SafeAs<T>(this object?)— Pattern-matching safe cast; returnsdefault(T)when the cast fails.Cast<T>(this object?)— Explicit cast that throwsInvalidCastExceptionon failure; returnsdefaultwhenobjisnullandTis nullable or a reference type.TryCast<T>(this object?, out T? result)— Try-style cast returningtrueon success andfalseotherwise while providing the cast result via anoutparameter.
Getting started
Add a project reference to the src/System.Keywordify.csproj in your solution, or install the package from NuGet (if published):
dotnet add package System.Keywordify
Examples
using System;
using System.Keywordify;
class Demo
{
static void Main()
{
object a = "hello";
string? s = a.As<string>(); // "hello"
object n = 123;
string? s2 = n.SafeAs<string>(); // null
int? x = n.SafeAs<int>(); // 123
Console.WriteLine($"As<string>: {(s is null ? "null" : s)}");
Console.WriteLine($"SafeAs<string> from int: {(s2 is null ? "null" : s2)}");
Console.WriteLine($"SafeAs<int> from int: {x}");
// Cast (throws on invalid cast)
object boxed = 42;
int y = boxed.Cast<int>(); // 42
// TryCast
if (boxed.TryCast<int>(out var result))
{
Console.WriteLine($"TryCast succeeded: {result}");
}
else
{
Console.WriteLine("TryCast failed");
}
}
}
Contributing & building
- Clone the repository and run
dotnet buildat the solution root to build the library and the test project. - The sample/test project is located in the
testfolder and demonstrates usage via aProjectReference.
License
This project is licensed under the MIT License — see the LICENSE file for details.
Contact
Please open issues or pull requests on the repository for questions, bug reports, or contributions.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. 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 is compatible. 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. |
| .NET Core | netcoreapp1.0 is compatible. netcoreapp1.1 is compatible. netcoreapp2.0 is compatible. netcoreapp2.1 is compatible. netcoreapp2.2 is compatible. netcoreapp3.0 is compatible. netcoreapp3.1 is compatible. |
| .NET Standard | netstandard1.0 is compatible. netstandard1.1 is compatible. netstandard1.2 is compatible. netstandard1.3 is compatible. netstandard1.4 is compatible. netstandard1.5 is compatible. netstandard1.6 is compatible. netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net35 is compatible. net40 is compatible. net403 was computed. net45 is compatible. net451 is compatible. net452 is compatible. net46 is compatible. net461 is compatible. net462 is compatible. net463 was computed. net47 is compatible. net471 is compatible. net472 is compatible. net48 is compatible. net481 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
| Universal Windows Platform | uap was computed. uap10.0 was computed. |
| Windows Phone | wp8 was computed. wp81 was computed. wpa81 was computed. |
| Windows Store | netcore was computed. netcore45 was computed. netcore451 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 1.0
- Microsoft.NETCore.App (>= 1.0.5)
-
.NETCoreApp 1.1
- Microsoft.NETCore.App (>= 1.1.2)
-
.NETCoreApp 2.0
- No dependencies.
-
.NETCoreApp 2.1
- No dependencies.
-
.NETCoreApp 2.2
- No dependencies.
-
.NETCoreApp 3.0
- No dependencies.
-
.NETCoreApp 3.1
- No dependencies.
-
.NETFramework 3.5
- No dependencies.
-
.NETFramework 4.0
- No dependencies.
-
.NETFramework 4.5
- No dependencies.
-
.NETFramework 4.5.1
- No dependencies.
-
.NETFramework 4.5.2
- No dependencies.
-
.NETFramework 4.6
- No dependencies.
-
.NETFramework 4.6.1
- No dependencies.
-
.NETFramework 4.6.2
- No dependencies.
-
.NETFramework 4.7
- No dependencies.
-
.NETFramework 4.7.1
- No dependencies.
-
.NETFramework 4.7.2
- No dependencies.
-
.NETFramework 4.8
- No dependencies.
-
.NETFramework 4.8.1
- No dependencies.
-
.NETStandard 1.0
- NETStandard.Library (>= 1.6.1)
-
.NETStandard 1.1
- NETStandard.Library (>= 1.6.1)
-
.NETStandard 1.2
- NETStandard.Library (>= 1.6.1)
-
.NETStandard 1.3
- NETStandard.Library (>= 1.6.1)
-
.NETStandard 1.4
- NETStandard.Library (>= 1.6.1)
-
.NETStandard 1.5
- NETStandard.Library (>= 1.6.1)
-
.NETStandard 1.6
- NETStandard.Library (>= 1.6.1)
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
-
net10.0
- No dependencies.
-
net5.0
- No dependencies.
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.0.1 | 95 | 5/11/2026 |