Skip to content

Commit

Permalink
add nuget and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminAbt committed Aug 16, 2024
1 parent a02cf56 commit 2dd6adf
Show file tree
Hide file tree
Showing 22 changed files with 193 additions and 121 deletions.
53 changes: 53 additions & 0 deletions .github/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: NET

on:
push:
branches:
- main
pull_request:
branches:
- main

env:
BuildConfig: Release
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true

jobs:
build:
runs-on: ubuntu-latest
steps:

- name: Cancel previous builds in PR
uses: styfle/[email protected]

- name: 'Checkout Code'
uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.

- name: 'Install .NET SDK'
uses: actions/setup-dotnet@v4
with:
global-json-file: ./global.json

- name: Versioning
uses: dotnet/nbgv@master
id: nbgv

- name: Version Info
run: |
echo 'SemVer2: ${{ steps.nbgv.outputs.SemVer2 }}'
- name: Build with dotnet
run: dotnet build
--configuration ${{ env.BuildConfig }}
/p:Version=${{ steps.nbgv.outputs.AssemblyVersion }}

- name: Test with dotnet
run: dotnet test

- name: Pack NuGet
run: dotnet pack
--configuration ${{ env.BuildConfig }}
/p:ContinuousIntegrationBuild=true
/p:Version=${{ steps.nbgv.outputs.NuGetPackageVersion }}
7 changes: 7 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
</PackageVersion>
</ItemGroup>

<ItemGroup Label="DevOps">
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.6.133">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageVersion>
</ItemGroup>

<ItemGroup Label="Tests">
<PackageVersion Include="Moq" Version="4.20.70" />
<PackageVersion Include="MSTest.TestFramework" Version="3.5.1" />
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MIT License
MIT License
Copyright (c) 2013-2024 Benjamin Abt

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Expand Down
15 changes: 11 additions & 4 deletions src/QuickIO/DirectoryAlreadyExistsException.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
namespace SchwabenCode.QuickIO;

/// <summary>
/// This error is raised if you want to create for example a folder which already exists.
/// Represents an exception that is thrown when an operation encounters an existing directory
/// that was expected to be unique or non-existent.
/// </summary>
/// <remarks>
/// This exception is typically used in scenarios involving directory creation where
/// a unique directory path is required. It provides detailed information about the conflicting
/// directory path, assisting in error handling and debugging.
/// </remarks>
[Serializable]
public class DirectoryAlreadyExistsException : QuickIOBaseException
{
/// <summary>
/// Creates an instance of <see cref="DirectoryAlreadyExistsException"/>
/// Initializes a new instance of the <see cref="DirectoryAlreadyExistsException"/> class
/// with a specified error message and the directory path that caused the exception.
/// </summary>
/// <param name="message">Error message</param>
/// <param name="path">Affected directory path</param>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="path">The directory path that already exists and caused the exception to be thrown.</param>
public DirectoryAlreadyExistsException(string message, string path)
: base(message, path) { }
}
15 changes: 11 additions & 4 deletions src/QuickIO/DirectoryNotEmptyException.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
namespace SchwabenCode.QuickIO;

