Skip to content

Commit

Permalink
Extracting abstractions package. Resolves #19
Browse files Browse the repository at this point in the history
  • Loading branch information
tpeczek authored May 29, 2022
2 parents 0f47c35 + 00e3a72 commit e7669ef
Show file tree
Hide file tree
Showing 15 changed files with 99 additions and 10 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/cd-aspnetcore-abstractions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Lib.AspNetCore.ServerTiming.Abstractions - CD
on:
push:
tags:
- "aspnetcore-abstractions-v[0-9]+.[0-9]+.[0-9]+"
jobs:
deployment:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Extract VERSION
run: echo "VERSION=${GITHUB_REF/refs\/tags\/aspnetcore-abstractions-v/}" >> $GITHUB_ENV
shell: bash
- name: Setup .NET Core 2.1 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: '2.1.x'
- name: Setup .NET Core 3.1 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
- name: Setup .NET 5.0 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.x'
- name: Setup .NET 6.0 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --configuration Release --no-build
- name: Pack
run: dotnet pack --configuration Release --no-build
- name: NuGet Push Lib.AspNetCore.ServerTiming.Abstractions
run: dotnet nuget push Lib.AspNetCore.ServerTiming.Abstractions/bin/Release/Lib.AspNetCore.ServerTiming.Abstractions.${VERSION}.nupkg --source https://api.nuget.org/v3/index.json --api-key ${NUGET_API_KEY}
shell: bash
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: CD
name: Lib.AspNetCore.ServerTiming - CD
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "aspnetcore-v[0-9]+.[0-9]+.[0-9]+"
jobs:
deployment:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Extract VERSION
run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
run: echo "VERSION=${GITHUB_REF/refs\/tags\/aspnetcore-v/}" >> $GITHUB_ENV
shell: bash
- name: Setup .NET Core 2.1 SDK
uses: actions/setup-dotnet@v1
Expand Down
1 change: 1 addition & 0 deletions DocFx.AspNetCore.ServerTiming/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"src": [
{
"files": [
"Lib.AspNetCore.ServerTiming.Abstractions/Lib.AspNetCore.ServerTiming.Abstractions.csproj",
"Lib.AspNetCore.ServerTiming/Lib.AspNetCore.ServerTiming.csproj"
],
"exclude": [ "**/bin/**", "**/obj/**" ],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Lib.AspNetCore.ServerTiming.Abstractions provides abstractions for Lib.AspNetCore.ServerTiming, a library which provides Server Timing API support for ASP.NET Core.</Description>
<Copyright>Copyright © 2022 Tomasz Pęczek</Copyright>
<VersionPrefix>1.0.0</VersionPrefix>
<Authors>Tomasz Pęczek</Authors>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0;net6.0;net461</TargetFrameworks>
<AssemblyTitle>Lib.AspNetCore.ServerTiming.Abstractions</AssemblyTitle>
<AssemblyName>Lib.AspNetCore.ServerTiming.Abstractions</AssemblyName>
<PackageId>Lib.AspNetCore.ServerTiming.Abstractions</PackageId>
<PackageTags>aspnetcore;servertiming;performance</PackageTags>
<PackageProjectUrl>https://github.com/tpeczek/Lib.AspNetCore.ServerTiming</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>git://github.com/tpeczek/Lib.AspNetCore.ServerTiming</RepositoryUrl>
<GenerateAssemblyTitleAttribute>true</GenerateAssemblyTitleAttribute>
<GenerateAssemblyDescriptionAttribute>true</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyProductAttribute>true</GenerateAssemblyProductAttribute>
<GenerateAssemblyCopyrightAttribute>true</GenerateAssemblyCopyrightAttribute>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<None Include="..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup Condition="('$(TargetFramework)' == 'netcoreapp2.1') Or ('$(TargetFramework)' == 'net461')">
<PackageReference Include="Microsoft.AspNetCore.Http" Version="[2.1.0,3.0.0)" />
</ItemGroup>
<ItemGroup Condition="('$(TargetFramework)' != 'netcoreapp2.1') And ('$(TargetFramework)' != 'net461')">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="DotNet.ReproducibleBuilds" Version="0.1.66" PrivateAssets="All" />
</ItemGroup>
</Project>
8 changes: 7 additions & 1 deletion Lib.AspNetCore.ServerTiming.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test.AspNetCore.ServerTimin
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Demo.AspNetCore.ServerTiming", "Demo.AspNetCore.ServerTiming\Demo.AspNetCore.ServerTiming.csproj", "{C7A47113-CBA9-486C-8F95-50B2E12D71B3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFx.AspNetCore.ServerTiming", "DocFx.AspNetCore.ServerTiming\DocFx.AspNetCore.ServerTiming.csproj", "{E7DC599F-40C9-4651-97B9-6B47CD05BA0D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocFx.AspNetCore.ServerTiming", "DocFx.AspNetCore.ServerTiming\DocFx.AspNetCore.ServerTiming.csproj", "{E7DC599F-40C9-4651-97B9-6B47CD05BA0D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0AE38B1E-B1A7-4CB7-8F17-54AED3982407}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -18,6 +18,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lib.AspNetCore.ServerTiming.Abstractions", "Lib.AspNetCore.ServerTiming.Abstractions\Lib.AspNetCore.ServerTiming.Abstractions.csproj", "{B7DECE31-F8E4-4503-BF5B-1A8D5671F4FD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -40,6 +42,10 @@ Global
{E7DC599F-40C9-4651-97B9-6B47CD05BA0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E7DC599F-40C9-4651-97B9-6B47CD05BA0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E7DC599F-40C9-4651-97B9-6B47CD05BA0D}.Release|Any CPU.Build.0 = Release|Any CPU
{B7DECE31-F8E4-4503-BF5B-1A8D5671F4FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B7DECE31-F8E4-4503-BF5B-1A8D5671F4FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B7DECE31-F8E4-4503-BF5B-1A8D5671F4FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B7DECE31-F8E4-4503-BF5B-1A8D5671F4FD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public override bool OnServerTimingHeaderPreparation(HttpContext context, IColle
{
if (!IsDevelopment)
{
List<ServerTimingMetric> newMetrics = metrics .Select(m => new ServerTimingMetric(m.Name,m.Value,null)).ToList();
List<ServerTimingMetric> newMetrics = metrics .Select(m => m.Value.HasValue ? new ServerTimingMetric(m.Name, m.Value.Value, null) : new ServerTimingMetric(m.Name, null)).ToList();
metrics.Clear();
newMetrics.ForEach(m => metrics.Add(m));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<ItemGroup>
<None Include="..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Lib.AspNetCore.ServerTiming.Abstractions\Lib.AspNetCore.ServerTiming.Abstractions.csproj" />
</ItemGroup>
<ItemGroup Condition="('$(TargetFramework)' == 'netcoreapp2.1') Or ('$(TargetFramework)' == 'net461')">
<PackageReference Include="Microsoft.AspNetCore.Http" Version="[2.1.0,3.0.0)" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="[2.1.0,3.0.0)" />
Expand Down
3 changes: 1 addition & 2 deletions Lib.AspNetCore.ServerTiming/ServerTimingUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ internal static void SetServerTimingDeliveryMode(this IServerTiming serverTiming
}

// Format a metric name from caller params --> "{fileName}.{function}+{lineNumber}
private static string FormatCallerName(string functionName, string filePath, int lineNumber) =>
String.Concat(Path.GetFileNameWithoutExtension(filePath), ".", functionName, "+", lineNumber);
private static string FormatCallerName(string functionName, string filePath, int lineNumber) => String.Concat(Path.GetFileNameWithoutExtension(filePath), ".", functionName, "+", lineNumber);

// On dispose, add server timing performance metric.
private sealed class ServerTimingInstance : IDisposable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Net;
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Lib.AspNetCore.ServerTiming.Http.Headers;
using Lib.AspNetCore.ServerTiming.Filters;
using Lib.AspNetCore.ServerTiming.Http.Headers;
using Xunit;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Lib.AspNetCore.ServerTiming.Http.Headers;
using Lib.AspNetCore.ServerTiming.Filters;
using Lib.AspNetCore.ServerTiming.Http.Headers;
using Moq;
using Xunit;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Lib.AspNetCore.ServerTiming.Http.Headers;
using Lib.AspNetCore.ServerTiming.Filters;
using Lib.AspNetCore.ServerTiming.Http.Headers;
using Moq;
using Xunit;

Expand Down

0 comments on commit e7669ef

Please sign in to comment.