Skip to content

Commit 263b266

Browse files
committed
Fix/skip/comment broken tests
1 parent 9663a20 commit 263b266

File tree

15 files changed

+112
-10
lines changed

15 files changed

+112
-10
lines changed

shared-test.props

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
<NoWarn>$(NoWarn);S2094;S3717;SA1602;CA1062;CA1707;NU5104</NoWarn>
55
</PropertyGroup>
66

7+
<!-- .NET 10 Preview -->
8+
<PropertyGroup>
9+
<!-- ASPDEPR004: 'WebHostBuilder' is deprecated in favor of HostBuilder and WebApplicationBuilder. -->
10+
<!-- ASPDEPR008: 'IWebHost' is obsolete: Use IHost instead. -->
11+
<NoWarn>$(NoWarn);ASPDEPR004;ASPDEPR008</NoWarn>
12+
</PropertyGroup>
13+
714
<PropertyGroup>
815
<!-- https://github.com/xunit/xunit/issues/3238#issuecomment-2770720936 -->
916
<TestTfmsInParallel>false</TestTfmsInParallel>

shared.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
<GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute>
1313
</PropertyGroup>
1414

15-
<PropertyGroup Condition="'$(TargetFramework)' == 'net10.0'">
15+
<!-- .NET 10 Preview -->
16+
<PropertyGroup>
1617
<LangVersion>preview</LangVersion>
1718
<!-- CA1873: Evaluation of this argument may be expensive and unnecessary if logging is disabled -->
1819
<NoWarn>$(NoWarn);CA1873</NoWarn>

src/Common/test/TestResources/HostWrapper.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
using Microsoft.AspNetCore.TestHost;
88
using Microsoft.Extensions.Hosting;
99

10+
#pragma warning disable ASPDEPR008 // 'IWebHost' is obsolete: Use IHost instead.
11+
1012
namespace Steeltoe.Common.TestResources;
1113

1214
public sealed class HostWrapper : IAsyncDisposable

src/Common/test/TestResources/TestWebHostBuilderFactory.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
using Microsoft.Extensions.DependencyInjection;
1010
using Microsoft.Extensions.DependencyInjection.Extensions;
1111

12+
#pragma warning disable ASPDEPR004 // 'WebHostBuilder' is deprecated in favor of HostBuilder and WebApplicationBuilder.
13+
1214
namespace Steeltoe.Common.TestResources;
1315

1416
public static class TestWebHostBuilderFactory

src/Configuration/src/Abstractions/CompositeConfigurationProvider.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,14 @@ public void Set(string key, string? value)
9797

9898
LogSet(GetType().Name, key, value);
9999

100+
#pragma warning disable IDE0031 // Use null propagation
101+
// ReSharper disable once UseNullPropagation
102+
// Justification: Triggers warning in Sonar, which doesn't support .NET 10 yet.
100103
if (ConfigurationRoot != null)
101104
{
102105
ConfigurationRoot[key] = value;
103106
}
107+
#pragma warning restore IDE0031 // Use null propagation
104108
}
105109

106110
public void Dispose()

