Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ jobs:
runs-on: ubuntu-latest

env:
Solution_File: Smidge.sln
Solution_File: Smidge.slnx
Test_Proj: test/Smidge.Tests/Smidge.Tests.csproj
Configuration: Release

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -42,11 +42,10 @@ jobs:
shell: pwsh

- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
8.0.x
10.0.x

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v3.0.3
Expand Down
8 changes: 8 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>

<PropertyGroup>
<!-- Fail the build on any compiler or NuGet warning so issues are caught in CI rather than ignored -->
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

</Project>
73 changes: 0 additions & 73 deletions Smidge.sln

This file was deleted.

28 changes: 28 additions & 0 deletions Smidge.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Solution>
<Configurations>
<Platform Name="Any CPU" />
<Platform Name="x64" />
<Platform Name="x86" />
</Configurations>
<Folder Name="/Solution Items/">
<File Path=".editorconfig" />
<File Path=".github/workflows/build.yml" />
<File Path=".github/workflows/test-report.yml" />
<File Path=".gitignore" />
<File Path="GitVersion.yml.bak" />
<File Path="LICENSE" />
<File Path="Nuget.config" />
<File Path="README.md" />
<File Path="src/Directory.Build.props" />
</Folder>
<Folder Name="/src/">
<Project Path="src/Smidge.Core/Smidge.Core.csproj" />
<Project Path="src/Smidge.InMemory/Smidge.InMemory.csproj" />
<Project Path="src/Smidge.Web/Smidge.Web.csproj" />
<Project Path="src/Smidge/Smidge.csproj" />
</Folder>
<Folder Name="/test/">
<Project Path="test/Smidge.Integration.Tests/Smidge.Integration.Tests.csproj" />
<Project Path="test/Smidge.Tests/Smidge.Tests.csproj" />
</Folder>
</Solution>
7 changes: 5 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<Project>

<!-- Import the repo-root props (TreatWarningsAsErrors, etc.) since the nearest-only auto-import stops here -->
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

<PropertyGroup>
<!-- These are Source link props -->
<PublishRepositoryUrl>https://github.com/Shazwazza/Smidge</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<LangVersion>9.0</LangVersion>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
Expand All @@ -23,6 +26,6 @@
<VersionPrefix>5.0.0</VersionPrefix>
</PropertyGroup>
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0;</TargetFrameworks>
<TargetFrameworks>net10.0</TargetFrameworks>
</PropertyGroup>
</Project>
16 changes: 16 additions & 0 deletions src/Smidge.Core/Cache/ICacheFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,23 @@ namespace Smidge.Cache
/// </summary>
public interface ICacheFileSystem
{
/// <summary>
/// Gets the <see cref="IFileInfo"/> for a cached file, throwing a <see cref="System.IO.FileNotFoundException"/> if it does not exist.
/// </summary>
/// <remarks>
/// Use this only when the file is expected to exist as an internal invariant. For request handling where the
/// path is (or can be) client supplied, use <see cref="GetFileInfo(string)"/> and check <see cref="IFileInfo.Exists"/>
/// so that a missing/stale/spoofed file results in a graceful 404 instead of an unhandled 500.
/// </remarks>
IFileInfo GetRequiredFileInfo(string filePath);

/// <summary>
/// Gets the <see cref="IFileInfo"/> for a cached file without throwing when it does not exist.
/// </summary>
/// <remarks>
/// The returned <see cref="IFileInfo"/> may have <see cref="IFileInfo.Exists"/> set to <c>false</c>; callers must check it.
/// </remarks>
IFileInfo GetFileInfo(string filePath);
Task ClearCachedCompositeFileAsync(string cacheBusterValue, CompressionType type, string filesetKey);
IFileInfo GetCachedCompositeFile(string cacheBusterValue, CompressionType type, string filesetKey, out string filePath);
IFileInfo GetCacheFile(IWebFile file, Func<IFileInfo> sourceFile, bool fileWatchEnabled, string extension, string cacheBusterValue, out string filePath);
Expand Down
2 changes: 2 additions & 0 deletions src/Smidge.Core/Cache/PhysicalFileCacheFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public IFileInfo GetRequiredFileInfo(string filePath)
return fileInfo;
}

