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

Handle unsupported browser warnings #43363

Merged
31 commits merged into from
Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4d13214
Handle browser warnings
buyaa-n Oct 13, 2020
c94abbf
Merge branch 'master' of https://github.com/dotnet/runtime into add_b…
buyaa-n Oct 16, 2020
148bd59
Apply feedback, revert updates handled with different PRs
buyaa-n Oct 16, 2020
36984e3
Merge branch 'master' of https://github.com/dotnet/runtime into add_b…
buyaa-n Oct 16, 2020
256f290
Add misssing diagnotic id
buyaa-n Oct 20, 2020
99fb042
Merge branch 'master' of https://github.com/dotnet/runtime into add_b…
buyaa-n Oct 20, 2020
351e839
Merge branch 'master' of https://github.com/dotnet/runtime into add_b…
buyaa-n Oct 21, 2020
6267bec
Address multitargeted warnings
buyaa-n Oct 21, 2020
422be5b
Apply feedback
buyaa-n Oct 23, 2020
a523788
Small type/comment updates
buyaa-n Oct 23, 2020
3892c1c
Apply more feedback
buyaa-n Oct 23, 2020
ca6e0fa
Use project settings instead adding Directory.Build.props
buyaa-n Oct 24, 2020
8007c09
Annotate APIs injecting unsupported type through DI
buyaa-n Oct 29, 2020
443aa1f
Fix window support related warnings found with generic type parameter
buyaa-n Nov 2, 2020
f86de1f
Fix another browser warning found with generic type parameter bug fix
buyaa-n Nov 2, 2020
cb052c3
All public APIs of ConsoleLoggerExtensions are unsupported, so markin…
buyaa-n Nov 9, 2020
c70674c
Try handle mono warnings
buyaa-n Nov 10, 2020
2c25aaa
Merge conflicts
buyaa-n Nov 10, 2020
38320a5
Revert mono related changes, it was mistake
buyaa-n Nov 11, 2020
636e5d9
Try handle browser warninga in mono
buyaa-n Nov 11, 2020
7fef65c
Apply feedback and fix new warnings caused from corelib changes
buyaa-n Nov 12, 2020
e5c1673
Review update
buyaa-n Nov 12, 2020
5c9254a
Apply feedback
buyaa-n Nov 12, 2020
f74e50f
Move platform specific section from HttpTelemetry
buyaa-n Nov 13, 2020
ed2b844
Revering unwanted changes
buyaa-n Nov 13, 2020
8d7d39d
Remove redundant attributes
buyaa-n Nov 13, 2020
9a043fe
Exclude cross platform build with browser target
buyaa-n Nov 17, 2020
f6d9618
small updates
buyaa-n Nov 17, 2020
3ba103c
Annotate entire type DiagnosticCounter unsupported
buyaa-n Nov 18, 2020
a804980
Apply feedback, improve suppression comments
buyaa-n Nov 20, 2020
22bb8a2
Remove Unsupported browser from TypeDescriptor.CreateInstance, TypeDe…
buyaa-n Nov 25, 2020
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
4 changes: 4 additions & 0 deletions eng/versioning.targets
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
</AssemblyAttribute>
</ItemGroup>

<ItemGroup Condition="('$(TargetsBrowser)' == 'true' or '$(TargetsAnyOS)' == 'true') and '$(IsTestProject)' != 'true'">
<SupportedPlatform Include="browser"/>
</ItemGroup>

<ItemGroup>
<_unsupportedOSPlatforms Include="$(UnsupportedOSPlatforms)" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ private bool SetColor(ConsoleColor? background, ConsoleColor? foreground)
return SetForegroundColor(foreground) || backgroundChanged;
}

#pragma warning disable CA1416 // Validate platform compatibility, not sure if this assembly is used for browser, suppressing for now
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
private bool SetBackgroundColor(ConsoleColor? background)
{
if (background.HasValue)
Expand All @@ -52,6 +53,7 @@ private void ResetColor()
{
System.Console.ResetColor();
}
#pragma warning restore CA1416

private void WriteToConsole(string message, int startIndex, int length, ConsoleColor? background, ConsoleColor? foreground)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public ConsoleLoggerProcessor()
IsBackground = true,
Name = "Console logger queue processing thread"
};
#pragma warning disable CA1416 // Validate platform compatibility, not sure if this assembly is used for browser, suppressing for now
_outputThread.Start();
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
#pragma warning restore CA1416
}

