Skip to content

Commit b743d8a

Browse files
Merge pull request #13 from thomasgalliker/update-targetframeworks-net8
Update target framework to .NET 8 + .NET Framework 4.8
2 parents 500953d + eb78b7a commit b743d8a

File tree

9 files changed

+91
-75
lines changed

9 files changed

+91
-75
lines changed

.editorconfig

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
####################################################################
2-
# Editor Configuration (Updated 2022-01-07)
2+
# Editor Configuration (Updated 2023-07-26)
33
#
4-
# (c)2021 superdev GmbH
4+
# (c)2023 superdev GmbH
55
####################################################################
66

77
root = true
88

9+
[*.csproj]
10+
indent_style = space
11+
indent_size = 2
12+
tab_width = 2
13+
914
[*.cs]
15+
indent_style = space
16+
indent_size = 4
17+
tab_width = 4
18+
end_of_line = crlf
19+
trim_trailing_whitespace = true
20+
insert_final_newline = false
21+
max_line_length = 140
22+
1023
csharp_indent_block_contents = true
1124
csharp_indent_braces = false
1225
csharp_indent_case_contents = true
@@ -23,16 +36,16 @@ csharp_new_line_between_query_expression_clauses = true
2336

2437
csharp_prefer_braces = true:error
2538
csharp_prefer_simple_default_expression = true:error
26-
csharp_prefer_simple_using_statement = false
39+
csharp_prefer_simple_using_statement = false:silent
2740

41+
csharp_using_directive_placement = outside_namespace:silent
2842
csharp_preserve_single_line_blocks = true
29-
csharp_preserve_single_line_statements = false
43+
csharp_preserve_single_line_statements = true
3044

3145
csharp_space_after_cast = false
3246
csharp_space_after_colon_in_inheritance_clause = true
3347
csharp_space_after_comma = true
3448
csharp_space_after_dot = false
35-
3649
csharp_space_after_keywords_in_control_flow_statements = true
3750
csharp_space_after_semicolon_in_for_statement = true
3851
csharp_space_around_binary_operators = before_and_after
@@ -57,7 +70,7 @@ csharp_style_expression_bodied_accessors = true:none
5770
csharp_style_expression_bodied_constructors = false:none
5871
csharp_style_expression_bodied_indexers = true:none
5972
csharp_style_expression_bodied_lambdas = true:none
60-
csharp_style_expression_bodied_local_functions = false
73+
csharp_style_expression_bodied_local_functions = false:silent
6174
csharp_style_expression_bodied_methods = false:none
6275
csharp_style_expression_bodied_operators = false:none
6376
csharp_style_expression_bodied_properties = true:silent
@@ -72,9 +85,13 @@ csharp_style_var_for_built_in_types = true:suggestion
7285
csharp_style_var_when_type_is_apparent = true:error
7386
csharp_style_implicit_object_creation_when_type_is_apparent = false
7487
csharp_style_prefer_switch_expression = false
88+
csharp_style_namespace_declarations = block_scoped:silent
89+
csharp_style_prefer_method_group_conversion = true:silent
90+
csharp_style_prefer_top_level_statements = true:silent
91+
csharp_style_prefer_null_check_over_type_check = true:suggestion
7592

7693
dotnet_sort_system_directives_first = true
77-
dotnet_style_coalesce_expression = true:error
94+
dotnet_style_coalesce_expression = true:suggestion
7895
dotnet_style_collection_initializer = true:error
7996
dotnet_style_explicit_tuple_names = true:error
8097
dotnet_style_null_propagation = true:error
@@ -86,12 +103,20 @@ dotnet_style_qualification_for_event = true:error
86103
dotnet_style_qualification_for_field = true:error
87104
dotnet_style_qualification_for_method = true:error
88105
dotnet_style_qualification_for_property = true:error
89-
90-
end_of_line = crlf
91-
indent_size = 4
92-
indent_style = space
93-
insert_final_newline = false
94-
tab_width = 4
106+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
107+
dotnet_style_prefer_auto_properties = true:silent
108+
dotnet_style_prefer_simplified_boolean_expressions = false:suggestion
109+
dotnet_style_prefer_conditional_expression_over_assignment = false:suggestion
110+
dotnet_style_prefer_conditional_expression_over_return = false:suggestion
111+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
112+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
113+
dotnet_style_prefer_compound_assignment = true:suggestion
114+
dotnet_style_prefer_simplified_interpolation = true:suggestion
115+
dotnet_style_namespace_match_folder = true:suggestion
116+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
117+
csharp_style_unused_value_expression_statement_preference = discard_variable:none
118+
csharp_style_unused_value_assignment_preference = discard_variable:none
119+
csharp_style_prefer_method_group_conversion = true
95120

