Skip to content

Update the (Get|Set)CompressedStack obsoletions to use SYSLIB0003 #56874

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

Merged
merged 2 commits into from
Aug 5, 2021
Merged
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 @@ -507,13 +507,13 @@ private bool SetApartmentState(ApartmentState state, bool throwOnError)
return SetApartmentStateUnchecked(state, throwOnError);
}

[Obsolete("Thread.GetCompressedStack has been deprecated. Use the System.Threading.CompressedStack class instead.")]
[Obsolete(Obsoletions.CodeAccessSecurityMessage, DiagnosticId = Obsoletions.CodeAccessSecurityDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public CompressedStack GetCompressedStack()
{
throw new InvalidOperationException(SR.Thread_GetSetCompressedStack_NotSupported);
}

[Obsolete("Thread.SetCompressedStack has been deprecated. Use the System.Threading.CompressedStack class instead.")]
[Obsolete(Obsoletions.CodeAccessSecurityMessage, DiagnosticId = Obsoletions.CodeAccessSecurityDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public void SetCompressedStack(CompressedStack stack)
{
throw new InvalidOperationException(SR.Thread_GetSetCompressedStack_NotSupported);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static void EndThreadAffinity() { }
~Thread() { }
public static void FreeNamedDataSlot(string name) { }
public System.Threading.ApartmentState GetApartmentState() { throw null; }
[System.ObsoleteAttribute("Thread.GetCompressedStack has been deprecated. Use the System.Threading.CompressedStack class instead.")]
[System.ObsoleteAttribute("Code Access Security is not supported or honored by the runtime.", DiagnosticId = "SYSLIB0003", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public System.Threading.CompressedStack GetCompressedStack() { throw null; }
public static int GetCurrentProcessorId() { throw null; }
public static object? GetData(System.LocalDataStoreSlot slot) { throw null; }
Expand All @@ -83,7 +83,7 @@ public static void ResetAbort() { }
public void Resume() { }
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
public void SetApartmentState(System.Threading.ApartmentState state) { }
[System.ObsoleteAttribute("Thread.SetCompressedStack has been deprecated. Use the System.Threading.CompressedStack class instead.")]
[System.ObsoleteAttribute("Code Access Security is not supported or honored by the runtime.", DiagnosticId = "SYSLIB0003", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public void SetCompressedStack(System.Threading.CompressedStack stack) { }
public static void SetData(System.LocalDataStoreSlot slot, object? data) { }
public static void Sleep(int millisecondsTimeout) { }
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/System.Threading.Thread/tests/ThreadTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1149,10 +1149,10 @@ public static void MiscellaneousTest()
Thread.BeginThreadAffinity();
Thread.EndThreadAffinity();

#pragma warning disable 618 // obsolete members
#pragma warning disable SYSLIB0003 // obsolete members
Assert.Throws<InvalidOperationException>(() => Thread.CurrentThread.GetCompressedStack());
Assert.Throws<InvalidOperationException>(() => Thread.CurrentThread.SetCompressedStack(CompressedStack.Capture()));
#pragma warning restore 618 // obsolete members
#pragma warning restore SYSLIB0003 // obsolete members

Thread.MemoryBarrier();

Expand Down