src/Configuration/src/SpringBoot/SpringBootEnvironmentVariableProvider.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace Steeltoe.Configuration.SpringBoot;
1313
internal sealed class SpringBootEnvironmentVariableProvider : JsonStreamConfigurationProvider
1414
{
1515
private const string SpringApplicationJson = "SPRING_APPLICATION_JSON";
16+
private static readonly bool IsAtLeastDotNet10 = typeof(JsonStreamConfigurationProvider).Assembly.GetName().Version?.Major >= 10;
1617
private readonly string? _springApplicationJson;
1718
private bool _loaded;
1819

@@ -61,7 +62,8 @@ public override void Load()
6162
{
6263
string? value = Data[key];
6364

64-
if (value != null)
65+
// Breaking change in JsonConfigurationFileParser at https://github.com/dotnet/runtime/pull/116677.
66+
if (IsAtLeastDotNet10 || value != null)
6567
{
6668
string newKey = key.Contains('.') ? key.Replace('.', ':') : key;
6769
data[newKey] = value;

src/Configuration/test/CloudFoundry.Test/CloudfoundryConfigurationProviderTest.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@
1212
using Microsoft.Extensions.DependencyInjection;
1313
using Microsoft.Extensions.Options;
1414
using Steeltoe.Common.TestResources;
15-
using IPNetwork = Microsoft.AspNetCore.HttpOverrides.IPNetwork;
15+
using IPNetwork =
16+
#if NET10_0_OR_GREATER
17+
System.Net.IPNetwork;
18+
19+
#else
20+
Microsoft.AspNetCore.HttpOverrides.IPNetwork;
21+
22+
#endif
1623

1724
namespace Steeltoe.Configuration.CloudFoundry.Test;
1825

@@ -244,14 +251,22 @@ public async Task ForwardedHeadersOptions_unrestricted_when_running_on_CloudFoun
244251
{
245252
options.ForwardedHeaders.Should().HaveFlag(ForwardedHeaders.XForwardedFor);
246253
options.ForwardedHeaders.Should().HaveFlag(ForwardedHeaders.XForwardedProto);
254+
#if NET10_0_OR_GREATER
255+
options.KnownIPNetworks.Should().BeEmpty();
256+
#else
247257
options.KnownNetworks.Should().BeEmpty();
258+
#endif
248259
options.KnownProxies.Should().BeEmpty();
249260
}
250261
else
251262
{
252263
options.ForwardedHeaders.Should().NotHaveFlag(ForwardedHeaders.XForwardedFor);
253264
options.ForwardedHeaders.Should().NotHaveFlag(ForwardedHeaders.XForwardedProto);
265+
#if NET10_0_OR_GREATER
266+
options.KnownIPNetworks.Should().ContainSingle().Which.Should().BeEquivalentTo(IPNetwork.Parse("127.0.0.1/8"));
267+
#else
254268
options.KnownNetworks.Should().ContainSingle().Which.Should().BeEquivalentTo(IPNetwork.Parse("127.0.0.1/8"));
269+
#endif
255270
options.KnownProxies.Should().ContainSingle().Which.Should().Be(IPAddress.Parse("::1"));
256271
}
257272
}

src/Configuration/test/SpringBoot.Test/SpringBootEnvironmentVariableProviderTest.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,32 @@ public void TryGet_Tree()
6363
value.Should().Be("q");
6464

6565
provider.TryGet("r", out value).Should().BeTrue();
66+
#if NET10_0_OR_GREATER
67+
value.Should().BeNull();
68+
#else
6669
value.Should().BeEmpty();
70+
#endif
6771

6872
provider.TryGet("s:t", out value).Should().BeTrue();
73+
#if NET10_0_OR_GREATER
74+
value.Should().BeNull();
75+
#else
6976
value.Should().BeEmpty();
77+
#endif
7078

79+
#if NET10_0_OR_GREATER
80+
provider.TryGet("u", out _).Should().BeTrue();
81+
value.Should().BeNull();
82+
#else
7183
provider.TryGet("u", out _).Should().BeFalse();
84+
#endif
7285

86+
#if NET10_0_OR_GREATER
87+
provider.TryGet("v:w", out _).Should().BeTrue();
88+
value.Should().BeNull();
89+
#else
7390
provider.TryGet("v:w", out _).Should().BeFalse();
91+
#endif
7492
}
7593

7694
[Fact]
@@ -113,14 +131,32 @@ public void TryGet_Array()
113131
value.Should().Be("q");
114132

115133
provider.TryGet("a:b:c:2:r", out value).Should().BeTrue();
134+
#if NET10_0_OR_GREATER
135+
value.Should().BeNull();
136+
#else
116137
value.Should().BeEmpty();
138+
#endif
117139

118140
provider.TryGet("a:b:c:2:s:t", out value).Should().BeTrue();
141+
#if NET10_0_OR_GREATER
142+
value.Should().BeNull();
143+
#else
119144
value.Should().BeEmpty();
145+
#endif
120146

147+
#if NET10_0_OR_GREATER
148+
provider.TryGet("a:b:c:2:u", out _).Should().BeTrue();
149+
value.Should().BeNull();
150+
#else
121151
provider.TryGet("a:b:c:2:u", out _).Should().BeFalse();
152+
#endif
122153

154+
#if NET10_0_OR_GREATER
155+
provider.TryGet("a:b:c:2:v:w", out _).Should().BeTrue();
156+
value.Should().BeNull();
157+
#else
123158
provider.TryGet("a:b:c:2:v:w", out _).Should().BeFalse();
159+
#endif
124160
}
125161

126162
[Fact]

src/Connectors/src/Connectors/DynamicTypeAccess/ConnectorFactoryShim.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private static TypeAccessor MakeGenericTypeAccessor(Type connectionType)
6060

6161
public ConnectorShim<TOptions> Get(string serviceBindingName)
6262
{
63-
object instance = InstanceAccessor.InvokeMethodOverload(nameof(ConnectorFactory<TOptions, object>.Get), true, [typeof(string)], serviceBindingName)!;
63+
object instance = InstanceAccessor.InvokeMethodOverload(nameof(ConnectorFactory<,>.Get), true, [typeof(string)], serviceBindingName)!;
6464

6565
return new ConnectorShim<TOptions>(_connectionType, instance);
6666
}

src/Connectors/src/Connectors/DynamicTypeAccess/ConnectorShim.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private static InstanceAccessor CreateAccessor(Type connectionType, object insta
2525

2626
public object GetConnection()
2727
{
28-
return InstanceAccessor.InvokeMethod(nameof(Connector<TOptions, object>.GetConnection), true)!;
28+
return InstanceAccessor.InvokeMethod(nameof(Connector<,>.GetConnection), true)!;
2929
}
3030

3131
public void Dispose()

0 commit comments

Comments
 (0)