96121
dotnet_naming_symbols.private_field_symbol.applicable_kinds = field
97122
dotnet_naming_symbols.private_field_symbol.applicable_accessibilities = private
@@ -111,13 +136,13 @@ dotnet_naming_symbols.parameter_symbol.applicable_kinds = parameter
111136
dotnet_naming_style.parameter_style.capitalization = camel_case
112137
dotnet_naming_rule.parameters_are_camel_case.severity = error
113138
dotnet_naming_rule.parameters_are_camel_case.symbols = parameter_symbol
114-
dotnet_naming_rule.parameters_are_camel_case.style = parameter_style
139+
dotnet_naming_rule.parameters_are_camel_case.style = private_field_style
115140

116141
dotnet_naming_symbols.non_interface_type_symbol.applicable_kinds = class,struct,enum,delegate
117142
dotnet_naming_style.non_interface_type_style.capitalization = pascal_case
118143
dotnet_naming_rule.non_interface_types_are_pascal_case.severity = error
119144
dotnet_naming_rule.non_interface_types_are_pascal_case.symbols = non_interface_type_symbol
120-
dotnet_naming_rule.non_interface_types_are_pascal_case.style = non_interface_type_style
145+
dotnet_naming_rule.non_interface_types_are_pascal_case.style = non_private_field_style
121146

122147
dotnet_naming_symbols.interface_type_symbol.applicable_kinds = interface
123148
dotnet_naming_style.interface_type_style.capitalization = pascal_case
@@ -130,11 +155,11 @@ dotnet_naming_symbols.member_symbol.applicable_kinds = method,property,event
130155
dotnet_naming_style.member_style.capitalization = pascal_case
131156
dotnet_naming_rule.members_are_pascal_case.severity = error
132157
dotnet_naming_rule.members_are_pascal_case.symbols = member_symbol
133-
dotnet_naming_rule.members_are_pascal_case.style = member_style
158+
dotnet_naming_rule.members_are_pascal_case.style = non_private_field_style
134159

135160
dotnet_naming_rule.static_fields_should_be_pascal_case.severity = suggestion
136161
dotnet_naming_rule.static_fields_should_be_pascal_case.symbols = static_fields
137-
dotnet_naming_rule.static_fields_should_be_pascal_case.style = static_field_style
162+
dotnet_naming_rule.static_fields_should_be_pascal_case.style = non_private_field_style
138163
dotnet_naming_symbols.static_fields.applicable_kinds = field
139164
dotnet_naming_symbols.static_fields.applicable_accessibilities = *
140165
dotnet_naming_symbols.static_fields.required_modifiers = static
@@ -144,4 +169,4 @@ dotnet_naming_style.static_field_style.capitalization = pascal_case
144169
dotnet_diagnostic.CS4014.severity = error
145170

146171
# IDE0051: Remove unused private members
147-
dotnet_diagnostic.IDE0051.severity = warning
172+
dotnet_diagnostic.IDE0051.severity = warning

