Skip to content

Commit

Permalink
Enable implicit usings on all projects (#520)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaliumhexacyanoferrat authored Oct 11, 2024
1 parent 9f87f7f commit b146b77
Show file tree
Hide file tree
Showing 411 changed files with 10,507 additions and 12,630 deletions.
1 change: 0 additions & 1 deletion API/Content/Authentication/IUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ public interface IUser
/// the UI (e.g. a rendered, themed page).
/// </summary>
string DisplayName { get; }

}
7 changes: 1 addition & 6 deletions API/Content/Caching/ICache.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.IO;
using System.Threading.Tasks;

namespace GenHTTP.Api.Content.Caching;
namespace GenHTTP.Api.Content.Caching;

/// <summary>
/// Saves intermediate results for fast access.
Expand Down Expand Up @@ -44,5 +40,4 @@ public interface ICache<T>
/// <param name="variation">The variation specification of the entry</param>
/// <param name="asyncWriter">A callback that allows to write the entry to the target stream</param>
ValueTask StoreDirectAsync(string key, string variation, Func<Stream, ValueTask> asyncWriter);

}
24 changes: 10 additions & 14 deletions API/Content/Concerns.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;

namespace GenHTTP.Api.Content;
namespace GenHTTP.Api.Content;

/// <summary>
/// Utility class to work with concerns.
Expand All @@ -25,21 +22,20 @@ public static class Concerns
/// <returns>The outermost handler or root of the chain</returns>
public static IHandler Chain(IHandler parent, IEnumerable<IConcernBuilder> concerns, Func<IHandler, IHandler> factory)
{
var stack = new Stack<IConcernBuilder>(concerns);
var stack = new Stack<IConcernBuilder>(concerns);

return Chain(parent, stack, factory);
}
return Chain(parent, stack, factory);
}

private static IHandler Chain(IHandler parent, Stack<IConcernBuilder> remainders, Func<IHandler, IHandler> factory)
{
if (remainders.Count > 0)
{
var concern = remainders.Pop();

return concern.Build(parent, (parent) => Chain(parent, remainders, factory));
}
if (remainders.Count > 0)
{
var concern = remainders.Pop();

return factory(parent);
return concern.Build(parent, p => Chain(p, remainders, factory));
}

return factory(parent);
}
}
1 change: 0 additions & 1 deletion API/Content/IConcern.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ public interface IConcern : IHandler
/// The actual handler the concern is added to.
/// </summary>
IHandler Content { get; }

}
5 changes: 1 addition & 4 deletions API/Content/IConcernBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace GenHTTP.Api.Content;
namespace GenHTTP.Api.Content;

/// <summary>
/// Interface which needs to be implementd by factories providing concern instances.
Expand All @@ -15,5 +13,4 @@ public interface IConcernBuilder
/// <param name="contentFactory">A method providing the content of the concern</param>
/// <returns>The newly created concern instance</returns>
IConcern Build(IHandler parent, Func<IHandler, IHandler> contentFactory);

}
16 changes: 9 additions & 7 deletions API/Content/IErrorMapper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Threading.Tasks;

using GenHTTP.Api.Protocol;
using GenHTTP.Api.Protocol;

namespace GenHTTP.Api.Content;

Expand All @@ -19,15 +16,20 @@ public interface IErrorMapper<in T> where T : Exception
/// <param name="request">The request which caused the error</param>
/// <param name="handler">The handler which catched the exception</param>
/// <param name="error">The actual exception to be mapped</param>
/// <returns>A HTTP response to be sent or null, if the error should be handled as not found by the next error handler in the chain</returns>
/// <returns>
/// A HTTP response to be sent or null, if the error should be handled as not found by the next error handler in
/// the chain
/// </returns>
ValueTask<IResponse?> Map(IRequest request, IHandler handler, T error);

