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

[wasm] Mark System.Threading.Thread APIs unsupported on Browser #41892

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
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.Runtime.Serialization;
using System.Runtime.Versioning;

namespace System.Threading
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public void Abort(object? stateInfo)
throw new PlatformNotSupportedException(SR.PlatformNotSupported_ThreadAbort);
}

[Obsolete("Thread.ResetAbort is not supported and throws PlatformNotSupportedException.")]
public static void ResetAbort()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this throws PNSE everywhere, is there a way we can mark it as such?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if its better to stick with the convention of marking it Obsolete. I wasn't sure if a docs issue should be linked in the parameters of Obsolete. It looks like it was brought up in dotnet/docs#3825.

Another option that was brought up was to mark this as [UnsupportedOSPlatform("none")]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeffhandley @buyaa-n What do y'all think about [UnsupportedOSPlatform("none")]?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the analyzer that would be treated like unsupported on a platform named "none", there is no generic naming for all platforms CC @terrajobst

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Obsolete] would be a better approach than to fake that with an [UnsupportedOSPlatform] or [SupportedOSPlatform] attribute. I recommend we omit this annotation here and file a 6.0.0 issue to mark this API as Obsolete.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was looking at a stale page a moment ago. I think we'll have to wait to mark this as Obsolete until 6.0.0 since it's technically a breaking change. We'll want to consider using a custom diagnostic id for the obsoletion too and add it to the list of obsoletions, etc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Jeff. We shouldn't annotate this API. We should obsolete, but not for .NET 5.

{
throw new PlatformNotSupportedException(SR.PlatformNotSupported_ThreadAbort);
Expand Down
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>
<IncludePlatformAttributes>true</IncludePlatformAttributes>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public void Join() { }
public bool Join(int millisecondsTimeout) { throw null; }
public bool Join(System.TimeSpan timeout) { throw null; }
public static void MemoryBarrier() { }
[System.ObsoleteAttribute("Thread.ResetAbort is not supported and throws PlatformNotSupportedException.")]
public static void ResetAbort() { }
[System.ObsoleteAttribute("Thread.Resume has been deprecated. Please use other classes in System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources. https://go.microsoft.com/fwlink/?linkid=14202", false)]
public void Resume() { }
Expand Down