public IFileInfo GetFileInfo(string filePath) => _fileProvider.GetFileInfo(filePath);

private string GetCompositeFilePath(string cacheBusterValue, CompressionType type, string filesetKey) => $"{cacheBusterValue}/{type}/{filesetKey}.s";

public Task ClearCachedCompositeFileAsync(string cacheBusterValue, CompressionType type, string filesetKey)
Expand Down
File renamed without changes.
22 changes: 7 additions & 15 deletions src/Smidge.Core/Smidge.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,12 @@
<ItemGroup>
<Content Include="..\..\assets\logo-nuget.png" Link="logo-nuget.png" Pack="true" PackagePath="" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Composite" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.4" />
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Composite" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.9" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="10.0.9" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Composite" Version="10.0.9" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="10.0.9" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.9" />
<PackageReference Include="Microsoft.Extensions.Options" Version="10.0.9" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System;
using System.Linq;
using System.Runtime.CompilerServices;
using Smidge.Models;

[assembly: InternalsVisibleTo("Smidge")]

namespace Smidge
{
internal class SmidgeRequire : ISmidgeRequire
Expand Down
3 changes: 3 additions & 0 deletions src/Smidge.InMemory/ConfiguredCacheFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public IFileInfo GetCacheFile(IWebFile file, Func<IFileInfo> sourceFile, bool fi
public IFileInfo GetRequiredFileInfo(string filePath)
=> _wrapped.GetRequiredFileInfo(filePath);

public IFileInfo GetFileInfo(string filePath)
=> _wrapped.GetFileInfo(filePath);

public Task WriteFileAsync(string filePath, string contents)
=> _wrapped.WriteFileAsync(filePath, contents);

Expand Down
2 changes: 2 additions & 0 deletions src/Smidge.InMemory/MemoryCacheFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public IFileInfo GetRequiredFileInfo(string filePath)
return fileInfo;
}

public IFileInfo GetFileInfo(string filePath) => _fileProvider.GetFileInfo(filePath);

private string GetCompositeFilePath(string cacheBusterValue, CompressionType type, string filesetKey)
=> $"{cacheBusterValue}/{type}/{filesetKey + ".s"}";

Expand Down
9 changes: 0 additions & 9 deletions src/Smidge.InMemory/Smidge.InMemory.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@
<ItemGroup>
<PackageReference Include="Dazinator.Extensions.FileProviders" Version="2.0.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Dazinator.Extensions.FileProviders" Version="2.0.0" />
<!-- Due to a security issue we need an explicit ref https://github.com/dotnet/announcements/issues/178 -->
<PackageReference Include="System.Text.Encodings.Web" Version="8.0.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<!-- Due to a security issue we need an explicit ref https://github.com/dotnet/announcements/issues/178 -->
<PackageReference Include="System.Text.Encodings.Web" Version="6.0.1" />
</ItemGroup>
<ItemGroup>
<Content Include="..\..\assets\logo-nuget.png" Link="logo-nuget.png" Pack="true" PackagePath="" />
</ItemGroup>
Expand Down
9 changes: 4 additions & 5 deletions src/Smidge.Web/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
Expand Down Expand Up @@ -48,10 +47,10 @@ public static void Main(string[] args)
BuildWebHost(args).Run();
}

public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
public static IHost BuildWebHost(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>())
.Build();

public IConfigurationRoot Configuration { get; }
public IWebHostEnvironment CurrentEnvironment { get; }
Expand Down
75 changes: 0 additions & 75 deletions src/Smidge/Controllers/AddCompressionHeaderAttribute.cs

This file was deleted.

Loading
Loading