Skip to content

Commit 07887d9

Browse files
committed
the initial code port from the jbarden NuGet / GitHub organisations
1 parent 87be56e commit 07887d9

File tree

12 files changed

+290
-12
lines changed

12 files changed

+290
-12
lines changed

AStar.Utilities.sln

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.7.34024.191
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AStar.Utilities", "src\AStar.Utilities\AStar.Utilities.csproj", "{E4D86C2D-C9F7-4738-93AD-8E726B12AA97}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F278FE7A-ED8B-4C98-98EA-2A99803A4A82}"
9+
ProjectSection(SolutionItems) = preProject
10+
LICENSE = LICENSE
11+
README.md = README.md
12+
EndProjectSection
13+
EndProject
14+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{8618654D-3A13-4B92-80FA-CE48DF281276}"
15+
EndProject
16+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AStar.Utilities.Unit.Tests", "tests\unit\AStar.Utilities.Unit.Tests\AStar.Utilities.Unit.Tests.csproj", "{6CD0E1F8-AD4A-46F3-9622-4DED14EFEF59}"
17+
EndProject
18+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{35AB19D2-EB84-456C-98BE-158393D488B4}"
19+
EndProject
20+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "unit", "unit", "{7D9D09F2-797B-4B79-B6A4-499EC673DAEC}"
21+
EndProject
22+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{D6963DCB-A452-4C85-88A0-C7F604CFE8CA}"
23+
EndProject
24+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{27076F0E-3C06-45EE-B4F2-B584BADF5DAA}"
25+
ProjectSection(SolutionItems) = preProject
26+
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml
27+
EndProjectSection
28+
EndProject
29+
Global
30+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
31+
Debug|Any CPU = Debug|Any CPU
32+
Release|Any CPU = Release|Any CPU
33+
EndGlobalSection
34+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
35+
{E4D86C2D-C9F7-4738-93AD-8E726B12AA97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36+
{E4D86C2D-C9F7-4738-93AD-8E726B12AA97}.Debug|Any CPU.Build.0 = Debug|Any CPU
37+
{E4D86C2D-C9F7-4738-93AD-8E726B12AA97}.Release|Any CPU.ActiveCfg = Release|Any CPU
38+
{E4D86C2D-C9F7-4738-93AD-8E726B12AA97}.Release|Any CPU.Build.0 = Release|Any CPU
39+
{6CD0E1F8-AD4A-46F3-9622-4DED14EFEF59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40+
{6CD0E1F8-AD4A-46F3-9622-4DED14EFEF59}.Debug|Any CPU.Build.0 = Debug|Any CPU
41+
{6CD0E1F8-AD4A-46F3-9622-4DED14EFEF59}.Release|Any CPU.ActiveCfg = Release|Any CPU
42+
{6CD0E1F8-AD4A-46F3-9622-4DED14EFEF59}.Release|Any CPU.Build.0 = Release|Any CPU
43+
EndGlobalSection
44+
GlobalSection(SolutionProperties) = preSolution
45+
HideSolutionNode = FALSE
46+
EndGlobalSection
47+
GlobalSection(NestedProjects) = preSolution
48+
{E4D86C2D-C9F7-4738-93AD-8E726B12AA97} = {8618654D-3A13-4B92-80FA-CE48DF281276}
49+
{6CD0E1F8-AD4A-46F3-9622-4DED14EFEF59} = {7D9D09F2-797B-4B79-B6A4-499EC673DAEC}
50+
{7D9D09F2-797B-4B79-B6A4-499EC673DAEC} = {35AB19D2-EB84-456C-98BE-158393D488B4}
51+
{27076F0E-3C06-45EE-B4F2-B584BADF5DAA} = {D6963DCB-A452-4C85-88A0-C7F604CFE8CA}
52+
EndGlobalSection
53+
GlobalSection(ExtensibilityGlobals) = postSolution
54+
SolutionGuid = {14B5B932-6D11-440E-A885-CC9B10F840DA}
55+
EndGlobalSection
56+
EndGlobal

Readme.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
1-
# AStar.Dev.Utilities
1+
# AStar Utilities
2+
A collection of useful utilities. At the moment, the collection is small but will grow as time and need permits.
23

3-
## GitHub build
4+
## Utilities
45

5-
[![Build and test solution](https://github.com/jbarden/astar-dev-utilities/actions/workflows/dotnet.yml/badge.svg)](https://github.com/jbarden/astar-dev-utilities/actions/workflows/dotnet.yml)
6+
### String Utilities
67

7-
## SonarCloud Analysis Results
8+
* IsNull - as you might expect, checks whether the string is, in fact, null.
9+
* IsNotNull - as you might expect, checks whether the string is not null.
10+
* IsNullOrWhiteSpace - as you might expect, checks whether the string is, in fact, null, empty or whitespace. *new*
11+
* IsNotNullOrWhiteSpace - as you might expect, checks whether the string is not null, empty or whitespace. *new*
12+
* FromJson - as you might expect, converts the JSON representation to the requested Type.
13+
14+
### String Utilities
15+
16+
* ToJson - as you might expect, converts the object to the appropriate JSON representation.
817

9-
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=jbarden_astar-dev-utilities&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=jbarden_astar-dev-utilities)
18+
## GitHub build
19+
[![Build and test solution](https://github.com/jbarden/astar-utilities/actions/workflows/dotnet.yml/badge.svg)](https://github.com/jbarden/astar-utilities/actions/workflows/dotnet.yml)
20+
21+
## SonarCloud Analysis Results
1022

11-
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=jbarden_astar-dev-utilities&metric=bugs)](https://sonarcloud.io/summary/new_code?id=jbarden_astar-dev-utilities)
23+
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=jbarden_astar-utilities&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=jbarden_astar-utilities)
1224

13-
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=jbarden_astar-dev-utilities&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=jbarden_astar-dev-utilities)
25+
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=jbarden_astar-utilities&metric=bugs)](https://sonarcloud.io/summary/new_code?id=jbarden_astar-utilities)
1426

15-
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=jbarden_astar-dev-utilities&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=jbarden_astar-dev-utilities)
27+
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=jbarden_astar-utilities&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=jbarden_astar-utilities)
1628

