Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add init #1

Merged
merged 36 commits into from
May 17, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f8e0d22
add init
BenjaminAbt May 15, 2021
de35be3
add bot tests
BenjaminAbt May 15, 2021
f5fd2ad
add regex map
BenjaminAbt May 15, 2021
0f313b9
Apply suggestions from code review
BenjaminAbt May 16, 2021
98cdb64
add memory cache implementation
BenjaminAbt May 16, 2021
7e597e1
add regex
BenjaminAbt May 16, 2021
398e922
remove custom
BenjaminAbt May 16, 2021
e2612ce
add factories
BenjaminAbt May 16, 2021
530468f
remove redirect
BenjaminAbt May 16, 2021
7c5146a
fix naming
BenjaminAbt May 16, 2021
1079944
add cache feedback
BenjaminAbt May 16, 2021
e9016f8
add feedback
BenjaminAbt May 16, 2021
98d6883
remove doubled ctor
BenjaminAbt May 16, 2021
50ec686
add feedback
BenjaminAbt May 16, 2021
76cb8bd
add docs
BenjaminAbt May 16, 2021
6506c43
add feedback
BenjaminAbt May 16, 2021
bfd72a4
add code cleanup
BenjaminAbt May 16, 2021
8da5e86
add docs
BenjaminAbt May 16, 2021
b46a8c8
add docs
BenjaminAbt May 16, 2021
fd79a9f
add feedback
BenjaminAbt May 16, 2021
32f99f4
add docs
BenjaminAbt May 16, 2021
d5c5760
add auto cleanup editconfig
BenjaminAbt May 16, 2021
7401c0e
add feedback
BenjaminAbt May 16, 2021
ed4f6be
add tests
BenjaminAbt May 16, 2021
b268088
add tests
BenjaminAbt May 16, 2021
59a9a5c
add tests
BenjaminAbt May 16, 2021
c412b2d
add tests
BenjaminAbt May 16, 2021
9dfc771
add tests
BenjaminAbt May 16, 2021
59700e3
add cicd
BenjaminAbt May 17, 2021
40fb27e
add feedback
BenjaminAbt May 17, 2021
eaa8a22
add nuget stuff
BenjaminAbt May 17, 2021
06e50e4
add docs
BenjaminAbt May 17, 2021
95593cb
add benchmark
BenjaminAbt May 17, 2021
e0da0a3
add benchmark
BenjaminAbt May 17, 2021
c5ab071
add benchmarks
BenjaminAbt May 17, 2021
8ab6364
fix doc
BenjaminAbt May 17, 2021
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
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: NETCore

on:
push:
branches:
- master
pull_request:
types: [closed]
branches:
- master

env:
BuildConfig: Release

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.

- uses: dotnet/nbgv@master # https://github.com/dotnet/nbgv
id: nbgv