/// <summary>
/// Generates a HTTP response for a resource that has not been found.
/// </summary>
/// <param name="request">The currently handled request</param>
/// <param name="handler">The inner handler of the error handling concern</param>
/// <returns>A HTTP response to be sent or null, if the error should be handled as not found by the next error handler in the chain</returns>
/// <returns>
/// A HTTP response to be sent or null, if the error should be handled as not found by the next error handler in
/// the chain
/// </returns>
ValueTask<IResponse?> GetNotFound(IRequest request, IHandler handler);

}
5 changes: 1 addition & 4 deletions API/Content/IHandler.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Threading.Tasks;

using GenHTTP.Api.Protocol;
using GenHTTP.Api.Protocol;

namespace GenHTTP.Api.Content;

Expand Down Expand Up @@ -40,5 +38,4 @@ public interface IHandler
/// <param name="request">The request to be handled</param>
/// <returns>The response to be sent to the requesting client</returns>
ValueTask<IResponse?> HandleAsync(IRequest request);

}
6 changes: 2 additions & 4 deletions API/Content/IHandlerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <summary>
/// Allows to create a handler instance.
/// </summary>
public interface IHandlerBuilder
public interface IHandlerBuilder
{

/// <summary>
Expand All @@ -12,10 +12,9 @@ public interface IHandlerBuilder
/// <param name="parent">The parent of the handler to be created</param>
/// <returns>The newly created handler instance</returns>
IHandler Build(IHandler parent);

}

public interface IHandlerBuilder<TBuilder> : IHandlerBuilder where TBuilder : IHandlerBuilder<TBuilder>
public interface IHandlerBuilder<out TBuilder> : IHandlerBuilder where TBuilder : IHandlerBuilder<TBuilder>
{

/// <summary>
Expand All @@ -27,5 +26,4 @@ public interface IHandlerBuilder<TBuilder> : IHandlerBuilder where TBuilder : IH
/// </remarks>
/// <param name="concern">The concern to be added to the resulting handler</param>
TBuilder Add(IConcernBuilder concern);

}
2 changes: 0 additions & 2 deletions API/Content/IO/ICompressionAlgorithm.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.IO.Compression;

using GenHTTP.Api.Infrastructure;
using GenHTTP.Api.Protocol;

Expand Down Expand Up @@ -32,5 +31,4 @@ public interface ICompressionAlgorithm
/// <param name="level">The compression level to be applied</param>
/// <returns>A result representing the compressed content</returns>
IResponseContent Compress(IResponseContent content, CompressionLevel level);

}
8 changes: 2 additions & 6 deletions API/Content/IO/IResource.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.IO;
using System.Threading.Tasks;
using GenHTTP.Api.Protocol;
using GenHTTP.Api.Protocol;

namespace GenHTTP.Api.Content.IO;

Expand All @@ -19,7 +16,7 @@ public interface IResource
{

/// <summary>
/// The name of this resource, if known.
/// The name of this resource, if known.
/// </summary>
string? Name { get; }

Expand Down Expand Up @@ -63,5 +60,4 @@ public interface IResource
/// <param name="target">The stream to write to</param>
/// <param name="bufferSize">The buffer size to be used for the operation</param>
ValueTask WriteAsync(Stream target, uint bufferSize);

}
6 changes: 1 addition & 5 deletions API/Content/IO/IResourceBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

using GenHTTP.Api.Infrastructure;
using GenHTTP.Api.Infrastructure;
using GenHTTP.Api.Protocol;

namespace GenHTTP.Api.Content.IO;
Expand Down Expand Up @@ -30,7 +28,6 @@ public interface IResourceBuilder<out T> : IBuilder<IResource> where T : IResour
/// </summary>
/// <param name="modified">The modification date and time of the resource</param>
T Modified(DateTime modified);

}

public static class IResourceMetaDataBuilderExtensions
Expand All @@ -41,5 +38,4 @@ public static class IResourceMetaDataBuilderExtensions
/// </summary>
/// <param name="contentType">The content type of the resource</param>
public static T Type<T>(this IResourceBuilder<T> builder, ContentType contentType) where T : IResourceBuilder<T> => builder.Type(FlexibleContentType.Get(contentType));

}
7 changes: 1 addition & 6 deletions API/Content/IO/IResourceContainer.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace GenHTTP.Api.Content.IO;
namespace GenHTTP.Api.Content.IO;