17-
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=jbarden_astar-dev-utilities&metric=coverage)](https://sonarcloud.io/summary/new_code?id=jbarden_astar-dev-utilities)
29+
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=jbarden_astar-utilities&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=jbarden_astar-utilities)
1830

19-
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=jbarden_astar-dev-utilities&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=jbarden_astar-dev-utilities)
31+
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=jbarden_astar-utilities&metric=coverage)](https://sonarcloud.io/summary/new_code?id=jbarden_astar-utilities)
2032

33+
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=jbarden_astar-utilities&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=jbarden_astar-utilities)

src/AStar.Dev.Utilities/AStar.Dev.Utilities.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
<RepositoryType>git</RepositoryType>
3030
<PackageProjectUrl>https://github.com/jbarden/astar-dev-utilities</PackageProjectUrl>
3131
<Description>A collection of useful utilities.</Description>
32-
<Version>1.4.0</Version>
32+
<Version>1.5.0</Version>
3333
<Authors>AStar Development, Jason Barden</Authors>
3434
<DocumentationFile>$(AssemblyName).xml</DocumentationFile>
3535
<PackageIcon>AStar.png</PackageIcon>
3636
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
37-
<PackageReleaseNotes>version 1.4.0, no changes - version increased as part of the migration to the new AStar NuGet / GitHub organisations.</PackageReleaseNotes>
37+
<PackageReleaseNotes>version 1.5.0 contains the initial code port from the jbarden NuGet / GitHub organisations.</PackageReleaseNotes>
3838
</PropertyGroup>
3939

