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 28 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
9 changes: 9 additions & 0 deletions eng/versioning.targets
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@
</AssemblyAttribute>
</ItemGroup>

<PropertyGroup Condition="'$(TargetsAnyOS)' == 'true' and !$(TargetFrameworks.Contains('$(TargetFramework)-Browser'))">
<CrossPlatformAndHasNoBrowserTarget>true</CrossPlatformAndHasNoBrowserTarget>
</PropertyGroup>

<!-- Enables browser warnings for cross platform or Brwoser targeted builds -->
<ItemGroup Condition="('$(TargetsBrowser)' == 'true' or '$(CrossPlatformAndHasNoBrowserTarget)' == '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 @@ -7,6 +7,7 @@
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
Expand All @@ -23,6 +24,7 @@ namespace System.Net.WebSockets
/// a send operation while another is in progress or a receive operation while another is in progress will
/// result in an exception.
/// </remarks>
[UnsupportedOSPlatform("browser")]
internal sealed partial class ManagedWebSocket : WebSocket
{
/// <summary>Creates a <see cref="ManagedWebSocket"/> from a <see cref="Stream"/> connected to a websocket endpoint.</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Microsoft.Extensions.Logging
{
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static partial class ConsoleLoggerExtensions
{
public static Microsoft.Extensions.Logging.ILoggingBuilder AddConsole(this Microsoft.Extensions.Logging.ILoggingBuilder builder) { throw null; }
Expand Down Expand Up @@ -63,6 +64,7 @@ public ConsoleLoggerOptions() { }
[System.ObsoleteAttribute("ConsoleLoggerOptions.UseUtcTimestamp has been deprecated. Please use ConsoleFormatterOptions.UseUtcTimestamp instead.", false)]
public bool UseUtcTimestamp { get { throw null; } set { } }
}
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[Microsoft.Extensions.Logging.ProviderAliasAttribute("Console")]
public partial class ConsoleLoggerProvider : Microsoft.Extensions.Logging.ILoggerProvider, Microsoft.Extensions.Logging.ISupportExternalScope, System.IDisposable
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<IncludePlatformAttributes>true</IncludePlatformAttributes>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

using System;
using System.IO;
using System.Runtime.Versioning;

namespace Microsoft.Extensions.Logging.Console
{
[UnsupportedOSPlatform("browser")]
internal class AnsiParsingLogConsole : IConsole
{
private readonly TextWriter _textWriter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

using System;
using System.IO;
using System.Runtime.Versioning;
using Microsoft.Extensions.Logging.Abstractions;

namespace Microsoft.Extensions.Logging.Console
{
[UnsupportedOSPlatform("browser")]
internal class ConsoleLogger : ILogger
{
private readonly string _name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Versioning;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
Expand All @@ -12,6 +13,7 @@

namespace Microsoft.Extensions.Logging
{
[UnsupportedOSPlatform("browser")]
public static class ConsoleLoggerExtensions
{
/// <summary>
Expand Down Expand Up @@ -154,6 +156,7 @@ private static ILoggingBuilder AddFormatterWithName(this ILoggingBuilder builder
}
}

[UnsupportedOSPlatform("browser")]
internal class ConsoleLoggerFormatterConfigureOptions<TFormatter, TOptions> : ConfigureFromConfigurationOptions<TOptions>
where TOptions : ConsoleFormatterOptions
where TFormatter : ConsoleFormatter
Expand All @@ -164,6 +167,7 @@ public ConsoleLoggerFormatterConfigureOptions(ILoggerProviderConfiguration<Conso
}
}

[UnsupportedOSPlatform("browser")]
internal class ConsoleLoggerFormatterOptionsChangeTokenSource<TFormatter, TOptions> : ConfigurationChangeTokenSource<TOptions>
where TOptions : ConsoleFormatterOptions
where TFormatter : ConsoleFormatter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

using System;
using System.Collections.Concurrent;
using System.Runtime.Versioning;
using System.Threading;

namespace Microsoft.Extensions.Logging.Console
{
[UnsupportedOSPlatform("browser")]
internal class ConsoleLoggerProcessor : IDisposable
{
private const int _maxQueuedMessages = 1024;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Microsoft.Extensions.Options;

namespace Microsoft.Extensions.Logging.Console
{
/// <summary>
/// A provider of <see cref="ConsoleLogger"/> instances.
/// </summary>
[UnsupportedOSPlatform("browser")]
[ProviderAlias("Console")]
public class ConsoleLoggerProvider : ILoggerProvider, ISupportExternalScope
{
Expand Down
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>
<TargetFrameworks>$(NetCoreAppCurrent);netcoreapp3.0;netstandard2.0;net461</TargetFrameworks>
Expand All @@ -8,6 +8,7 @@
<DefineConstants>$(DefineConstants);NO_SUPPRESS_GC_TRANSITION</DefineConstants>
<!-- Use targeting pack references instead of granular ones in the project file. -->
<DisableImplicitAssemblyReferences>false</DisableImplicitAssemblyReferences>
<IncludePlatformAttributes>true</IncludePlatformAttributes>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace System.Collections.Concurrent
{
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public partial class BlockingCollection<T> : System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IReadOnlyCollection<T>, System.Collections.ICollection, System.Collections.IEnumerable, System.IDisposable
{
public BlockingCollection() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.Versioning;
using System.Threading;

namespace System.Collections.Concurrent
Expand All @@ -38,6 +39,7 @@ namespace System.Collections.Concurrent
/// away as an <see cref="System.Collections.Concurrent.IProducerConsumerCollection{T}"/>.
/// </remarks>
/// <typeparam name="T">Specifies the type of elements in the collection.</typeparam>
[UnsupportedOSPlatform("browser")]
[DebuggerTypeProxy(typeof(BlockingCollectionDebugView<>))]
[DebuggerDisplay("Count = {Count}, Type = {_collection}")]
public class BlockingCollection<T> : IEnumerable<T>, ICollection, IDisposable, IReadOnlyCollection<T>
Expand Down Expand Up @@ -1801,6 +1803,7 @@ public BlockingCollectionDebugView(BlockingCollection<T> collection)
}

/// <summary>Returns a snapshot of the underlying collection's elements.</summary>
[UnsupportedOSPlatform("browser")]
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public T[] Items
{
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 @@ -258,14 +258,14 @@ private void WriteEndHeader()
string? processName = s_processName;
if (processName is null)
{
try
if (OperatingSystem.IsBrowser()) // Process isn't supported on Browser
{
using Process process = Process.GetCurrentProcess();
s_processName = processName = process.ProcessName;
s_processName = processName = string.Empty;
}
catch (PlatformNotSupportedException) // Process isn't supported on Browser
else
{
s_processName = processName = string.Empty;
using Process process = Process.GetCurrentProcess();
s_processName = processName = process.ProcessName;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,31 @@ internal DiagnosticCounter() { }
public System.Diagnostics.Tracing.EventSource EventSource { get { throw null; } }
public string Name { get { throw null; } }
public void AddMetadata(string key, string? value) { }
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
eerhardt marked this conversation as resolved.
Show resolved Hide resolved
public void Dispose() { }
}
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public partial class PollingCounter : System.Diagnostics.Tracing.DiagnosticCounter
{
public PollingCounter(string name, System.Diagnostics.Tracing.EventSource eventSource, System.Func<double> metricProvider) { }
public override string ToString() { throw null; }
}
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public partial class IncrementingEventCounter : System.Diagnostics.Tracing.DiagnosticCounter
{
public IncrementingEventCounter(string name, System.Diagnostics.Tracing.EventSource eventSource) { }
public System.TimeSpan DisplayRateTimeScale { get { throw null; } set { } }
public void Increment(double increment = 1) { }
public override string ToString() { throw null; }
}
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public partial class IncrementingPollingCounter : System.Diagnostics.Tracing.DiagnosticCounter
{
public IncrementingPollingCounter(string name, System.Diagnostics.Tracing.EventSource eventSource, System.Func<double> totalValueProvider) { }
public System.TimeSpan DisplayRateTimeScale { get { throw null; } set { } }
public override string ToString() { throw null; }
}
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public partial class EventCounter : System.Diagnostics.Tracing.DiagnosticCounter
{
public EventCounter(string name, System.Diagnostics.Tracing.EventSource eventSource) { }
Expand Down
1 change: 1 addition & 0 deletions src/libraries/System.Linq.Parallel/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<Import Project="..\Directory.Build.props" />
<PropertyGroup>
<StrongNameKeyId>Microsoft</StrongNameKeyId>
<UnsupportedOSPlatforms>browser</UnsupportedOSPlatforms>
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>
</Project>
1 change: 1 addition & 0 deletions src/libraries/System.Net.Connections/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<Import Project="..\Directory.Build.props" />
<PropertyGroup>
<StrongNameKeyId>Microsoft</StrongNameKeyId>
<UnsupportedOSPlatforms>browser</UnsupportedOSPlatforms>
</PropertyGroup>
</Project>
1 change: 1 addition & 0 deletions src/libraries/System.Net.Http/ref/System.Net.Http.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public HttpClientHandler() { }
public System.Net.CookieContainer CookieContainer { get { throw null; } set { } }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public System.Net.ICredentials? Credentials { get { throw null; } set { } }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
public static System.Func<System.Net.Http.HttpRequestMessage, System.Security.Cryptography.X509Certificates.X509Certificate2?, System.Security.Cryptography.X509Certificates.X509Chain?, System.Net.Security.SslPolicyErrors, bool> DangerousAcceptAnyServerCertificateValidator { get { throw null; } }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public System.Net.ICredentials? DefaultProxyCredentials { get { throw null; } set { } }
Expand Down
8 changes: 5 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 @@ -106,8 +106,6 @@
<Compile Include="System\Net\Http\Headers\UriHeaderParser.cs" />
<Compile Include="System\Net\Http\Headers\ViaHeaderValue.cs" />
<Compile Include="System\Net\Http\Headers\WarningHeaderValue.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 @@ -173,6 +171,7 @@
<Compile Include="System\Net\Http\SocketsHttpHandler\RedirectHandler.cs" />
<Compile Include="System\Net\Http\SocketsHttpHandler\SocketsHttpConnectionContext.cs" />
<Compile Include="System\Net\Http\SocketsHttpHandler\SocketsHttpHandler.cs" />
<Compile Include="System\Net\Http\HttpTelemetry.AnyOS.cs" />
<Compile Include="System\Net\Http\HttpUtilities.AnyOS.cs" />
<Compile Include="System\Net\Http\SocketsHttpHandler\SystemProxyInfo.cs" />
<Compile Include="$(CommonPath)System\Net\NTAuthentication.Common.cs"
Expand All @@ -183,6 +182,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 Expand Up @@ -607,6 +608,7 @@
<Compile Include="System\Net\Http\BrowserHttpHandler\SystemProxyInfo.Browser.cs" />
<Compile Include="System\Net\Http\BrowserHttpHandler\SocketsHttpHandler.cs" />
<Compile Include="System\Net\Http\BrowserHttpHandler\BrowserHttpHandler.cs" />
<Compile Include="System\Net\Http\BrowserHttpHandler\HttpTelemetry.Browser.cs" />
<Compile Include="System\Net\Http\BrowserHttpHandler\HttpUtilities.Browser.cs" />
<Compile Include="$(CommonPath)System\Net\Http\HttpHandlerDefaults.cs"
Link="Common\System\Net\Http\HttpHandlerDefaults.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.Tracing;

namespace System.Net.Http
{
internal sealed partial class HttpTelemetry
{
public void Http11RequestLeftQueue(double timeOnQueueMilliseconds)
{
}

public void Http20RequestLeftQueue(double timeOnQueueMilliseconds)
{
}

protected override void OnEventCommand(EventCommandEventArgs command)
{
}
}
}
Loading