From 44d7ed94e404ce5d7cfa648fb7103434499d86f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Foidl?= Date: Tue, 18 May 2021 14:45:07 +0200 Subject: [PATCH] Strong name signing of assemblies (#18) * Enabled .Net Standard 2.0 too * Make .NS 2.0 code cleaner * Strong name signing * Fixed CI * Make string.Contains on NS2.0 the same behavior as NS2.1 --- Directory.Build.props | 10 ++++++ MyCSharp.HttpUserAgentParser.sln | 2 +- MyCSharp.HttpUserAgentParser.snk | Bin 0 -> 596 bytes ...harp.HttpUserAgentParser.Benchmarks.csproj | 4 +++ ...HttpUserAgentParserMemoryCachedProvider.cs | 5 +++ ...arp.HttpUserAgentParser.MemoryCache.csproj | 6 +++- .../MyCSharp.HttpUserAgentParser.csproj | 6 +++- src/NetStandard2.0-Shim.cs | 30 ++++++++++++++++++ 8 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 MyCSharp.HttpUserAgentParser.snk create mode 100644 src/NetStandard2.0-Shim.cs diff --git a/Directory.Build.props b/Directory.Build.props index b736c47..8cee08b 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,4 +1,5 @@ + 2.12 MyCSharp.de, Benjamin Abt, Günther Foidl and Contributors @@ -15,9 +16,18 @@ $(MSBuildProjectName.Contains('Test')) $(MsBuildProjectName.Contains('Benchmark')) false + true true + + + true + $(MSBuildThisFileDirectory)MyCSharp.HttpUserAgentParser.snk + + 00240000048000009400000006020000002400005253413100040000010001003d5c022c088a46d41d5a5bf7591f3a3dcba30f76b0f43a312b6e45bb419d32283175cbd8bfd83134b123da6db83479e50596fb6bbe0e8c6cef50c01c64a0861c963daaf6905920f44ffe1ce44b3cfcb9c23779f34bc90c7b04e74e36a19bb58af3a69456d49b56993969dba9f8e9e935c2757844a11066d1091477f10cd923b7 + + diff --git a/MyCSharp.HttpUserAgentParser.sln b/MyCSharp.HttpUserAgentParser.sln index defb60f..f5e1dd7 100644 --- a/MyCSharp.HttpUserAgentParser.sln +++ b/MyCSharp.HttpUserAgentParser.sln @@ -33,7 +33,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_", "_", "{5738CE0D-5E6E-47 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "perf", "perf", "{FAAD18A0-E1B8-448D-B611-AFBDA8A89808}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyCSharp.HttpUserAgentParser.Benchmarks", "perf\MyCSharp.HttpUserAgentParser.Benchmarks\MyCSharp.HttpUserAgentParser.Benchmarks.csproj", "{A0D213E9-6408-46D1-AFAF-5096C2F6E027}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyCSharp.HttpUserAgentParser.Benchmarks", "perf\MyCSharp.HttpUserAgentParser.Benchmarks\MyCSharp.HttpUserAgentParser.Benchmarks.csproj", "{A0D213E9-6408-46D1-AFAF-5096C2F6E027}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/MyCSharp.HttpUserAgentParser.snk b/MyCSharp.HttpUserAgentParser.snk new file mode 100644 index 0000000000000000000000000000000000000000..76170899d56adbd122336f9cce998a8edbfb27b4 GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50096!Tmmczibm8OT3h#7A38nDqYrkl^g1ys zZbiF6oiZpfb<5bl*fBJ*Bie1aG zJp8%BH+l0*$qai0=T0`Eo3)Dbrj%CHn^u`QY1^sz>FG7Xb$CRf5N6Q{6nF6q*(0~F zRO}r73PNg+nM5k2C*J`>X;w?Dr8@dRUUTxfAfRqyYqPgr%t)P4zg6)blatsfn{0zb z*y~*?cw6tPzsT9saFlh1an7w4af`*>gg$6WzI-~YEMO2wIlh}2(gW4Z)ND7>%y-In zpl<4Dxkh(E<~e~G%dXYCXf0%+(ni;NHp?3~x@w&4*&gitB=?VuO~tJfWNMjpCC{5P zJPQ{tBg#0AXIC8vf%=ciey({$x12}R_HLalobbrAO~wz4+Y*%Dt?J%-gB&L|Y#V{%H!6H$n<}327eG%~ zR+ocVTO&WY%>dR-{d%!W%-p4RTJ&OEZpyq!4RpCW0SHfh##0fx9|b|wTO?6MzMBr@{XQ+=9??cE^9J6WIXvZs|;`U2Xl^^y1 literal 0 HcmV?d00001 diff --git a/perf/MyCSharp.HttpUserAgentParser.Benchmarks/MyCSharp.HttpUserAgentParser.Benchmarks.csproj b/perf/MyCSharp.HttpUserAgentParser.Benchmarks/MyCSharp.HttpUserAgentParser.Benchmarks.csproj index bfe6d06..801f331 100644 --- a/perf/MyCSharp.HttpUserAgentParser.Benchmarks/MyCSharp.HttpUserAgentParser.Benchmarks.csproj +++ b/perf/MyCSharp.HttpUserAgentParser.Benchmarks/MyCSharp.HttpUserAgentParser.Benchmarks.csproj @@ -10,6 +10,10 @@ $(DefineConstants);OS_WIN + + $(NoWarn);CS8002 + + diff --git a/src/MyCSharp.HttpUserAgentParser.MemoryCache/HttpUserAgentParserMemoryCachedProvider.cs b/src/MyCSharp.HttpUserAgentParser.MemoryCache/HttpUserAgentParserMemoryCachedProvider.cs index e2f221a..a8f8f1d 100644 --- a/src/MyCSharp.HttpUserAgentParser.MemoryCache/HttpUserAgentParserMemoryCachedProvider.cs +++ b/src/MyCSharp.HttpUserAgentParser.MemoryCache/HttpUserAgentParserMemoryCachedProvider.cs @@ -12,6 +12,11 @@ public class HttpUserAgentParserMemoryCachedProvider : IHttpUserAgentParserProvi private readonly IMemoryCache _memoryCache; private readonly HttpUserAgentParserMemoryCachedProviderOptions _options; + /// + /// Creates a new instance of . + /// + /// The memory cache instance to use + /// The options used to set expiration and size limit public HttpUserAgentParserMemoryCachedProvider(IMemoryCache memoryCache, HttpUserAgentParserMemoryCachedProviderOptions options) { _memoryCache = memoryCache; diff --git a/src/MyCSharp.HttpUserAgentParser.MemoryCache/MyCSharp.HttpUserAgentParser.MemoryCache.csproj b/src/MyCSharp.HttpUserAgentParser.MemoryCache/MyCSharp.HttpUserAgentParser.MemoryCache.csproj index dd632d6..1c3a6c9 100644 --- a/src/MyCSharp.HttpUserAgentParser.MemoryCache/MyCSharp.HttpUserAgentParser.MemoryCache.csproj +++ b/src/MyCSharp.HttpUserAgentParser.MemoryCache/MyCSharp.HttpUserAgentParser.MemoryCache.csproj @@ -3,10 +3,14 @@ HTTP User Agent Parser Extensions for IMemoryCache HTTP User Agent Parser Extensions for IMemoryCache - netstandard2.1 + netstandard2.0;netstandard2.1 true + + + + diff --git a/src/MyCSharp.HttpUserAgentParser/MyCSharp.HttpUserAgentParser.csproj b/src/MyCSharp.HttpUserAgentParser/MyCSharp.HttpUserAgentParser.csproj index b07b831..86f0545 100644 --- a/src/MyCSharp.HttpUserAgentParser/MyCSharp.HttpUserAgentParser.csproj +++ b/src/MyCSharp.HttpUserAgentParser/MyCSharp.HttpUserAgentParser.csproj @@ -3,10 +3,14 @@ HTTP User Agent Parser Parses user agents for Browser, Platform and Bots. - netstandard2.1 + netstandard2.0;netstandard2.1 true + + + + diff --git a/src/NetStandard2.0-Shim.cs b/src/NetStandard2.0-Shim.cs new file mode 100644 index 0000000..74653c4 --- /dev/null +++ b/src/NetStandard2.0-Shim.cs @@ -0,0 +1,30 @@ +// Copyright © myCSharp 2020-2021, all rights reserved + +namespace System.Diagnostics.CodeAnalysis +{ + [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] + internal sealed class NotNullWhenAttribute : Attribute + { + public NotNullWhenAttribute(bool returnValue) => this.ReturnValue = returnValue; + + public bool ReturnValue { get; } + } +} + +namespace MyCSharp.HttpUserAgentParser +{ + using System; + using System.Collections.Generic; + + internal static class Extensions + { + public static void Deconstruct(this KeyValuePair kvp, out TKey key, out TValue value) + { + key = kvp.Key; + value = kvp.Value; + } + + public static bool Contains(this string instance, string value, StringComparison comparison) + => instance.IndexOf(value, comparison) >= 0; + } +}