4040
<ItemGroup>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Text.Json;
2+
3+
namespace AStar.Utilities;
4+
5+
/// <summary>
6+
/// The <see href="Constants"></see>see> class contains static / constant properties to simplify and centralise various settings.
7+
/// </summary>
8+
public static class Constants
9+
{
10+
/// <summary>
11+
/// Returns an instance of <see href="JsonSerializerOptions"></see> configured with the Web defaults.
12+
/// </summary>
13+
public static JsonSerializerOptions WebDeserialisationSettings => new(JsonSerializerDefaults.Web);
14+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace AStar.Utilities;
2+
3+
/// <summary>
4+
///
5+
/// </summary>
6+
public static class EnumExtensions
7+
{
8+
/// <summary>
9+
///
10+
/// </summary>
11+
/// <typeparam name="T"></typeparam>
12+
/// <param name="value"></param>
13+
/// <returns></returns>
14+
public static T ParseEnum<T>(this string value) => (T)Enum.Parse(typeof(T), value, true);
15+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System.Text.Json;
2+
3+
namespace AStar.Utilities;
4+
5+
/// <summary>
6+
/// The <see cref="ObjectExtensions" /> class contains some useful methods to enable various tasks
7+
/// to be performed in a more fluid, English sentence, style.
8+
/// </summary>
9+
public static class ObjectExtensions
10+
{
11+
/// <summary>
12+
/// The ToJson method, as you might expect, converts the supplied object to its JSON equivalent.
13+
/// </summary>
14+
/// <param name="object">The object to convert to JSON.</param>
15+
/// <returns>The JSON string of the object supplied.</returns>
16+
public static string ToJson<T>(this T @object) => JsonSerializer.Serialize(@object);
17+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System.Text.Json;
2+
3+
namespace AStar.Utilities;
4+
5+
/// <summary>
6+
/// The <see cref="StringExtensions" /> class contains some useful methods to enable checks to be
7+
/// performed in a more fluid, English sentence, style.
8+
/// </summary>
9+
public static class StringExtensions
10+
{
11+
/// <summary>
12+
/// The IsNull method, as you might expect, checks whether the string is, in fact, null.
13+
/// </summary>
14+
/// <param name="value">The string to check for being null.</param>
15+
/// <returns>True if the string is null, False otherwise.</returns>
16+
public static bool IsNull(this string? value) => value is null;
17+
18+
/// <summary>
19+
/// The IsNotNull method, as you might expect, checks whether the string is not null.
20+
/// </summary>
21+
/// <param name="value">The string to check for being not null.</param>
22+
/// <returns>True if the string is not null, False otherwise.</returns>
23+
public static bool IsNotNull(this string? value) => !value.IsNull();
24+
25+
/// <summary>
26+
/// The IsNullOrWhiteSpace method, as you might expect, checks whether the string is, in fact, null, empty or whitespace.
27+
/// </summary>
28+
/// <param name="value">The string to check for being null, empty or whitespace.</param>
29+
/// <returns>True if the string is null, empty or whitespace, False otherwise.</returns>
30+
public static bool IsNullOrWhiteSpace(this string? value) => string.IsNullOrWhiteSpace(value);
31+
32+
/// <summary>
33+
/// The IsNotNullOrWhiteSpace method, as you might expect, checks whether the string is not null, empty or whitespace.
34+
/// </summary>
35+
/// <param name="value">The string to check for being not null, empty or whitespace.</param>
36+
/// <returns>True if the string is not null, empty or whitespace, False otherwise.</returns>
37+
public static bool IsNotNullOrWhiteSpace(this string? value) => !value.IsNullOrWhiteSpace();
38+
39+
/// <summary>
40+
/// The FromJson method, as you might expect, converts the supplied JSON to the specified object.
41+
/// </summary>
42+
/// <typeparam name="T">The required type of the object to deserialise to.</typeparam>
43+
/// <param name="json">The JSON representation of the object.</param>
44+
/// <returns>A deserialised object based on the original JSON.</returns>
45+
public static T FromJson<T>(this string json) => JsonSerializer.Deserialize<T>(json)!;
46+
47+
/// <summary>
48+
/// The FromJson method, as you might expect, converts the supplied JSON to the specified object.
49+
/// </summary>
50+
/// <typeparam name="T">The required type of the object to deserialise to.</typeparam>
51+
/// <param name="json">The JSON representation of the object.</param>
52+
/// <param name="options">Allows the specific <see href="JsonSerializerOptions">options</see> to be set to control deserialisation.</param>
53+
/// <returns>A deserialised object based on the original JSON.</returns>
54+
public static T FromJson<T>(this string json, JsonSerializerOptions options) => JsonSerializer.Deserialize<T>(json, options)!;
55+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
8+
<IsPackable>false</IsPackable>
9+
<IsTestProject>true</IsTestProject>
10+
</PropertyGroup>
11+
12+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
13+
<NoWarn>1701;1702;IDE0058;</NoWarn>
14+
</PropertyGroup>
15+
16+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
17+
<NoWarn>1701;1702;IDE0058;</NoWarn>
18+
</PropertyGroup>
19+
20+
<ItemGroup>
21+
<PackageReference Include="FluentAssertions" Version="6.12.1" />
22+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
23+
<PackageReference Include="xunit" Version="2.9.2" />
24+
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
25+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
26+
<PrivateAssets>all</PrivateAssets>
27+
</PackageReference>
28+
<PackageReference Include="coverlet.collector" Version="6.0.2">
29+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
30+
<PrivateAssets>all</PrivateAssets>
31+
</PackageReference>
32+
</ItemGroup>
33+
34+
<ItemGroup>
35+
<ProjectReference Include="..\..\..\src\AStar.Utilities\AStar.Utilities.csproj" />
36+
</ItemGroup>
37+
38+
</Project>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
global using FluentAssertions;
2+
global using Xunit;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace AStar.Utilities.Unit.Tests.Helpers;
2+
3+
internal class AnyClass
4+
{
5+
public int Id { get; set; }
6+
}

0 commit comments

Comments
 (0)