forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't call into unsupported APIs on build targets which don't support…
… quic (dotnet#49261) * Don't call into unsupported APIs on build targets which don't support quic The code could be extracted to HttpConnectionPool.quick.cs but not sure it's worth the split as that would move the majority of the code. Fixes dotnet#49201 Fixes dotnet#49187 * if-def less version * Quic IsSupported working and not throwing for AnyOS. * Fix for running the newly added UnitTest. * Add missing unsupported targets * Reverted Quic changes. * Unsupported to Supported * Guarded unsupported calls with OperationgSystem.Is...() * Addressed comments. * Analyzer fixed, macOS fixed. * Trimming test. * Removed test. * Guard more unsupported platform calls * Some more analyzer attributes. * Fix for Android, which returns true for IsLinux(). * Skip failing trimming test on wasm * Removed additional UnsupportedOS attributes, referenced issue. Co-authored-by: Marie Píchová <[email protected]>
- Loading branch information
1 parent
7c5a92f
commit d4818a3
Showing
14 changed files
with
192 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/libraries/System.Net.Http/tests/TrimmingTests/HttpClientTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.IO; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
|
||
class Program | ||
{ | ||
static async Task<int> Main(string[] args) | ||
{ | ||
using var client = new HttpClient(); | ||
using var response = await client.GetAsync("https://www.microsoft.com"); | ||
var result = await response.Content.ReadAsStringAsync(); | ||
Console.WriteLine(result); | ||
|
||
const string quicDll = "System.Net.Quic.dll"; | ||
var quicDllExists = File.Exists(Path.Combine(AppContext.BaseDirectory, quicDll)); | ||
|
||
// TODO: Replace with Platform-Guard Assertion Annotations once https://github.com/dotnet/runtime/issues/44922 is finished | ||
if ((OperatingSystem.IsLinux() && !OperatingSystem.IsAndroid()) || OperatingSystem.IsWindows() || OperatingSystem.IsMacOS()) | ||
{ | ||
Console.WriteLine($"Expected {quicDll} is {(quicDllExists ? "present - OK" : "missing - BAD")}."); | ||
return quicDllExists ? 100 : -1; | ||
} | ||
else | ||
{ | ||
Console.WriteLine($"Unexpected {quicDll} is {(quicDllExists ? "present - BAD" : "missing - OK")}."); | ||
return quicDllExists ? -1 : 100; | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/libraries/System.Net.Http/tests/TrimmingTests/System.Net.Http.TrimmingTests.proj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<Project DefaultTargets="Build"> | ||
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" /> | ||
|
||
<ItemGroup> | ||
<TestConsoleAppSourceFiles Include="HttpClientTest.cs"> | ||
<SkipOnTestRuntimes>browser-wasm</SkipOnTestRuntimes> | ||
</TestConsoleAppSourceFiles> | ||
</ItemGroup> | ||
|
||
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" /> | ||
</Project> |
Oops, something went wrong.