- name: Versioning
run: echo ${{ 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:Version=${{ steps.nbgv.outputs.NuGetPackageVersion }}

- name: Push to NuGet
run: dotnet nuget push **/*.nupkg
--api-key ${{ secrets.NUGET_DEPLOY_KEY }}
--source https://api.nuget.org/v3/index.json
--no-symbols 1
18 changes: 18 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project>
<PropertyGroup>
<MinClientVersion>2.12</MinClientVersion>
<GenerateDocumentationFile Condition=" '$(Configuration)' == 'Release' ">true</GenerateDocumentationFile>
<Authors>MyCSharp.de, Benjamin Abt, Günther Foidl and Contributors</Authors>
<PackageProjectUrl>https://github.com/mycsharp/HttpUserAgentParser</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<DefaultLanguage>en-US</DefaultLanguage>
<IsTestProject>$(MSBuildProjectName.Contains('Test'))</IsTestProject>
BenjaminAbt marked this conversation as resolved.
Show resolved Hide resolved
<Description>HTTP User Agent Parser for .NET</Description>
<NoPackageAnalysis>true</NoPackageAnalysis>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<DebugType>embedded</DebugType>
</PropertyGroup>
</Project>
12 changes: 12 additions & 0 deletions MyCSharp.HttpUserAgentParser.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyCSharp.HttpUserAgentParse
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests", "tests\MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests\MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests.csproj", "{39FC1EC2-2AD3-411F-A545-AB6CCB94FB7E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_", "_", "{5738CE0D-5E6E-47CB-BFF5-08F45A2C33AD}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitignore = .gitignore
.github\workflows\ci.yml = .github\workflows\ci.yml
Directory.Build.props = Directory.Build.props
LICENSE = LICENSE
NuGet.config = NuGet.config
README.md = README.md
version.json = version.json
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<Product>HTTP User Agent Parser Extensions for ASP.NET Core</Product>
<Description>HTTP User Agent Parser Extensions for ASP.NET Core</Description>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\MyCSharp.HttpUserAgentParser\MyCSharp.HttpUserAgentParser.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MyCSharp.HttpUserAgentParser\MyCSharp.HttpUserAgentParser.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public HttpUserAgentParserMemoryCachedProvider(IMemoryCache memoryCache, HttpUse

public HttpUserAgentInformation Parse(string userAgent)
{
CacheKey key = GetKey(userAgent);
CacheKey key = this.GetKey(userAgent);

return _memoryCache.GetOrCreate(key, static entry =>
{
Expand Down Expand Up @@ -53,7 +53,7 @@ private CacheKey GetKey(string userAgent)
public bool Equals(CacheKey? other)
{
if (ReferenceEquals(this, other)) return true;
if (ReferenceEquals(other, null)) return false;
if (other is null) return false;

return this.UserAgent == other.UserAgent && this.Options == other.Options;
}
Expand All @@ -63,14 +63,7 @@ public override bool Equals(object? obj)
return this.Equals(obj as CacheKey);
}

public override int GetHashCode()
{
int hash = 13;
hash = (hash * 7) + UserAgent.GetHashCode();
hash = (hash * 7) + Options.GetHashCode();

return hash;
}
public override int GetHashCode() => HashCode.Combine(this.UserAgent, this.Options);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// Copyright © myCSharp 2020-2021, all rights reserved
// Copyright © myCSharp 2020-2021, all rights reserved

using System;
using Microsoft.Extensions.Caching.Memory;

namespace MyCSharp.HttpUserAgentParser.MemoryCache
{
/// <summary>
/// Provider options for <see cref="HttpUserAgentParserMemoryCachedProvider"/>
/// </summary>
public class HttpUserAgentParserMemoryCachedProviderOptions
{
/// <summary>
Expand All @@ -22,15 +25,15 @@ public HttpUserAgentParserMemoryCachedProviderOptions(MemoryCacheEntryOptions ca

public HttpUserAgentParserMemoryCachedProviderOptions(MemoryCacheOptions? cacheOptions = null, MemoryCacheEntryOptions? cacheEntryOptions = null)
{
CacheEntryOptions = cacheEntryOptions ?? new MemoryCacheEntryOptions
this.CacheEntryOptions = cacheEntryOptions ?? new MemoryCacheEntryOptions
{
// defaults
SlidingExpiration = TimeSpan.FromDays(1)
};
CacheOptions = cacheOptions ?? new MemoryCacheOptions
this.CacheOptions = cacheOptions ?? new MemoryCacheOptions
{
SizeLimit = 256
BenjaminAbt marked this conversation as resolved.
Show resolved Hide resolved
};
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
BenjaminAbt marked this conversation as resolved.
Show resolved Hide resolved

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<Product>HTTP User Agent Parser Extensions for IMemoryCache</Product>
<Description>HTTP User Agent Parser Extensions for IMemoryCache</Description>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\MyCSharp.HttpUserAgentParser.AspNetCore\MyCSharp.HttpUserAgentParser.AspNetCore.csproj" />
<ProjectReference Include="..\MyCSharp.HttpUserAgentParser\MyCSharp.HttpUserAgentParser.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MyCSharp.HttpUserAgentParser\MyCSharp.HttpUserAgentParser.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<Product>HTTP User Agent Parser</Product>
<Description>Parses user agents for Browser, Platform and Bots.</Description>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
BenjaminAbt marked this conversation as resolved.
Show resolved Hide resolved

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.console" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.console" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\MyCSharp.HttpUserAgentParser.AspNetCore\MyCSharp.HttpUserAgentParser.AspNetCore.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\MyCSharp.HttpUserAgentParser.AspNetCore\MyCSharp.HttpUserAgentParser.AspNetCore.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.console" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.console" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\MyCSharp.HttpUserAgentParser.MemoryCache\MyCSharp.HttpUserAgentParser.MemoryCache.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\MyCSharp.HttpUserAgentParser.MemoryCache\MyCSharp.HttpUserAgentParser.MemoryCache.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.console" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.console" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\MyCSharp.HttpUserAgentParser\MyCSharp.HttpUserAgentParser.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\MyCSharp.HttpUserAgentParser\MyCSharp.HttpUserAgentParser.csproj" />
</ItemGroup>

</Project>