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

Fixing API compat issues between ref/src for attributes on properties #68432

Merged
merged 6 commits into from
Apr 30, 2022
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 @@ -84,6 +84,7 @@ private static partial bool GetCodeBase(QCallAssembly assembly,
return null;
}

[Obsolete("Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location.", DiagnosticId = "SYSLIB0012", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[RequiresAssemblyFiles(ThrowingMessageInRAF)]
public override string? CodeBase
{
Expand All @@ -103,7 +104,9 @@ public override string? CodeBase
if (codeBase.Length == 0)
{
// For backward compatibility, return CoreLib codebase for assemblies loaded from memory.
#pragma warning disable SYSLIB0012
codeBase = typeof(object).Assembly.CodeBase;
#pragma warning restore SYSLIB0012
}
return codeBase;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public static unsafe void PrepareMethod(RuntimeMethodHandle method, RuntimeTypeH
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern new bool Equals(object? o1, object? o2);

[Obsolete("OffsetToStringData has been deprecated. Use string.GetPinnableReference() instead.")]
public static int OffsetToStringData
{
// This offset is baked in by string indexer intrinsic, so there is no harm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ public static int ReadInt32(object ptr, int ofs)
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("ReadInt64(Object, Int32) may be unavailable in future releases.")]
[RequiresDynamicCode("Marshalling code for the object might not be available")]
#pragma warning disable CS0618 // Type or member is obsolete
public static long ReadInt64([MarshalAs(UnmanagedType.AsAny), In] object ptr, int ofs)
#pragma warning restore CS0618 // Type or member is obsolete
{
return ReadValueSlow(ptr, ofs, (IntPtr nativeHome, int offset) => ReadInt64(nativeHome, offset));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public static unsafe int GetHashCode(object o)
return ObjectHeader.GetHashCode(o);
}

[Obsolete("OffsetToStringData has been deprecated. Use string.GetPinnableReference() instead.")]
public static int OffsetToStringData
{
// This offset is baked in by string indexer intrinsic, so there is no harm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public int OffsetHigh
set { _overlappedData.OffsetHigh = value; }
}

[Obsolete("This property is not 64-bit compatible. Use EventHandleIntPtr instead. http://go.microsoft.com/fwlink/?linkid=14202")]
[Obsolete("Overlapped.EventHandle is not 64-bit compatible and has been deprecated. Use EventHandleIntPtr instead.")]
public int EventHandle
{
get { return EventHandleIntPtr.ToInt32(); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ internal partial class RuntimeAssemblyInfo
public sealed override bool IsDynamic => base.IsDynamic;
public sealed override string ToString() => base.ToString();
[RequiresAssemblyFilesAttribute("The code will return an empty string for assemblies embedded in a single-file app")]
#pragma warning disable SYSLIB0012
public sealed override string EscapedCodeBase => base.EscapedCodeBase;
#pragma warning restore SYSLIB0012
[RequiresAssemblyFiles("The code will throw for assemblies embedded in a single-file app")]
public sealed override FileStream[] GetFiles() => base.GetFiles();
#endif //DEBUG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,7 @@ public TextFieldParser(System.IO.TextReader reader) { }
public TextFieldParser(string path) { }
public TextFieldParser(string path, System.Text.Encoding defaultEncoding) { }
public TextFieldParser(string path, System.Text.Encoding defaultEncoding, bool detectEncoding) { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public string[]? CommentTokens { get { throw null; } set { } }
public string[]? Delimiters { get { throw null; } set { } }
public bool EndOfData { get { throw null; } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Namespace Global.Microsoft.VisualBasic

Public Const vbCrLf As String = ChrW(13) & ChrW(10)
Public Const vbObjectError As Integer = &H80040000I
<Global.System.Obsolete("For a carriage return and line feed, use vbCrLf. For the current platform's newline, use System.Environment.NewLine.")>
<Global.System.Obsolete("vbNewLine has been deprecated. For a carriage return and line feed, use vbCrLf. For the current platform's newline, use System.Environment.NewLine.")>
Public Const vbNewLine As String = ChrW(13) & ChrW(10)
Public Const vbCr As String = ChrW(13)
Public Const vbLf As String = ChrW(10)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,9 @@ internal TypeDescriptor() { }
[System.Diagnostics.CodeAnalysis.DisallowNullAttribute]
[System.ObsoleteAttribute("TypeDescriptor.ComNativeDescriptorHandler has been deprecated. Use a type description provider to supply type information for COM types instead.")]
public static System.ComponentModel.IComNativeDescriptorHandler? ComNativeDescriptorHandler { get { throw null; } set { } }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public static System.Type ComObjectType { [return: System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] get { throw null; } }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public static System.Type InterfaceType { [return: System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] get { throw null; } }
public static event System.ComponentModel.RefreshEventHandler? Refreshed { add { } remove { } }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
Expand Down
1 change: 1 addition & 0 deletions src/libraries/System.Data.Common/ref/System.Data.Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1577,6 +1577,7 @@ public enum SchemaType
public enum SerializationFormat
{
Xml = 0,
[System.ObsoleteAttribute("SerializationFormat.Binary is obsolete and should not be used. See https://aka.ms/serializationformat-binary-obsolete for more information.", DiagnosticId = "SYSLIB0038")]
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a breaking change: it was already made in the src but never shipped in references.

Copy link
Member

Choose a reason for hiding this comment

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

This should be fine. We already have obsolete attributes regarding binary formatter in various places; it seems we simply missed this occurrence. However, given this is in System.Data, it might be a very different scenario. /cc @roji @ajcvickers

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, we did this recently in #39289 as part of obsoleting (and eventually removing) all uses of BinaryFormatter, for 7.0 (so hasn't shipped yet). It's indeed being treated and documented as a breaking change.

Binary = 1,
}
public enum SqlDbType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public partial class DataColumn
[System.ComponentModel.DefaultValueAttribute(typeof(string))]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
[System.ComponentModel.TypeConverter(typeof(ColumnTypeConverter))]
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public System.Type DataType { get { throw null; } set { } }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1585,7 +1585,9 @@ public void WriteXmlEscapeName()
public void SerializationFormat_Binary_does_not_work_by_default()
{
DataSet ds = new DataSet();
#pragma warning disable SYSLIB0038
Assert.Throws<InvalidEnumArgumentException>(() => ds.RemotingFormat = SerializationFormat.Binary);
#pragma warning restore SYSLIB0038
}

[ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
Expand All @@ -1602,7 +1604,9 @@ static void RunTest()
DataColumn dc = new DataColumn("dc", typeof(int));
dt.Columns.Add(dc);
ds.Tables.Add(dt);
#pragma warning disable SYSLIB0038
ds.RemotingFormat = SerializationFormat.Binary;
#pragma warning restore SYSLIB0038

DataSet dsDeserialized;
using (MemoryStream ms = new MemoryStream())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,9 @@ public void SelectOperators()
public void SerializationFormat_Binary_does_not_work_by_default()
{
DataTable dt = new DataTable("MyTable");
#pragma warning disable SYSLIB0038
Assert.Throws<InvalidEnumArgumentException>(() => dt.RemotingFormat = SerializationFormat.Binary);
#pragma warning restore SYSLIB0038
}

[ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
Expand All @@ -396,7 +398,9 @@ static void RunTest()
DataTable dt = new DataTable("MyTable");
DataColumn dc = new DataColumn("dc", typeof(int));
dt.Columns.Add(dc);
#pragma warning disable SYSLIB0038
dt.RemotingFormat = SerializationFormat.Binary;
#pragma warning restore SYSLIB0038

DataTable dtDeserialized;
using (MemoryStream ms = new MemoryStream())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public OdbcParameter Add(OdbcParameter value)
}

[EditorBrowsableAttribute(EditorBrowsableState.Never)]
[ObsoleteAttribute("Add(String parameterName, Object value) has been deprecated. Use AddWithValue(String parameterName, Object value) instead.")]
[Obsolete("Add(String parameterName, Object value) has been deprecated. Use AddWithValue(String parameterName, Object value) instead.")]
public OdbcParameter Add(string? parameterName, object? value)
{
// MDAC 59206
Expand Down
1 change: 1 addition & 0 deletions src/libraries/System.Data.OleDb/ref/System.Data.OleDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public OleDbCommand(string? cmdText, System.Data.OleDb.OleDbConnection? connecti
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DefaultValueAttribute(true)]
[System.ComponentModel.DesignOnlyAttribute(true)]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool DesignTimeVisible { get { throw null; } set { } }
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)]
public new System.Data.OleDb.OleDbParameterCollection Parameters { get { throw null; } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public enum StandardEventKeywords : long
/// <summary>
/// Incorrect CorrelationHint value mistakenly shipped in .NET 3.5. Don't use: duplicates AuditFailure.
/// </summary>
[Obsolete("StandardEventKeywords.CorrelationHint has an incorrect value. Use CorrelationHint2 instead.")]
[Obsolete("StandardEventKeywords.CorrelationHint has an incorrect value and has been deprecated. Use CorrelationHint2 instead.")]
CorrelationHint = 0x10000000000000,
/// <summary>
/// Transfer events where the related Activity ID is a computed value and not a GUID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void CopyTo(System.Diagnostics.InstanceDataCollection[] counters, int ind
}
public sealed partial class PerformanceCounter : System.ComponentModel.Component, System.ComponentModel.ISupportInitialize
{
[System.ObsoleteAttribute("This field has been deprecated and is not used. Use machine.config or an application configuration file to set the size of the PerformanceCounter file mapping instead.")]
[System.ObsoleteAttribute("PerformanceCounter.DefaultFileMappingSize has been deprecated and is not used. Use machine.config or an application configuration file to set the size of the PerformanceCounter file mapping instead.")]
public static int DefaultFileMappingSize;
public PerformanceCounter() { }
public PerformanceCounter(string categoryName, string counterName) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public sealed class PerformanceCounter : Component, ISupportInitialize
// Cached IP Shared Performanco counter
private SharedPerformanceCounter _sharedCounter;

[ObsoleteAttribute("PerformanceCounter.DefaultFileMappingSize has been deprecated and is not used. Use machine.config or an application configuration file to set the size of the PerformanceCounter file mapping instead.")]
[Obsolete("PerformanceCounter.DefaultFileMappingSize has been deprecated and is not used. Use machine.config or an application configuration file to set the size of the PerformanceCounter file mapping instead.")]
public static int DefaultFileMappingSize = 524288;

private object _instanceLockObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ namespace System.Diagnostics
{
public sealed class PerformanceCounterManager : ICollectData
{
[ObsoleteAttribute("PerformanceCounterManager has been deprecated. Use the PerformanceCounters through the System.Diagnostics.PerformanceCounter class instead.")]
[Obsolete("PerformanceCounterManager has been deprecated. Use the PerformanceCounters through the System.Diagnostics.PerformanceCounter class instead.")]
public PerformanceCounterManager()
{
}

[ObsoleteAttribute("PerformanceCounterManager has been deprecated. Use the PerformanceCounters through the System.Diagnostics.PerformanceCounter class instead.")]
[Obsolete("PerformanceCounterManager has been deprecated. Use the PerformanceCounters through the System.Diagnostics.PerformanceCounter class instead.")]
void ICollectData.CollectData(int callIdx, IntPtr valueNamePtr, IntPtr dataPtr, int totalBytes, out IntPtr res)
{
res = (IntPtr)(-1);
}

[ObsoleteAttribute("PerformanceCounterManager has been deprecated. Use the PerformanceCounters through the System.Diagnostics.PerformanceCounter class instead.")]
[Obsolete("PerformanceCounterManager has been deprecated. Use the PerformanceCounters through the System.Diagnostics.PerformanceCounter class instead.")]
void ICollectData.CloseData()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public Process() { }
[System.ObsoleteAttribute("Process.PrivateMemorySize has been deprecated because the type of the property can't represent all valid results. Use System.Diagnostics.Process.PrivateMemorySize64 instead.")]
public int PrivateMemorySize { get { throw null; } }
public long PrivateMemorySize64 { get { throw null; } }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
ericstj marked this conversation as resolved.
Show resolved Hide resolved
public System.TimeSpan PrivilegedProcessorTime { get { throw null; } }
public string ProcessName { get { throw null; } }
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
Expand All @@ -81,6 +83,9 @@ public Process() { }
public System.IO.StreamWriter StandardInput { get { throw null; } }
public System.IO.StreamReader StandardOutput { get { throw null; } }
public System.Diagnostics.ProcessStartInfo StartInfo { get { throw null; } set { } }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
[System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")]
public System.DateTime StartTime { get { throw null; } }
public System.ComponentModel.ISynchronizeInvoke? SynchronizingObject { get { throw null; } set { } }
public System.Diagnostics.ProcessThreadCollection Threads { get { throw null; } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;

namespace System.Diagnostics
{
Expand All @@ -26,6 +27,9 @@ internal DateTime StartTimeCore
/// It is the sum of the <see cref='System.Diagnostics.Process.UserProcessorTime'/> and
/// <see cref='System.Diagnostics.Process.PrivilegedProcessorTime'/>.
/// </summary>
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
public TimeSpan TotalProcessorTime
{
get
Expand All @@ -40,6 +44,9 @@ public TimeSpan TotalProcessorTime
/// Gets the amount of time the associated process has spent running code
/// inside the application portion of the process (not the operating system core).
/// </summary>
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
public TimeSpan UserProcessorTime
{
get
Expand All @@ -52,6 +59,8 @@ public TimeSpan UserProcessorTime
}

/// <summary>Gets the amount of time the process has spent running code inside the operating system core.</summary>
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
public TimeSpan PrivilegedProcessorTime
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public static Process[] GetProcessesByName(string? processName, string machineNa
}

/// <summary>Gets the amount of time the process has spent running code inside the operating system core.</summary>
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
public TimeSpan PrivilegedProcessorTime
{
get
Expand Down Expand Up @@ -127,6 +129,9 @@ private static DateTime BootTime
/// It is the sum of the <see cref='System.Diagnostics.Process.UserProcessorTime'/> and
/// <see cref='System.Diagnostics.Process.PrivilegedProcessorTime'/>.
/// </summary>
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
public TimeSpan TotalProcessorTime
{
get
Expand All @@ -140,6 +145,9 @@ public TimeSpan TotalProcessorTime
/// Gets the amount of time the associated process has spent running code
/// inside the application portion of the process (not the operating system core).
/// </summary>
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
public TimeSpan UserProcessorTime
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.Versioning;

namespace System.Diagnostics
{
Expand All @@ -13,6 +14,8 @@ public partial class Process
private const int MicrosecondsToSecondsFactor = 1_000_000;

/// <summary>Gets the amount of time the process has spent running code inside the operating system core.</summary>
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
public TimeSpan PrivilegedProcessorTime
{
get
Expand Down Expand Up @@ -52,6 +55,9 @@ private static string GetPathToOpenFile()
/// It is the sum of the <see cref='System.Diagnostics.Process.UserProcessorTime'/> and
/// <see cref='System.Diagnostics.Process.PrivilegedProcessorTime'/>.
/// </summary>
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
public TimeSpan TotalProcessorTime
{
get
Expand All @@ -66,6 +72,9 @@ public TimeSpan TotalProcessorTime
/// Gets the amount of time the associated process has spent running code
/// inside the application portion of the process (not the operating system core).
/// </summary>
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
public TimeSpan UserProcessorTime
{
get
Expand Down
Loading