public virtual void EnqueueMessage(LogMessageEntry message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,7 @@ protected PropertyDescriptor(string name, System.Attribute[] attrs) : base (defa
public virtual bool SupportsChangeEvents { get { throw null; } }
public virtual void AddValueChanged(object component, System.EventHandler handler) { }
public abstract bool CanResetValue(object component);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
protected object CreateInstance(System.Type type) { throw null; }
public override bool Equals(object obj) { throw null; }
protected override void FillAttributes(System.Collections.IList attributeList) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections;
using System.Runtime.Versioning;

namespace System.ComponentModel
{
Expand Down Expand Up @@ -31,6 +32,7 @@ internal DelegatingTypeDescriptionProvider(Type type)
/// data type. If the method is not interested in providing a substitute
/// instance, it should call base.
/// </summary>
[UnsupportedOSPlatform("browser")]
public override object CreateInstance(IServiceProvider provider, Type objectType, Type[] argTypes, object[] args)
{
return Provider.CreateInstance(provider, objectType, argTypes, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.Versioning;

namespace System.ComponentModel
{
Expand Down Expand Up @@ -69,7 +70,7 @@ public virtual TypeConverter Converter
if (attr.ConverterTypeName != null && attr.ConverterTypeName.Length > 0)
{
Type converterType = GetTypeFromName(attr.ConverterTypeName);
if (converterType != null && typeof(TypeConverter).IsAssignableFrom(converterType))
if (converterType != null && typeof(TypeConverter).IsAssignableFrom(converterType) && !OperatingSystem.IsBrowser())
{
_converter = (TypeConverter)CreateInstance(converterType);
}
Expand Down Expand Up @@ -183,6 +184,7 @@ public override bool Equals(object obj)
/// <summary>
/// Creates an instance of the specified type.
/// </summary>
[UnsupportedOSPlatform("browser")]
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
protected object CreateInstance(Type type)
{
Type[] typeArgs = new Type[] { typeof(Type) };
Expand Down Expand Up @@ -272,7 +274,7 @@ public virtual object GetEditor(Type editorBaseType)
if (editorBaseType == editorType)
{
Type type = GetTypeFromName(attr.EditorTypeName);
if (type != null)
if (type != null && !OperatingSystem.IsBrowser())
{
editor = CreateInstance(type);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3051,6 +3051,7 @@ internal TypeDescriptionNode(TypeDescriptionProvider provider)
/// Implements CreateInstance. This just walks the linked list
/// looking for someone who implements the call.
/// </summary>
[UnsupportedOSPlatform("browser")]
public override object CreateInstance(IServiceProvider provider, Type objectType, Type[] argTypes, object[] args)
{
if (objectType == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,10 @@ private void WriteEndHeader()
{
try
{
#pragma warning disable CA1416 // Validate platform compatibility
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
using Process process = Process.GetCurrentProcess();
s_processName = processName = process.ProcessName;
#pragma warning restore CA1416
}
catch (PlatformNotSupportedException) // Process isn't supported on Browser
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,9 @@ private bool TryWaitForElement(int producer, ref Pair<TKey, TOutput> element)
}

_mergeHelper._consumerWaiting[producer] = true;
#pragma warning disable CA1416 // Validate platform compatibility, it might not reachable on browser, suppressing for now
Monitor.Wait(bufferLock);
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
#pragma warning restore CA1416

// If the buffer is still empty, the producer is done
if (buffer.Count == 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Threading;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Runtime.Versioning;

namespace System.Linq.Parallel
{
Expand Down Expand Up @@ -84,6 +85,7 @@ internal OrderPreservingPipeliningSpoolingTask(
/// This method is responsible for enumerating results and enqueuing them to
/// the output buffer as appropriate. Each base class implements its own.
/// </summary>
[UnsupportedOSPlatform("browser")]
protected override void SpoolingWork()
{
TOutput element = default(TOutput)!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ public partial class SocketsConnectionFactory : System.Net.Connections.Connectio
{
public SocketsConnectionFactory(System.Net.Sockets.AddressFamily addressFamily, System.Net.Sockets.SocketType socketType, System.Net.Sockets.ProtocolType protocolType) { }
public SocketsConnectionFactory(System.Net.Sockets.SocketType socketType, System.Net.Sockets.ProtocolType protocolType) { }
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
public override System.Threading.Tasks.ValueTask<System.Net.Connections.Connection> ConnectAsync(System.Net.EndPoint? endPoint, System.Net.Connections.IConnectionProperties? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
protected virtual System.Net.Sockets.Socket CreateSocket(System.Net.Sockets.AddressFamily addressFamily, System.Net.Sockets.SocketType socketType, System.Net.Sockets.ProtocolType protocolType, System.Net.EndPoint? endPoint, System.Net.Connections.IConnectionProperties? options) { throw null; }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
using System.IO.Pipelines;
using System.Net.Sockets;
using System.Runtime.ExceptionServices;
using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;

namespace System.Net.Connections
{
[UnsupportedOSPlatform("browser")]
internal sealed class SocketConnection : Connection, IConnectionProperties
{
private readonly Socket _socket;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.IO.Pipelines;
using System.Net.Sockets;
using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;

Expand Down Expand Up @@ -52,6 +53,7 @@ public SocketsConnectionFactory(SocketType socketType, ProtocolType protocolType

/// <inheritdoc />
/// <exception cref="ArgumentNullException">When <paramref name="endPoint"/> is <see langword="null"/>.</exception>
[UnsupportedOSPlatform("browser")]
public override async ValueTask<Connection> ConnectAsync(
EndPoint? endPoint,
IConnectionProperties? options = null,
Expand Down Expand Up @@ -92,6 +94,7 @@ public override async ValueTask<Connection> ConnectAsync(
/// In case of TCP sockets, the default implementation of this method will create a socket with <see cref="Socket.NoDelay"/> enabled.
/// In case of IPv6 sockets <see cref="Socket.DualMode"/> is also be enabled.
/// </remarks>
[UnsupportedOSPlatform("browser")]
protected virtual Socket CreateSocket(
AddressFamily addressFamily,
SocketType socketType,
Expand Down
6 changes: 3 additions & 3 deletions src/libraries/System.Net.Http/src/System.Net.Http.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<WindowsRID>win</WindowsRID>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down Expand Up @@ -108,8 +108,6 @@
<Compile Include="System\Net\Http\Headers\WarningHeaderValue.cs" />
<Compile Include="$(CommonPath)System\IO\StreamHelpers.CopyValidation.cs"
Link="Common\System\IO\StreamHelpers.CopyValidation.cs" />
<Compile Include="$(CommonPath)System\Net\Security\SslClientAuthenticationOptionsExtensions.cs"
Link="Common\System\Net\Security\SslClientAuthenticationOptionsExtensions.cs" />
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
<Compile Include="$(CommonPath)System\IO\DelegatingStream.cs"
Link="Common\System\IO\DelegatingStream.cs" />
<Compile Include="$(CommonPath)System\IO\ReadOnlyMemoryStream.cs"
Expand Down Expand Up @@ -185,6 +183,8 @@
Link="Common\System\Net\SecurityStatusPal.cs" />
<Compile Include="$(CommonPath)System\Net\Security\SSPIHandleCache.cs"
Link="Common\System\Net\Security\SSPIHandleCache.cs" />
<Compile Include="$(CommonPath)System\Net\Security\SslClientAuthenticationOptionsExtensions.cs"
Link="Common\System\Net\Security\SslClientAuthenticationOptionsExtensions.cs" />
<Compile Include="$(CommonPath)System\Net\Security\NetEventSource.Security.cs"
Link="Common\System\Net\Security\NetEventSource.Security.cs" />
<Compile Include="$(CommonPath)System\Net\ExceptionCheck.cs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,9 @@ private async ValueTask<HttpResponseMessage> SendAsyncCore(
// Wait for the send request to complete, getting back the response.
response = async ?
await base.SendAsync(request, cts.Token).ConfigureAwait(false) :
#pragma warning disable CA1416 // Validate platform compatibility
base.Send(request, cts.Token);
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
#pragma warning restore CA1416
ThrowForNullResponse(response);

// Buffer the response content if we've been asked to.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ internal ServicePointManager() { }
public static int DefaultConnectionLimit { get { throw null; } set { } }
public static int DnsRefreshTimeout { get { throw null; } set { } }
public static bool EnableDnsRoundRobin { get { throw null; } set { } }
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
public static System.Net.Security.EncryptionPolicy EncryptionPolicy { get { throw null; } }
public static bool Expect100Continue { get { throw null; } set { } }
public static int MaxServicePointIdleTime { get { throw null; } set { } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Net.Security;
using System.Runtime.Versioning;
using System.Threading;

namespace System.Net
Expand Down Expand Up @@ -102,6 +103,7 @@ public static int DnsRefreshTimeout

public static bool CheckCertificateRevocationList { get; set; }

[UnsupportedOSPlatform("browser")]
public static EncryptionPolicy EncryptionPolicy { get; } = EncryptionPolicy.RequireEncryption;

[Obsolete(Obsoletions.WebRequestMessage, DiagnosticId = Obsoletions.WebRequestDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
Expand Down
5 changes: 4 additions & 1 deletion src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Globalization;
using System.Net.NetworkInformation;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;

namespace System.Net
Expand Down Expand Up @@ -157,7 +158,7 @@ private bool IsLocal(Uri host)
}

string hostString = host.Host;

#pragma warning disable CA1416 // Validate platform compatibility, it might need annotated as Unsupported on browser, but several public APIs will be affected, suppressing for now
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
if (IPAddress.TryParse(hostString, out IPAddress? hostAddress))
{
return IPAddress.IsLoopback(hostAddress) || IsAddressLocal(hostAddress);
Expand All @@ -172,11 +173,13 @@ private bool IsLocal(Uri host)

// If it matches the primary domain, it's local. (Whether or not the hostname matches.)
string local = "." + IPGlobalProperties.GetIPGlobalProperties().DomainName;
#pragma warning restore CA1416 // Validate platform compatibility
return
local.Length == (hostString.Length - dot) &&
string.Compare(local, 0, hostString, dot, local.Length, StringComparison.OrdinalIgnoreCase) == 0;
}

[UnsupportedOSPlatform("browser")]
private static bool IsAddressLocal(IPAddress ipAddress)
{
// Perf note: The .NET Framework caches this and then uses network change notifications to track
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Threading;
using System.Threading.Tasks;

#pragma warning disable CA1416 // Validate platform compatibility
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
namespace System.Net.WebSockets
{
internal sealed class WebSocketHandle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ private async Task<Stream> GetNonFileStreamAsync(Uri uri, ICredentials? credenti
var handler = new HttpClientHandler();
using (var client = new HttpClient(handler))
{
#pragma warning disable CA1416 // Validate platform compatibility, not sure how to handle
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
if (credentials != null)
{
handler.Credentials = credentials;
Expand All @@ -37,7 +38,7 @@ private async Task<Stream> GetNonFileStreamAsync(Uri uri, ICredentials? credenti
{
handler.Proxy = proxy;
}

#pragma warning restore CA1416 // Validate platform compatibility
using (Stream respStream = await client.GetStreamAsync(uri).ConfigureAwait(false))
{
var result = new MemoryStream();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ public CommittableTransaction(System.Transactions.TransactionOptions options) {
bool System.IAsyncResult.CompletedSynchronously { get { throw null; } }
bool System.IAsyncResult.IsCompleted { get { throw null; } }
public System.IAsyncResult BeginCommit(System.AsyncCallback? asyncCallback, object? asyncState) { throw null; }
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
public void Commit() { }
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public void EndCommit(System.IAsyncResult asyncResult) { }
}
public enum DependentCloneOption
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;
using System.Runtime.Versioning;
using System.Threading;

namespace System.Transactions
Expand Down Expand Up @@ -76,6 +77,7 @@ public IAsyncResult BeginCommit(AsyncCallback? asyncCallback, object? asyncState

// Forward the commit to the state machine to take the appropriate action.
//
[UnsupportedOSPlatform("browser")]
public void Commit()
{
TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
Expand Down Expand Up @@ -156,6 +158,7 @@ internal override void InternalDispose()
}
}

[UnsupportedOSPlatform("browser")]
public void EndCommit(IAsyncResult asyncResult)
{
TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,9 @@ private void InternalDispose()
// If we are supposed to commit on dispose, cast to CommittableTransaction and commit it.
if (null != _committableTransaction)
{
#pragma warning disable CA1416 // Validate platform compatibility, not sure if we need to add condition instead
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
_committableTransaction.Commit();
#pragma warning restore CA1416
}
else
{
Expand Down