HttpClient.Caching/HttpClient.Caching.csproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
<VersionPrefix>1.0.0</VersionPrefix>
77
<Version>1.0.0</Version>
88
<Authors>Thomas Galliker</Authors>
9-
<TargetFrameworks>net462;netstandard1.2;netstandard2.0;netstandard2.1</TargetFrameworks>
9+
<TargetFrameworks>net48;netstandard1.2;netstandard2.0;netstandard2.1;net6.0;net7.0;net8.0</TargetFrameworks>
1010
<AssemblyName>HttpClient.Caching</AssemblyName>
1111
<PackageId>HttpClient.Caching</PackageId>
1212
<PackageTags>httpclient.caching;httpclient;caching;cache;inmemory</PackageTags>
1313
<PackageIconUrl>https://raw.githubusercontent.com/thomasgalliker/HttpClient.Caching/develop/logo.png</PackageIconUrl>
1414
<PackageProjectUrl>https://github.com/thomasgalliker/HttpClient.Caching</PackageProjectUrl>
1515
<RepositoryType>git</RepositoryType>
1616
<RepositoryUrl>https://github.com/thomasgalliker/HttpClient.Caching</RepositoryUrl>
17-
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
1817
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netstandard1.2' ">$(PackageTargetFallback);netcoreapp1.0</PackageTargetFallback>
1918
<NetStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netstandard1.2' ">1.6.1</NetStandardImplicitPackageVersion>
2019
<SignAssembly>True</SignAssembly>
@@ -32,15 +31,15 @@
3231
1.0.0
3332
- Initial release
3433
</PackageReleaseNotes>
35-
<Copyright>Copyright 2022</Copyright>
34+
<Copyright>Copyright $([System.DateTime]::Now.ToString(`yyyy`)) © Thomas Galliker</Copyright>
3635
<PackageReadmeFile>README.md</PackageReadmeFile>
3736
</PropertyGroup>
3837

3938
<ItemGroup>
4039
<PackageReference Include="Newtonsoft.Json" Version="[11.0.2,)" />
4140
</ItemGroup>
4241

43-
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
42+
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' ">
4443
<Reference Include="System.Net.Http" />
4544
</ItemGroup>
4645

HttpClient.Caching/InMemory/IMemoryCache.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace Microsoft.Extensions.Caching.InMemory
88
/// </summary>
99
public interface IMemoryCache : IDisposable
1010
{
11+
int Count { get; }
12+
1113
/// <summary>Gets the item associated with this key if present.</summary>
1214
/// <param name="key">An object identifying the requested entry.</param>
1315
/// <param name="value">The located value or null.</param>
@@ -23,6 +25,8 @@ public interface IMemoryCache : IDisposable
2325
/// <param name="key">An object identifying the entry.</param>
2426
void Remove(object key);
2527

28+
void Compact(double percentage);
29+
2630
void Clear();
2731
}
2832
}

HttpClient.Caching/InMemory/MemoryCache.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ namespace Microsoft.Extensions.Caching.InMemory
1212
public class MemoryCache : IMemoryCache
1313
{
1414
private readonly ConcurrentDictionary<object, CacheEntry> entries;
15-
private bool disposed;
1615
private readonly Action<CacheEntry> setEntry;
1716
private readonly Action<CacheEntry> entryExpirationNotification;
1817
private readonly ISystemClock clock;
1918
private readonly TimeSpan expirationScanFrequency;
19+
2020
private DateTimeOffset lastExpirationScan;
21+
private bool disposed;
2122

2223
public int Count => this.entries.Count;
2324

@@ -110,10 +111,7 @@ private void SetEntry(CacheEntry entry)
110111
entry.InvokeEvictionCallbacks();
111112
}
112113