/// <summary>
/// This error is raised if a folder that is not empty should be deleted.
/// Represents an exception that is thrown when an operation fails because a directory
/// that was expected to be empty is not.
/// </summary>
/// <remarks>
/// This exception is typically used in scenarios where a directory must be empty
/// for a specific operation to proceed, such as deletion or renaming. It provides detailed
/// information about the non-empty directory path, aiding in error handling and debugging.
/// </remarks>
[Serializable]
public class DirectoryNotEmptyException : QuickIOBaseException
{
/// <summary>
/// Creates an instance of <see cref="DirectoryNotEmptyException"/>
/// Initializes a new instance of the <see cref="DirectoryNotEmptyException"/> class
/// with a specified error message and the directory path that caused the exception.
/// </summary>
/// <param name="message">Error message</param>
/// <param name="path">Affected directory path</param>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="path">The directory path that is not empty and caused the exception to be thrown.</param>
public DirectoryNotEmptyException(string message, string path)
: base(message, path)
{
Expand Down
30 changes: 18 additions & 12 deletions src/QuickIO/FileAlreadyExistsException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,34 @@
namespace SchwabenCode.QuickIO;

/// <summary>
/// This error is raised if a file should be created that already exists.
/// </summary>
/// Represents an exception that is thrown when an operation encounters an existing file
/// that was expected to be unique or non-existent.
/// </summary>
/// <remarks>
/// This exception is typically used in scenarios involving file creation where a unique
/// file path is required. It provides detailed information about the conflicting file path,
/// assisting in error handling and debugging.
/// </remarks>
[Serializable]
public class FileAlreadyExistsException : QuickIOBaseException
{
/// <summary>
/// Creates an instance of <see cref="FileAlreadyExistsException"/>
/// Initializes a new instance of the <see cref="FileAlreadyExistsException"/> class
/// with the file path that caused the exception. The error message is automatically
/// generated based on the Win32 error code for "file already exists."
/// </summary>
/// <param name="path">Affected file path</param>
/// <param name="path">The file path that already exists and caused the exception to be thrown.</param>
public FileAlreadyExistsException(string path)
: base(Win32ErrorCodes.FormatMessage(Win32ErrorCodes.ERROR_ALREADY_EXISTS), path)
{
}
{ }

/// <summary>
/// Creates an instance of <see cref="FileAlreadyExistsException"/>
/// Initializes a new instance of the <see cref="FileAlreadyExistsException"/> class
/// with a specified error message and the file path that caused the exception.
/// </summary>
/// <param name="message">Error message</param>
/// <param name="path">Affected file path</param>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="path">The file path that already exists and caused the exception to be thrown.</param>
public FileAlreadyExistsException(string message, string path)
: base(message, path)
{
}
{ }
}

13 changes: 9 additions & 4 deletions src/QuickIO/FileSystemIsBusyException.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
namespace SchwabenCode.QuickIO;

/// <summary>
/// This error is raised if file system is busy and further operations are not able to execute
/// Represents an exception that is thrown when a file system operation fails because the target file or directory is currently in use or locked by another process.
/// </summary>
/// <remarks>
/// This exception is typically used in scenarios where operations like deleting, moving, or modifying files and directories cannot be completed
/// because they are being accessed by other processes. It provides detailed information about the busy path, aiding in error handling and debugging.
/// </remarks>
[Serializable]
public class FileSystemIsBusyException : QuickIOBaseException
{
/// <summary>
/// Creates an instance of <see cref="FileSystemIsBusyException"/>
/// Initializes a new instance of the <see cref="FileSystemIsBusyException"/> class
/// with a specified error message and the path that caused the exception.
/// </summary>
/// <param name="message">Error message</param>
/// <param name="path">Affected directory path</param>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="path">The file or directory path that is currently in use and caused the exception to be thrown.</param>
public FileSystemIsBusyException(string message, string path)
: base(message, path)
{
Expand Down
20 changes: 14 additions & 6 deletions src/QuickIO/InvalidPathException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,33 @@
namespace SchwabenCode.QuickIO;

/// <summary>
/// Invalid Path Exception
/// Represents an exception that is thrown when a provided file or directory path is invalid.
/// </summary>
/// <remarks>
/// This exception is typically used in scenarios where a path does not conform to the expected format,
/// such as containing illegal characters or being otherwise malformed. It provides detailed information
/// about the invalid path, assisting in error handling and debugging.
/// </remarks>
[Serializable]
public class InvalidPathException : QuickIOBaseException
{
/// <summary>
/// Invalid Path Exception
/// Initializes a new instance of the <see cref="InvalidPathException"/> class
/// with the path that caused the exception. The error message is automatically generated
/// based on the Win32 error code for "invalid name."
/// </summary>
/// <param name="path">Invalid Path</param>
/// <param name="path">The file or directory path that is invalid and caused the exception to be thrown.</param>
public InvalidPathException(string path)
: base(Win32ErrorCodes.FormatMessage(Win32ErrorCodes.ERROR_INVALID_NAME), path)
{
}

/// <summary>
/// Invalid Path Exception
/// Initializes a new instance of the <see cref="InvalidPathException"/> class
/// with a specified error message and the path that caused the exception.
/// </summary>
/// <param name="message">Error Message</param>
/// <param name="path">Invalid Path</param>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="path">The file or directory path that is invalid and caused the exception to be thrown.</param>
public InvalidPathException(string message, string path)
: base(message, path)
{
Expand Down
22 changes: 13 additions & 9 deletions src/QuickIO/PathAlreadyExistsException.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
using System.Diagnostics.Contracts;


namespace SchwabenCode.QuickIO;

/// <summary>
/// Exception if path does not exist.
/// Represents an exception that is thrown when an operation encounters an existing path
/// that was expected to be unique or non-existent.
/// </summary>
/// <remarks>
/// This exception is typically used in scenarios involving file or directory creation
/// where a unique path is required. The exception provides detailed information about
/// the conflicting path, allowing for better error handling and debugging.
/// </remarks>
[Serializable]
public class PathAlreadyExistsException : QuickIOBaseException
{
/// <summary>
/// Exception if path does not exist.
/// Initializes a new instance of the <see cref="PathAlreadyExistsException"/> class
/// with a specified error message and the path that caused the exception.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="path">The path that already exists and caused the exception to be thrown.</param>
public PathAlreadyExistsException(string message, string path)
: base(message, path)
{
Contract.Requires(!string.IsNullOrWhiteSpace(message));
Contract.Requires(!string.IsNullOrWhiteSpace(path));
}
: base(message, path) { }
}
26 changes: 17 additions & 9 deletions src/QuickIO/PathNotFoundException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,32 @@
namespace SchwabenCode.QuickIO;

/// <summary>
/// Exception if path does not exist.
/// Represents an exception that is thrown when an operation fails due to a specified
/// path not being found.
/// </summary>
/// <remarks>
/// This exception is typically used in scenarios involving file or directory access where
/// the specified path does not exist. It provides detailed information about the missing
/// path, aiding in error handling and debugging.
/// </remarks>
[Serializable]
public class PathNotFoundException : QuickIOBaseException
{
/// <summary>
/// Exception if path does not exist.
/// Initializes a new instance of the <see cref="PathNotFoundException"/> class
/// with a specified path that caused the exception. The error message is automatically
/// generated based on the Win32 error code for "path not found."
/// </summary>
/// <param name="path">The path that was not found and caused the exception to be thrown.</param>
public PathNotFoundException(string path)
: base(Win32ErrorCodes.FormatMessage(Win32ErrorCodes.ERROR_PATH_NOT_FOUND), path)
{
}
: base(Win32ErrorCodes.FormatMessage(Win32ErrorCodes.ERROR_PATH_NOT_FOUND), path) { }

/// <summary>
/// Exception if path does not exist.
/// Initializes a new instance of the <see cref="PathNotFoundException"/> class
/// with a specified error message and the path that caused the exception.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="path">The path that was not found and caused the exception to be thrown.</param>
public PathNotFoundException(string message, string path)
: base(message, path)
{
}
: base(message, path) { }
}
5 changes: 3 additions & 2 deletions src/QuickIO/QuickIO.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using SchwabenCode.QuickIO.Internal;
using System.Diagnostics.CodeAnalysis;
using SchwabenCode.QuickIO.Internal;

namespace SchwabenCode.QuickIO;

Expand All @@ -15,7 +16,7 @@ public static partial class QuickIO
/// <returns></returns>
/// <exception cref="UnmatchedFileSystemEntryTypeException">Searched for file but found folder.</exception>
/// <exception cref="InvalidPathException">Path is invalid.</exception>
public static bool FileExists(string path)
public static bool FileExists([NotNullWhen(true)] string path)
{
return QuickIOFile.Exists(path);
}
Expand Down
13 changes: 9 additions & 4 deletions src/QuickIO/QuickIO.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">


<PropertyGroup Label="Package">
<PackageId>QuickIO.NET</PackageId>
<IsPackable>true</IsPackable>
<PackageReadmeFile>readme.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
</PropertyGroup>


<ItemGroup>
<None Update="CodeTemplates\SaveOutput.tt">
<Generator>TextTemplatingFileGenerator</Generator>
Expand Down Expand Up @@ -176,8 +185,4 @@
<DependentUpon>QuickIOFile_Root_Async.tt</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
</Project>
20 changes: 0 additions & 20 deletions src/QuickIO/QuickIODirectoryInfo_Async.cs

This file was deleted.

Loading

0 comments on commit 2dd6adf

Please sign in to comment.