/// <summary>
/// Provides a single hierarchy level in a structure
Expand Down Expand Up @@ -42,5 +38,4 @@ public interface IResourceContainer
/// </summary>
/// <returns>The resources provided by this container</returns>
ValueTask<IReadOnlyCollection<IResource>> GetResources();

}
1 change: 0 additions & 1 deletion API/Content/IO/IResourceNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ public interface IResourceNode : IResourceContainer
/// The parent of this node.
/// </summary>
IResourceContainer Parent { get; }

}
5 changes: 1 addition & 4 deletions API/Content/IO/IResourceTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,4 @@
/// Provides resources organized into a tree structure
/// (e.g. a directory or embedded ressources).
/// </summary>
public interface IResourceTree : IResourceContainer
{

}
public interface IResourceTree : IResourceContainer;
12 changes: 5 additions & 7 deletions API/Content/ProviderException.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

using GenHTTP.Api.Protocol;
using GenHTTP.Api.Protocol;

namespace GenHTTP.Api.Content;

Expand All @@ -26,13 +24,13 @@ public class ProviderException : Exception

public ProviderException(ResponseStatus status, string message) : base(message)
{
Status = status;
}
Status = status;
}

public ProviderException(ResponseStatus status, string message, Exception inner) : base(message, inner)
{
Status = status;
}
Status = status;
}

#endregion

Expand Down
81 changes: 41 additions & 40 deletions API/GenHTTP.Api.csproj
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>

<TargetFrameworks>net8.0;net9.0</TargetFrameworks>

<LangVersion>13.0</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

<AssemblyVersion>9.0.0.0</AssemblyVersion>
<FileVersion>9.0.0.0</FileVersion>
<Version>9.0.0</Version>

<Authors>Andreas Nägeli</Authors>
<Company />

<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageProjectUrl>https://genhttp.org/</PackageProjectUrl>

<Description>Public API of the GenHTTP webserver. This package is at least required to build a project that can be executed with the GenHTTP webserver.</Description>
<PackageTags>HTTP Embedded Webserver Website Server Library C# Standard API</PackageTags>

<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>

<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>CS1591,CS1587,CS1572,CS1573</NoWarn>

<PackageIcon>icon.png</PackageIcon>

</PropertyGroup>

<ItemGroup>

<None Include="..\LICENSE" Pack="true" PackagePath="\" />
<None Include="..\Resources\icon.png" Pack="true" PackagePath="\" />

<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />

</ItemGroup>
<PropertyGroup>

<TargetFrameworks>net8.0;net9.0</TargetFrameworks>

<LangVersion>13.0</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<ImplicitUsings>enable</ImplicitUsings>

<AssemblyVersion>9.0.0.0</AssemblyVersion>
<FileVersion>9.0.0.0</FileVersion>
<Version>9.0.0</Version>

<Authors>Andreas Nägeli</Authors>
<Company/>

<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageProjectUrl>https://genhttp.org/</PackageProjectUrl>

<Description>Public API of the GenHTTP webserver. This package is at least required to build a project that can be executed with the GenHTTP webserver.</Description>
<PackageTags>HTTP Embedded Webserver Website Server Library C# Standard API</PackageTags>

<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>

<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>CS1591,CS1587,CS1572,CS1573</NoWarn>

<PackageIcon>icon.png</PackageIcon>

</PropertyGroup>

<ItemGroup>

<None Include="..\LICENSE" Pack="true" PackagePath="\"/>
<None Include="..\Resources\icon.png" Pack="true" PackagePath="\"/>

<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>

</ItemGroup>

</Project>
7 changes: 2 additions & 5 deletions API/Infrastructure/BindingException.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace GenHTTP.Api.Infrastructure;
namespace GenHTTP.Api.Infrastructure;

/// <summary>
/// Will be thrown, if the server cannot bind to the requested port for some reason.
Expand All @@ -12,6 +10,5 @@ public class BindingException : Exception
public BindingException(string message, Exception inner) : base(message, inner)
{

}

}
}
Loading

0 comments on commit b146b77

Please sign in to comment.