113-
if (cacheEntry != null)
114-
{
115-
cacheEntry.InvokeEvictionCallbacks();
116-
}
114+
cacheEntry?.InvokeEvictionCallbacks();
117115
}
118116
else
119117
{

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ HttpClient allows to inject a custom http handler. In the follwing example, we i
5959
```C#
6060
static void Main(string[] args)
6161
{
62-
const string url = "http://worldclockapi.com/api/json/utc/now";
62+
const string url = "http://worldtimeapi.org/api/timezone/Europe/Zurich";
6363

6464
var httpClientHandler = new HttpClientHandler();
6565
var cacheExpirationPerHttpResponseCode = CacheExpirationProvider.CreateSimple(TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(5));
@@ -96,11 +96,11 @@ static void Main(string[] args)
9696

9797
Console output:
9898
```
99-
Attempt 1: HTTP GET http://worldclockapi.com/api/json/utc/now... completed in 625ms
100-
Attempt 2: HTTP GET http://worldclockapi.com/api/json/utc/now... completed in 48ms
101-
Attempt 3: HTTP GET http://worldclockapi.com/api/json/utc/now... completed in 1ms
102-
Attempt 4: HTTP GET http://worldclockapi.com/api/json/utc/now... completed in 1ms
103-
Attempt 5: HTTP GET http://worldclockapi.com/api/json/utc/now... completed in 1ms
99+
Attempt 1: HTTP GET http://worldtimeapi.org/api/timezone/Europe/Zurich... completed in 625ms
100+
Attempt 2: HTTP GET http://worldtimeapi.org/api/timezone/Europe/Zurich... completed in 48ms
101+
Attempt 3: HTTP GET http://worldtimeapi.org/api/timezone/Europe/Zurich... completed in 1ms
102+
Attempt 4: HTTP GET http://worldtimeapi.org/api/timezone/Europe/Zurich... completed in 1ms
103+
Attempt 5: HTTP GET http://worldtimeapi.org/api/timezone/Europe/Zurich... completed in 1ms
104104
105105
TotalRequests: 5
106106
-> CacheHit: 4
@@ -118,7 +118,7 @@ with InMemoryCacheHandler.
118118
```C#
119119
static void Main(string[] args)
120120
{
121-
const string url = "http://worldclockapi.com/api/json/utc/now";
121+
const string url = "http://worldtimeapi.org/api/timezone/Europe/Zurich";
122122

123123
var httpClientHandler = new HttpClientHandler();
124124
var cacheExpirationPerHttpResponseCode = CacheExpirationProvider.CreateSimple(TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(5));

Samples/ConsoleAppSample/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ internal class Program
1111
{
1212
private static void Main(string[] args)
1313
{
14-
const string url = "http://worldclockapi.com/api/json/utc/now";
14+
const string url = "http://worldtimeapi.org/api/timezone/Europe/Zurich";
1515

1616
// HttpClient uses an HttpClientHandler nested into InMemoryCacheHandler in order to handle http get response caching
1717
var httpClientHandler = new HttpClientHandler();

Tests/HttpClient.Caching.Tests/Extensions/StringExtensions.cs

Lines changed: 0 additions & 22 deletions
This file was deleted.

Tests/HttpClient.Caching.Tests/HttpClient.Caching.Tests.csproj

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net462;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
4+
<TargetFrameworks>net48;net8.0</TargetFrameworks>
55
<AssemblyName>HttpClient.Caching.Tests</AssemblyName>
66
<PackageId>HttpClient.Caching.Tests</PackageId>
7-
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
87
<IncludeBuildOutput>false</IncludeBuildOutput>
98
<RootNamespace>HttpClient.Caching.Tests</RootNamespace>
109
<NeutralLanguage>en</NeutralLanguage>
1110
</PropertyGroup>
1211

1312
<ItemGroup>
14-
<PackageReference Include="coverlet.msbuild" Version="3.1.2">
13+
<PackageReference Include="coverlet.msbuild" Version="6.0.1">
1514
<PrivateAssets>all</PrivateAssets>
1615
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1716
</PackageReference>
18-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
19-
<PackageReference Include="ncrontab" Version="3.3.1" />
20-
<PackageReference Include="ObjectDumper.NET" Version="3.3.20" />
21-
<PackageReference Include="xunit" Version="2.4.1" />
22-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
17+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
18+
<PackageReference Include="ObjectDumper.NET" Version="4.1.15" />
19+
<PackageReference Include="xunit" Version="2.7.0" />
20+
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
2321
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2422
<PrivateAssets>all</PrivateAssets>
2523
</PackageReference>
26-
<PackageReference Include="Moq.AutoMock" Version="3.3.0" />
27-
<PackageReference Include="FluentAssertions" Version="6.6.0" />
24+
<PackageReference Include="Moq.AutoMock" Version="3.5.0" />
25+
<PackageReference Include="FluentAssertions" Version="6.12.0" />
2826
</ItemGroup>
2927

30-
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
28+
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' ">
3129
<Reference Include="System.Net.Http" />
3230
</ItemGroup>
3331

0 commit comments

Comments
 (0)