diff --git a/eng/ApiCompatExcludeAttributes.txt b/eng/ApiCompatExcludeAttributes.txt index 83aa68c922346..325c9fa1f934a 100644 --- a/eng/ApiCompatExcludeAttributes.txt +++ b/eng/ApiCompatExcludeAttributes.txt @@ -1,3 +1,4 @@ T:System.Diagnostics.CodeAnalysis.MemberNotNullAttribute T:System.Diagnostics.DebuggerGuidedStepThroughAttribute T:System.Runtime.CompilerServices.EagerStaticClassConstructionAttribute +T:System.Runtime.CompilerServices.NativeIntegerAttribute diff --git a/eng/Versions.props b/eng/Versions.props index e7db623f5862d..45b6ba1b75fb5 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -49,9 +49,9 @@ - 4.3.0-2.22261.3 + 4.3.0-2.22270.2 - 2.0.0-alpha.1.21525.11 + 2.0.0-preview.4.22252.4 7.0.0-beta.22255.2 7.0.0-beta.22255.2 diff --git a/src/libraries/Microsoft.Extensions.Caching.Abstractions/src/CompatibilitySuppressions.xml b/src/libraries/Microsoft.Extensions.Caching.Abstractions/src/CompatibilitySuppressions.xml new file mode 100644 index 0000000000000..3b52b355d9329 --- /dev/null +++ b/src/libraries/Microsoft.Extensions.Caching.Abstractions/src/CompatibilitySuppressions.xml @@ -0,0 +1,9 @@ + + + + CP0002 + M:Microsoft.Extensions.Caching.Memory.PostEvictionDelegate.#ctor(System.Object,System.IntPtr) + lib/net6.0/Microsoft.Extensions.Caching.Abstractions.dll + lib/net7.0/Microsoft.Extensions.Caching.Abstractions.dll + + \ No newline at end of file diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/CompatibilitySuppressions.xml b/src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/CompatibilitySuppressions.xml new file mode 100644 index 0000000000000..351221bb28d4a --- /dev/null +++ b/src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/CompatibilitySuppressions.xml @@ -0,0 +1,9 @@ + + + + CP0002 + M:Microsoft.Extensions.DependencyInjection.ObjectFactory.#ctor(System.Object,System.IntPtr) + lib/net6.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll + lib/net7.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll + + \ No newline at end of file diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection.Specification.Tests/src/CompatibilitySuppressions.xml b/src/libraries/Microsoft.Extensions.DependencyInjection.Specification.Tests/src/CompatibilitySuppressions.xml new file mode 100644 index 0000000000000..6b7b6bfd1c22a --- /dev/null +++ b/src/libraries/Microsoft.Extensions.DependencyInjection.Specification.Tests/src/CompatibilitySuppressions.xml @@ -0,0 +1,9 @@ + + + + CP0002 + M:Microsoft.Extensions.DependencyInjection.Specification.DependencyInjectionSpecificationTests.CreateInstanceFunc.#ctor(System.Object,System.IntPtr) + lib/net6.0/Microsoft.Extensions.DependencyInjection.Specification.Tests.dll + lib/net7.0/Microsoft.Extensions.DependencyInjection.Specification.Tests.dll + + \ No newline at end of file diff --git a/src/libraries/Microsoft.Win32.SystemEvents/src/CompatibilitySuppressions.xml b/src/libraries/Microsoft.Win32.SystemEvents/src/CompatibilitySuppressions.xml new file mode 100644 index 0000000000000..f41d235839d41 --- /dev/null +++ b/src/libraries/Microsoft.Win32.SystemEvents/src/CompatibilitySuppressions.xml @@ -0,0 +1,57 @@ + + + + CP0002 + M:Microsoft.Win32.PowerModeChangedEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/Microsoft.Win32.SystemEvents.dll + lib/net7.0/Microsoft.Win32.SystemEvents.dll + + + CP0002 + M:Microsoft.Win32.SessionEndedEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/Microsoft.Win32.SystemEvents.dll + lib/net7.0/Microsoft.Win32.SystemEvents.dll + + + CP0002 + M:Microsoft.Win32.SessionEndingEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/Microsoft.Win32.SystemEvents.dll + lib/net7.0/Microsoft.Win32.SystemEvents.dll + + + CP0002 + M:Microsoft.Win32.SessionSwitchEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/Microsoft.Win32.SystemEvents.dll + lib/net7.0/Microsoft.Win32.SystemEvents.dll + + + CP0002 + M:Microsoft.Win32.SystemEvents.KillTimer(System.IntPtr) + lib/net6.0/Microsoft.Win32.SystemEvents.dll + lib/net7.0/Microsoft.Win32.SystemEvents.dll + + + CP0002 + M:Microsoft.Win32.TimerElapsedEventArgs.#ctor(System.IntPtr) + lib/net6.0/Microsoft.Win32.SystemEvents.dll + lib/net7.0/Microsoft.Win32.SystemEvents.dll + + + CP0002 + M:Microsoft.Win32.TimerElapsedEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/Microsoft.Win32.SystemEvents.dll + lib/net7.0/Microsoft.Win32.SystemEvents.dll + + + CP0002 + M:Microsoft.Win32.UserPreferenceChangedEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/Microsoft.Win32.SystemEvents.dll + lib/net7.0/Microsoft.Win32.SystemEvents.dll + + + CP0002 + M:Microsoft.Win32.UserPreferenceChangingEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/Microsoft.Win32.SystemEvents.dll + lib/net7.0/Microsoft.Win32.SystemEvents.dll + + \ No newline at end of file diff --git a/src/libraries/System.CodeDom/src/CompatibilitySuppressions.xml b/src/libraries/System.CodeDom/src/CompatibilitySuppressions.xml new file mode 100644 index 0000000000000..b755bb33f2cdf --- /dev/null +++ b/src/libraries/System.CodeDom/src/CompatibilitySuppressions.xml @@ -0,0 +1,15 @@ + + + + CP0002 + M:System.CodeDom.Compiler.Executor.ExecWaitWithCapture(System.IntPtr,System.String,System.CodeDom.Compiler.TempFileCollection,System.String@,System.String@) + lib/net6.0/System.CodeDom.dll + lib/net7.0/System.CodeDom.dll + + + CP0002 + M:System.CodeDom.Compiler.Executor.ExecWaitWithCapture(System.IntPtr,System.String,System.String,System.CodeDom.Compiler.TempFileCollection,System.String@,System.String@) + lib/net6.0/System.CodeDom.dll + lib/net7.0/System.CodeDom.dll + + \ No newline at end of file diff --git a/src/libraries/System.Composition.Hosting/src/CompatibilitySuppressions.xml b/src/libraries/System.Composition.Hosting/src/CompatibilitySuppressions.xml new file mode 100644 index 0000000000000..e358a0e72439b --- /dev/null +++ b/src/libraries/System.Composition.Hosting/src/CompatibilitySuppressions.xml @@ -0,0 +1,9 @@ + + + + CP0002 + M:System.Composition.Hosting.Core.CompositeActivator.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Composition.Hosting.dll + lib/net7.0/System.Composition.Hosting.dll + + \ No newline at end of file diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/CompatibilitySuppressions.xml b/src/libraries/System.Configuration.ConfigurationManager/src/CompatibilitySuppressions.xml index 8a07071730984..70889d28bf99a 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/CompatibilitySuppressions.xml +++ b/src/libraries/System.Configuration.ConfigurationManager/src/CompatibilitySuppressions.xml @@ -36,4 +36,40 @@ lib/netstandard2.0/System.Configuration.ConfigurationManager.dll lib/net462/System.Configuration.ConfigurationManager.dll + + CP0002 + M:System.Configuration.SettingChangingEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Configuration.ConfigurationManager.dll + lib/net7.0/System.Configuration.ConfigurationManager.dll + + + CP0002 + M:System.Configuration.SettingsLoadedEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Configuration.ConfigurationManager.dll + lib/net7.0/System.Configuration.ConfigurationManager.dll + + + CP0002 + M:System.Configuration.SettingsSavingEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Configuration.ConfigurationManager.dll + lib/net7.0/System.Configuration.ConfigurationManager.dll + + + CP0002 + M:System.Configuration.ValidatorCallback.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Configuration.ConfigurationManager.dll + lib/net7.0/System.Configuration.ConfigurationManager.dll + + + CP0002 + M:System.Configuration.Internal.InternalConfigEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Configuration.ConfigurationManager.dll + lib/net7.0/System.Configuration.ConfigurationManager.dll + + + CP0002 + M:System.Configuration.Internal.StreamChangeCallback.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Configuration.ConfigurationManager.dll + lib/net7.0/System.Configuration.ConfigurationManager.dll + \ No newline at end of file diff --git a/src/libraries/System.Data.Odbc/src/CompatibilitySuppressions.xml b/src/libraries/System.Data.Odbc/src/CompatibilitySuppressions.xml index 5971367836429..0c15b2d390f7c 100644 --- a/src/libraries/System.Data.Odbc/src/CompatibilitySuppressions.xml +++ b/src/libraries/System.Data.Odbc/src/CompatibilitySuppressions.xml @@ -347,4 +347,22 @@ lib/netstandard2.0/System.Data.Odbc.dll true + + CP0002 + M:System.Data.Odbc.OdbcInfoMessageEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Data.Odbc.dll + lib/net7.0/System.Data.Odbc.dll + + + CP0002 + M:System.Data.Odbc.OdbcRowUpdatedEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Data.Odbc.dll + lib/net7.0/System.Data.Odbc.dll + + + CP0002 + M:System.Data.Odbc.OdbcRowUpdatingEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Data.Odbc.dll + lib/net7.0/System.Data.Odbc.dll + \ No newline at end of file diff --git a/src/libraries/System.Data.OleDb/src/CompatibilitySuppressions.xml b/src/libraries/System.Data.OleDb/src/CompatibilitySuppressions.xml new file mode 100644 index 0000000000000..19a4947b8f7be --- /dev/null +++ b/src/libraries/System.Data.OleDb/src/CompatibilitySuppressions.xml @@ -0,0 +1,21 @@ + + + + CP0002 + M:System.Data.OleDb.OleDbInfoMessageEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Data.OleDb.dll + lib/net7.0/System.Data.OleDb.dll + + + CP0002 + M:System.Data.OleDb.OleDbRowUpdatedEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Data.OleDb.dll + lib/net7.0/System.Data.OleDb.dll + + + CP0002 + M:System.Data.OleDb.OleDbRowUpdatingEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Data.OleDb.dll + lib/net7.0/System.Data.OleDb.dll + + \ No newline at end of file diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/CompatibilitySuppressions.xml b/src/libraries/System.Diagnostics.DiagnosticSource/src/CompatibilitySuppressions.xml new file mode 100644 index 0000000000000..994ad65b2944d --- /dev/null +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/CompatibilitySuppressions.xml @@ -0,0 +1,27 @@ + + + + CP0002 + M:System.Diagnostics.SampleActivity`1.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Diagnostics.DiagnosticSource.dll + lib/net7.0/System.Diagnostics.DiagnosticSource.dll + + + CP0002 + M:System.Diagnostics.DistributedContextPropagator.PropagatorGetterCallback.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Diagnostics.DiagnosticSource.dll + lib/net7.0/System.Diagnostics.DiagnosticSource.dll + + + CP0002 + M:System.Diagnostics.DistributedContextPropagator.PropagatorSetterCallback.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Diagnostics.DiagnosticSource.dll + lib/net7.0/System.Diagnostics.DiagnosticSource.dll + + + CP0002 + M:System.Diagnostics.Metrics.MeasurementCallback`1.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Diagnostics.DiagnosticSource.dll + lib/net7.0/System.Diagnostics.DiagnosticSource.dll + + \ No newline at end of file diff --git a/src/libraries/System.Diagnostics.EventLog/src/CompatibilitySuppressions.xml b/src/libraries/System.Diagnostics.EventLog/src/CompatibilitySuppressions.xml new file mode 100644 index 0000000000000..3c98c29c672ce --- /dev/null +++ b/src/libraries/System.Diagnostics.EventLog/src/CompatibilitySuppressions.xml @@ -0,0 +1,9 @@ + + + + CP0002 + M:System.Diagnostics.EntryWrittenEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Diagnostics.EventLog.dll + lib/net7.0/System.Diagnostics.EventLog.dll + + \ No newline at end of file diff --git a/src/libraries/System.Diagnostics.PerformanceCounter/src/CompatibilitySuppressions.xml b/src/libraries/System.Diagnostics.PerformanceCounter/src/CompatibilitySuppressions.xml new file mode 100644 index 0000000000000..536f709eb9a6a --- /dev/null +++ b/src/libraries/System.Diagnostics.PerformanceCounter/src/CompatibilitySuppressions.xml @@ -0,0 +1,15 @@ + + + + CP0002 + M:System.Diagnostics.ICollectData.CollectData(System.Int32,System.IntPtr,System.IntPtr,System.Int32,System.IntPtr@) + lib/net6.0/System.Diagnostics.PerformanceCounter.dll + lib/net7.0/System.Diagnostics.PerformanceCounter.dll + + + CP0006 + M:System.Diagnostics.ICollectData.CollectData(System.Int32,System.IntPtr,System.IntPtr,System.Int32,System.IntPtr@) + lib/net6.0/System.Diagnostics.PerformanceCounter.dll + lib/net7.0/System.Diagnostics.PerformanceCounter.dll + + \ No newline at end of file diff --git a/src/libraries/System.DirectoryServices.Protocols/src/CompatibilitySuppressions.xml b/src/libraries/System.DirectoryServices.Protocols/src/CompatibilitySuppressions.xml new file mode 100644 index 0000000000000..0eedfcc415e06 --- /dev/null +++ b/src/libraries/System.DirectoryServices.Protocols/src/CompatibilitySuppressions.xml @@ -0,0 +1,33 @@ + + + + CP0002 + M:System.DirectoryServices.Protocols.DereferenceConnectionCallback.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.DirectoryServices.Protocols.dll + lib/net7.0/System.DirectoryServices.Protocols.dll + + + CP0002 + M:System.DirectoryServices.Protocols.NotifyOfNewConnectionCallback.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.DirectoryServices.Protocols.dll + lib/net7.0/System.DirectoryServices.Protocols.dll + + + CP0002 + M:System.DirectoryServices.Protocols.QueryClientCertificateCallback.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.DirectoryServices.Protocols.dll + lib/net7.0/System.DirectoryServices.Protocols.dll + + + CP0002 + M:System.DirectoryServices.Protocols.QueryForConnectionCallback.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.DirectoryServices.Protocols.dll + lib/net7.0/System.DirectoryServices.Protocols.dll + + + CP0002 + M:System.DirectoryServices.Protocols.VerifyServerCertificateCallback.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.DirectoryServices.Protocols.dll + lib/net7.0/System.DirectoryServices.Protocols.dll + + \ No newline at end of file diff --git a/src/libraries/System.DirectoryServices/src/CompatibilitySuppressions.xml b/src/libraries/System.DirectoryServices/src/CompatibilitySuppressions.xml new file mode 100644 index 0000000000000..8f56bc5a74e02 --- /dev/null +++ b/src/libraries/System.DirectoryServices/src/CompatibilitySuppressions.xml @@ -0,0 +1,9 @@ + + + + CP0002 + M:System.DirectoryServices.ActiveDirectory.SyncUpdateCallback.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.DirectoryServices.dll + lib/net7.0/System.DirectoryServices.dll + + \ No newline at end of file diff --git a/src/libraries/System.Drawing.Common/src/CompatibilitySuppressions.xml b/src/libraries/System.Drawing.Common/src/CompatibilitySuppressions.xml index 4870097bdac77..e2ab49e117507 100644 --- a/src/libraries/System.Drawing.Common/src/CompatibilitySuppressions.xml +++ b/src/libraries/System.Drawing.Common/src/CompatibilitySuppressions.xml @@ -201,4 +201,640 @@ lib/netstandard2.0/System.Drawing.Common.dll true + + CP0002 + M:System.Drawing.Bitmap.#ctor(System.Int32,System.Int32,System.Int32,System.Drawing.Imaging.PixelFormat,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Bitmap.FromHicon(System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Bitmap.FromResource(System.IntPtr,System.String) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Brush.SetNativeBrush(System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.BufferedGraphics.Render(System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.BufferedGraphicsContext.Allocate(System.IntPtr,System.Drawing.Rectangle) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Font.FromHdc(System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Font.FromHfont(System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Font.FromLogFont(System.Object,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.DrawImageAbort.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.DrawImageAbort.Invoke(System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.DrawImageAbort.BeginInvoke(System.IntPtr,System.AsyncCallback,System.Object) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafileProc.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafileProc.Invoke(System.Drawing.Imaging.EmfPlusRecordType,System.Int32,System.Int32,System.IntPtr,System.Drawing.Imaging.PlayRecordCallback) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafileProc.BeginInvoke(System.Drawing.Imaging.EmfPlusRecordType,System.Int32,System.Int32,System.IntPtr,System.Drawing.Imaging.PlayRecordCallback,System.AsyncCallback,System.Object) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.DrawImage(System.Drawing.Image,System.Drawing.Rectangle,System.Int32,System.Int32,System.Int32,System.Int32,System.Drawing.GraphicsUnit,System.Drawing.Imaging.ImageAttributes,System.Drawing.Graphics.DrawImageAbort,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.DrawImage(System.Drawing.Image,System.Drawing.Rectangle,System.Single,System.Single,System.Single,System.Single,System.Drawing.GraphicsUnit,System.Drawing.Imaging.ImageAttributes,System.Drawing.Graphics.DrawImageAbort,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.Point,System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.Point,System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr,System.Drawing.Imaging.ImageAttributes) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.Point,System.Drawing.Rectangle,System.Drawing.GraphicsUnit,System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.Point,System.Drawing.Rectangle,System.Drawing.GraphicsUnit,System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr,System.Drawing.Imaging.ImageAttributes) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.PointF,System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.PointF,System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr,System.Drawing.Imaging.ImageAttributes) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.PointF,System.Drawing.RectangleF,System.Drawing.GraphicsUnit,System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.PointF,System.Drawing.RectangleF,System.Drawing.GraphicsUnit,System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr,System.Drawing.Imaging.ImageAttributes) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.PointF[],System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.PointF[],System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr,System.Drawing.Imaging.ImageAttributes) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.PointF[],System.Drawing.RectangleF,System.Drawing.GraphicsUnit,System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.PointF[],System.Drawing.RectangleF,System.Drawing.GraphicsUnit,System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr,System.Drawing.Imaging.ImageAttributes) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.Point[],System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.Point[],System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr,System.Drawing.Imaging.ImageAttributes) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.Point[],System.Drawing.Rectangle,System.Drawing.GraphicsUnit,System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.Point[],System.Drawing.Rectangle,System.Drawing.GraphicsUnit,System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr,System.Drawing.Imaging.ImageAttributes) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.Rectangle,System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.Rectangle,System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr,System.Drawing.Imaging.ImageAttributes) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.Rectangle,System.Drawing.Rectangle,System.Drawing.GraphicsUnit,System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.Rectangle,System.Drawing.Rectangle,System.Drawing.GraphicsUnit,System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr,System.Drawing.Imaging.ImageAttributes) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.RectangleF,System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.RectangleF,System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr,System.Drawing.Imaging.ImageAttributes) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.RectangleF,System.Drawing.RectangleF,System.Drawing.GraphicsUnit,System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.EnumerateMetafile(System.Drawing.Imaging.Metafile,System.Drawing.RectangleF,System.Drawing.RectangleF,System.Drawing.GraphicsUnit,System.Drawing.Graphics.EnumerateMetafileProc,System.IntPtr,System.Drawing.Imaging.ImageAttributes) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.FromHdc(System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.FromHdc(System.IntPtr,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.FromHdcInternal(System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.FromHwnd(System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.FromHwndInternal(System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.ReleaseHdc(System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Graphics.ReleaseHdcInternal(System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Icon.FromHandle(System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Image.GetThumbnailImageAbort.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Image.FromHbitmap(System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Image.FromHbitmap(System.IntPtr,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Image.GetThumbnailImage(System.Int32,System.Int32,System.Drawing.Image.GetThumbnailImageAbort,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Region.FromHrgn(System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Region.ReleaseHrgn(System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Text.PrivateFontCollection.AddMemoryFont(System.IntPtr,System.Int32) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Printing.PageSettings.CopyToHdevmode(System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Printing.PageSettings.SetHdevmode(System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Printing.PrinterSettings.SetHdevmode(System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Printing.PrinterSettings.SetHdevnames(System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Printing.PrintEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Printing.PrintPageEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Printing.QueryPageSettingsEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.EncoderParameter.#ctor(System.Drawing.Imaging.Encoder,System.Int32,System.Drawing.Imaging.EncoderParameterValueType,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IntPtr,System.Boolean) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IntPtr,System.Drawing.Imaging.EmfType) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IntPtr,System.Drawing.Imaging.EmfType,System.String) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IntPtr,System.Drawing.Imaging.WmfPlaceableFileHeader) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IntPtr,System.Drawing.Imaging.WmfPlaceableFileHeader,System.Boolean) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IntPtr,System.Drawing.Rectangle) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IntPtr,System.Drawing.Rectangle,System.Drawing.Imaging.MetafileFrameUnit) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IntPtr,System.Drawing.Rectangle,System.Drawing.Imaging.MetafileFrameUnit,System.Drawing.Imaging.EmfType) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IntPtr,System.Drawing.Rectangle,System.Drawing.Imaging.MetafileFrameUnit,System.Drawing.Imaging.EmfType,System.String) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IntPtr,System.Drawing.RectangleF) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IntPtr,System.Drawing.RectangleF,System.Drawing.Imaging.MetafileFrameUnit) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IntPtr,System.Drawing.RectangleF,System.Drawing.Imaging.MetafileFrameUnit,System.Drawing.Imaging.EmfType) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IntPtr,System.Drawing.RectangleF,System.Drawing.Imaging.MetafileFrameUnit,System.Drawing.Imaging.EmfType,System.String) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IO.Stream,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IO.Stream,System.IntPtr,System.Drawing.Imaging.EmfType) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IO.Stream,System.IntPtr,System.Drawing.Imaging.EmfType,System.String) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IO.Stream,System.IntPtr,System.Drawing.Rectangle) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IO.Stream,System.IntPtr,System.Drawing.Rectangle,System.Drawing.Imaging.MetafileFrameUnit) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IO.Stream,System.IntPtr,System.Drawing.Rectangle,System.Drawing.Imaging.MetafileFrameUnit,System.Drawing.Imaging.EmfType) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IO.Stream,System.IntPtr,System.Drawing.Rectangle,System.Drawing.Imaging.MetafileFrameUnit,System.Drawing.Imaging.EmfType,System.String) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IO.Stream,System.IntPtr,System.Drawing.RectangleF) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IO.Stream,System.IntPtr,System.Drawing.RectangleF,System.Drawing.Imaging.MetafileFrameUnit) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IO.Stream,System.IntPtr,System.Drawing.RectangleF,System.Drawing.Imaging.MetafileFrameUnit,System.Drawing.Imaging.EmfType) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.IO.Stream,System.IntPtr,System.Drawing.RectangleF,System.Drawing.Imaging.MetafileFrameUnit,System.Drawing.Imaging.EmfType,System.String) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.String,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.String,System.IntPtr,System.Drawing.Imaging.EmfType) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.String,System.IntPtr,System.Drawing.Imaging.EmfType,System.String) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.String,System.IntPtr,System.Drawing.Rectangle) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.String,System.IntPtr,System.Drawing.Rectangle,System.Drawing.Imaging.MetafileFrameUnit) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.String,System.IntPtr,System.Drawing.Rectangle,System.Drawing.Imaging.MetafileFrameUnit,System.Drawing.Imaging.EmfType) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.String,System.IntPtr,System.Drawing.Rectangle,System.Drawing.Imaging.MetafileFrameUnit,System.Drawing.Imaging.EmfType,System.String) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.String,System.IntPtr,System.Drawing.Rectangle,System.Drawing.Imaging.MetafileFrameUnit,System.String) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.String,System.IntPtr,System.Drawing.RectangleF) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.String,System.IntPtr,System.Drawing.RectangleF,System.Drawing.Imaging.MetafileFrameUnit) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.String,System.IntPtr,System.Drawing.RectangleF,System.Drawing.Imaging.MetafileFrameUnit,System.Drawing.Imaging.EmfType) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.String,System.IntPtr,System.Drawing.RectangleF,System.Drawing.Imaging.MetafileFrameUnit,System.Drawing.Imaging.EmfType,System.String) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.#ctor(System.String,System.IntPtr,System.Drawing.RectangleF,System.Drawing.Imaging.MetafileFrameUnit,System.String) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.GetMetafileHeader(System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.Metafile.GetMetafileHeader(System.IntPtr,System.Drawing.Imaging.WmfPlaceableFileHeader) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.PlayRecordCallback.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.PlayRecordCallback.Invoke(System.Drawing.Imaging.EmfPlusRecordType,System.Int32,System.Int32,System.IntPtr) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + + + CP0002 + M:System.Drawing.Imaging.PlayRecordCallback.BeginInvoke(System.Drawing.Imaging.EmfPlusRecordType,System.Int32,System.Int32,System.IntPtr,System.AsyncCallback,System.Object) + lib/net6.0/System.Drawing.Common.dll + lib/net7.0/System.Drawing.Common.dll + \ No newline at end of file diff --git a/src/libraries/System.IO.Ports/src/CompatibilitySuppressions.xml b/src/libraries/System.IO.Ports/src/CompatibilitySuppressions.xml new file mode 100644 index 0000000000000..63bae74d6ede3 --- /dev/null +++ b/src/libraries/System.IO.Ports/src/CompatibilitySuppressions.xml @@ -0,0 +1,21 @@ + + + + CP0002 + M:System.IO.Ports.SerialDataReceivedEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.IO.Ports.dll + lib/net7.0/System.IO.Ports.dll + + + CP0002 + M:System.IO.Ports.SerialErrorReceivedEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.IO.Ports.dll + lib/net7.0/System.IO.Ports.dll + + + CP0002 + M:System.IO.Ports.SerialPinChangedEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.IO.Ports.dll + lib/net7.0/System.IO.Ports.dll + + \ No newline at end of file diff --git a/src/libraries/System.Management/src/CompatibilitySuppressions.xml b/src/libraries/System.Management/src/CompatibilitySuppressions.xml new file mode 100644 index 0000000000000..75f1cb64ce530 --- /dev/null +++ b/src/libraries/System.Management/src/CompatibilitySuppressions.xml @@ -0,0 +1,45 @@ + + + + CP0002 + M:System.Management.CompletedEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Management.dll + lib/net7.0/System.Management.dll + + + CP0002 + M:System.Management.EventArrivedEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Management.dll + lib/net7.0/System.Management.dll + + + CP0002 + M:System.Management.ManagementBaseObject.op_Explicit(System.Management.ManagementBaseObject)~System.IntPtr + lib/net6.0/System.Management.dll + lib/net7.0/System.Management.dll + + + CP0002 + M:System.Management.ObjectPutEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Management.dll + lib/net7.0/System.Management.dll + + + CP0002 + M:System.Management.ObjectReadyEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Management.dll + lib/net7.0/System.Management.dll + + + CP0002 + M:System.Management.ProgressEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Management.dll + lib/net7.0/System.Management.dll + + + CP0002 + M:System.Management.StoppedEventHandler.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Management.dll + lib/net7.0/System.Management.dll + + \ No newline at end of file diff --git a/src/libraries/System.Memory/tests/MemoryMarshal/CreateReadOnlySpanFromNullTerminated.cs b/src/libraries/System.Memory/tests/MemoryMarshal/CreateReadOnlySpanFromNullTerminated.cs index 0b848524edd9d..d4f8d7977cba5 100644 --- a/src/libraries/System.Memory/tests/MemoryMarshal/CreateReadOnlySpanFromNullTerminated.cs +++ b/src/libraries/System.Memory/tests/MemoryMarshal/CreateReadOnlySpanFromNullTerminated.cs @@ -68,7 +68,7 @@ public static unsafe void CreateReadOnlySpanFromNullTerminated_Char_ExceedsMaxim char* mem; try { - mem = (char*)Marshal.AllocHGlobal((IntPtr)(sizeof(char) * (2L + int.MaxValue))); + mem = (char*)Marshal.AllocHGlobal(unchecked((nint)(sizeof(char) * (2L + int.MaxValue)))); } catch (OutOfMemoryException) { @@ -96,7 +96,7 @@ public static unsafe void CreateReadOnlySpanFromNullTerminated_Byte_ExceedsMaxim byte* mem; try { - mem = (byte*)Marshal.AllocHGlobal((IntPtr)(2L + int.MaxValue)); + mem = (byte*)Marshal.AllocHGlobal(unchecked((nint)(2L + int.MaxValue))); } catch (OutOfMemoryException) { diff --git a/src/libraries/System.Memory/tests/ReadOnlySpan/Overflow.cs b/src/libraries/System.Memory/tests/ReadOnlySpan/Overflow.cs index d5c40ffbf62eb..0571c9d55299d 100644 --- a/src/libraries/System.Memory/tests/ReadOnlySpan/Overflow.cs +++ b/src/libraries/System.Memory/tests/ReadOnlySpan/Overflow.cs @@ -30,7 +30,7 @@ public static void IndexOverflow() unsafe { - if (!AllocationHelper.TryAllocNative((IntPtr)ThreeGiB, out IntPtr memBlock)) + if (!AllocationHelper.TryAllocNative(unchecked((nint)ThreeGiB), out IntPtr memBlock)) return; // It's not implausible to believe that a 3gb allocation will fail - if so, skip this test to avoid unnecessary test flakiness. try diff --git a/src/libraries/System.Memory/tests/Span/Clear.cs b/src/libraries/System.Memory/tests/Span/Clear.cs index ee9a8ff469ac8..205ec76d5a483 100644 --- a/src/libraries/System.Memory/tests/Span/Clear.cs +++ b/src/libraries/System.Memory/tests/Span/Clear.cs @@ -263,7 +263,7 @@ static unsafe void ClearLongerThanUintMaxValueBytes() if (sizeof(IntPtr) == sizeof(long)) { // Arrange - IntPtr bytes = (IntPtr)(((long)int.MaxValue) * sizeof(int)); + nint bytes = unchecked((nint)(((long)int.MaxValue) * sizeof(int))); int length = (int)(((long)bytes) / sizeof(int)); if (!AllocationHelper.TryAllocNative(bytes, out IntPtr memory)) diff --git a/src/libraries/System.Memory/tests/Span/Overflow.cs b/src/libraries/System.Memory/tests/Span/Overflow.cs index aa9e6d4265d27..92ce3d11f0650 100644 --- a/src/libraries/System.Memory/tests/Span/Overflow.cs +++ b/src/libraries/System.Memory/tests/Span/Overflow.cs @@ -29,7 +29,7 @@ public static void IndexOverflow() // unsafe { - if (!AllocationHelper.TryAllocNative((IntPtr)ThreeGiB, out IntPtr memBlock)) + if (!AllocationHelper.TryAllocNative(unchecked((nint)ThreeGiB), out IntPtr memBlock)) { Console.WriteLine($"Span.Overflow test {nameof(IndexOverflow)} skipped (could not alloc memory)."); return; // It's not implausible to believe that a 3gb allocation will fail - if so, skip this test to avoid unnecessary test flakiness. @@ -78,7 +78,7 @@ public static void SliceStartInt32Overflow() { unsafe { - if (!AllocationHelper.TryAllocNative((IntPtr)ThreeGiB, out IntPtr memory)) + if (!AllocationHelper.TryAllocNative(unchecked((nint)ThreeGiB), out IntPtr memory)) { Console.WriteLine($"Span.Overflow test {nameof(SliceStartInt32Overflow)} skipped (could not alloc memory)."); return; @@ -122,7 +122,7 @@ public static void ReadOnlySliceStartInt32Overflow() { unsafe { - if (!AllocationHelper.TryAllocNative((IntPtr)ThreeGiB, out IntPtr memory)) + if (!AllocationHelper.TryAllocNative(unchecked((nint)ThreeGiB), out IntPtr memory)) { Console.WriteLine($"Span.Overflow test {nameof(ReadOnlySliceStartInt32Overflow)} skipped (could not alloc memory)."); return; diff --git a/src/libraries/System.Private.CoreLib/src/System/IntPtr.cs b/src/libraries/System.Private.CoreLib/src/System/IntPtr.cs index 6050df99b6fee..d777a0565aef2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IntPtr.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IntPtr.cs @@ -11,7 +11,6 @@ using System.Runtime.Versioning; #pragma warning disable SA1121 // explicitly using type aliases instead of built-in types -#pragma warning disable CA1066 // Implement IEquatable when overriding Object.Equals #if TARGET_64BIT using nint_t = System.Int64; @@ -34,24 +33,24 @@ public readonly struct IntPtr IMinMaxValue, ISignedNumber { - private readonly unsafe void* _value; // Do not rename (binary serialization) + private readonly nint _value; [Intrinsic] - public static readonly IntPtr Zero; + public static readonly nint Zero; [NonVersionable] - public unsafe IntPtr(int value) + public IntPtr(int value) { - _value = (void*)value; + _value = value; } [NonVersionable] - public unsafe IntPtr(long value) + public IntPtr(long value) { #if TARGET_64BIT - _value = (void*)value; + _value = (nint)value; #else - _value = (void*)checked((int)value); + _value = checked((nint)value); #endif } @@ -59,111 +58,100 @@ public unsafe IntPtr(long value) [NonVersionable] public unsafe IntPtr(void* value) { - _value = value; + _value = (nint)value; } - private unsafe IntPtr(SerializationInfo info, StreamingContext context) + private IntPtr(SerializationInfo info, StreamingContext context) { - long l = info.GetInt64("value"); + long value = info.GetInt64("value"); - if (Size == 4 && (l > int.MaxValue || l < int.MinValue)) +#if TARGET_32BIT + if ((value > int.MaxValue) || (value < int.MinValue)) + { throw new ArgumentException(SR.Serialization_InvalidPtrValue); + } +#endif - _value = (void*)l; + _value = (nint)value; } - unsafe void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { ArgumentNullException.ThrowIfNull(info); - info.AddValue("value", ToInt64()); + long value = _value; + info.AddValue("value", value); } - public override unsafe bool Equals([NotNullWhen(true)] object? obj) => - obj is IntPtr other && - _value == other._value; + public override bool Equals([NotNullWhen(true)] object? obj) => (obj is nint other) && Equals(other); - public override unsafe int GetHashCode() + public override int GetHashCode() { #if TARGET_64BIT - long l = (long)_value; - return unchecked((int)l) ^ (int)(l >> 32); + long value = _value; + return value.GetHashCode(); #else - return unchecked((int)_value); + return (int)_value; #endif } [NonVersionable] - public unsafe int ToInt32() + public int ToInt32() { #if TARGET_64BIT - long l = (long)_value; - return checked((int)l); + return checked((int)_value); #else return (int)_value; #endif } [NonVersionable] - public unsafe long ToInt64() => - (nint)_value; + public long ToInt64() => _value; [NonVersionable] - public static unsafe explicit operator IntPtr(int value) => - new IntPtr(value); + public static explicit operator nint(int value) => value; [NonVersionable] - public static unsafe explicit operator IntPtr(long value) => - new IntPtr(value); + public static explicit operator nint(long value) => checked((nint)value); [CLSCompliant(false)] [NonVersionable] - public static unsafe explicit operator IntPtr(void* value) => - new IntPtr(value); + public static unsafe explicit operator nint(void* value) => (nint)value; [CLSCompliant(false)] [NonVersionable] - public static unsafe explicit operator void*(IntPtr value) => - value._value; + public static unsafe explicit operator void*(nint value) => (void*)value; [NonVersionable] - public static unsafe explicit operator int(IntPtr value) + public static explicit operator int(nint value) { #if TARGET_64BIT - long l = (long)value._value; - return checked((int)l); + return checked((int)value); #else - return (int)value._value; + return (int)value; #endif } [NonVersionable] - public static unsafe explicit operator long(IntPtr value) => - (nint)value._value; + public static explicit operator long(nint value) => value; [NonVersionable] - public static unsafe bool operator ==(IntPtr value1, IntPtr value2) => - value1._value == value2._value; + public static bool operator ==(nint value1, nint value2) => value1 == value2; [NonVersionable] - public static unsafe bool operator !=(IntPtr value1, IntPtr value2) => - value1._value != value2._value; + public static bool operator !=(nint value1, nint value2) => value1 != value2; [NonVersionable] - public static IntPtr Add(IntPtr pointer, int offset) => - pointer + offset; + public static nint Add(nint pointer, int offset) => pointer + offset; [NonVersionable] - public static unsafe IntPtr operator +(IntPtr pointer, int offset) => - (nint)pointer._value + offset; + public static nint operator +(nint pointer, int offset) => pointer + offset; [NonVersionable] - public static IntPtr Subtract(IntPtr pointer, int offset) => - pointer - offset; + public static nint Subtract(nint pointer, int offset) => pointer - offset; [NonVersionable] - public static unsafe IntPtr operator -(IntPtr pointer, int offset) => - (nint)pointer._value - offset; + public static nint operator -(nint pointer, int offset) => pointer - offset; public static int Size { @@ -173,93 +161,95 @@ public static int Size [CLSCompliant(false)] [NonVersionable] - public unsafe void* ToPointer() => _value; + public unsafe void* ToPointer() => (void*)_value; /// - public static IntPtr MaxValue + public static nint MaxValue { [NonVersionable] - get => (IntPtr)nint_t.MaxValue; + get => unchecked((nint)nint_t.MaxValue); } /// - public static IntPtr MinValue + public static nint MinValue { [NonVersionable] - get => (IntPtr)nint_t.MinValue; + get => unchecked((nint)nint_t.MinValue); } - // Don't just delegate to nint_t.CompareTo as it needs to throw when not IntPtr - public unsafe int CompareTo(object? value) + public int CompareTo(object? value) { - if (value is null) + if (value is nint other) { - return 1; + return CompareTo(other); } - if (value is nint i) + else if (value is null) { - if ((nint)_value < i) return -1; - if ((nint)_value > i) return 1; - return 0; + return 1; } throw new ArgumentException(SR.Arg_MustBeIntPtr); } - public unsafe int CompareTo(IntPtr value) => ((nint_t)_value).CompareTo((nint_t)value); + public int CompareTo(nint value) + { + if (_value < value) return -1; + if (_value > value) return 1; + return 0; + } [NonVersionable] - public unsafe bool Equals(IntPtr other) => (nint_t)_value == (nint_t)other; + public bool Equals(nint other) => _value == other; - public unsafe override string ToString() => ((nint_t)_value).ToString(); - public unsafe string ToString([StringSyntax(StringSyntaxAttribute.NumericFormat)] string? format) => ((nint_t)_value).ToString(format); - public unsafe string ToString(IFormatProvider? provider) => ((nint_t)_value).ToString(provider); - public unsafe string ToString([StringSyntax(StringSyntaxAttribute.NumericFormat)] string? format, IFormatProvider? provider) => ((nint_t)_value).ToString(format, provider); + public override string ToString() => ((nint_t)_value).ToString(); + public string ToString([StringSyntax(StringSyntaxAttribute.NumericFormat)] string? format) => ((nint_t)_value).ToString(format); + public string ToString(IFormatProvider? provider) => ((nint_t)_value).ToString(provider); + public string ToString([StringSyntax(StringSyntaxAttribute.NumericFormat)] string? format, IFormatProvider? provider) => ((nint_t)_value).ToString(format, provider); - public unsafe bool TryFormat(Span destination, out int charsWritten, [StringSyntax(StringSyntaxAttribute.NumericFormat)] ReadOnlySpan format = default, IFormatProvider? provider = null) => + public bool TryFormat(Span destination, out int charsWritten, [StringSyntax(StringSyntaxAttribute.NumericFormat)] ReadOnlySpan format = default, IFormatProvider? provider = null) => ((nint_t)_value).TryFormat(destination, out charsWritten, format, provider); - public static IntPtr Parse(string s) => (IntPtr)nint_t.Parse(s); - public static IntPtr Parse(string s, NumberStyles style) => (IntPtr)nint_t.Parse(s, style); - public static IntPtr Parse(string s, IFormatProvider? provider) => (IntPtr)nint_t.Parse(s, provider); - public static IntPtr Parse(string s, NumberStyles style, IFormatProvider? provider) => (IntPtr)nint_t.Parse(s, style, provider); - public static IntPtr Parse(ReadOnlySpan s, IFormatProvider? provider) => (IntPtr)nint_t.Parse(s, provider); - public static IntPtr Parse(ReadOnlySpan s, NumberStyles style = NumberStyles.Integer, IFormatProvider? provider = null) => (IntPtr)nint_t.Parse(s, style, provider); + public static nint Parse(string s) => (nint)nint_t.Parse(s); + public static nint Parse(string s, NumberStyles style) => (nint)nint_t.Parse(s, style); + public static nint Parse(string s, IFormatProvider? provider) => (nint)nint_t.Parse(s, provider); + public static nint Parse(string s, NumberStyles style, IFormatProvider? provider) => (nint)nint_t.Parse(s, style, provider); + public static nint Parse(ReadOnlySpan s, IFormatProvider? provider) => (nint)nint_t.Parse(s, provider); + public static nint Parse(ReadOnlySpan s, NumberStyles style = NumberStyles.Integer, IFormatProvider? provider = null) => (nint)nint_t.Parse(s, style, provider); - public static bool TryParse([NotNullWhen(true)] string? s, out IntPtr result) + public static bool TryParse([NotNullWhen(true)] string? s, out nint result) { Unsafe.SkipInit(out result); - return nint_t.TryParse(s, out Unsafe.As(ref result)); + return nint_t.TryParse(s, out Unsafe.As(ref result)); } - public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out IntPtr result) + public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out nint result) { Unsafe.SkipInit(out result); - return nint_t.TryParse(s, provider, out Unsafe.As(ref result)); + return nint_t.TryParse(s, provider, out Unsafe.As(ref result)); } - public static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out IntPtr result) + public static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out nint result) { Unsafe.SkipInit(out result); - return nint_t.TryParse(s, style, provider, out Unsafe.As(ref result)); + return nint_t.TryParse(s, style, provider, out Unsafe.As(ref result)); } - public static bool TryParse(ReadOnlySpan s, out IntPtr result) + public static bool TryParse(ReadOnlySpan s, out nint result) { Unsafe.SkipInit(out result); - return nint_t.TryParse(s, out Unsafe.As(ref result)); + return nint_t.TryParse(s, out Unsafe.As(ref result)); } - public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out IntPtr result) + public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out nint result) { Unsafe.SkipInit(out result); - return nint_t.TryParse(s, provider, out Unsafe.As(ref result)); + return nint_t.TryParse(s, provider, out Unsafe.As(ref result)); } - public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out IntPtr result) + public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out nint result) { Unsafe.SkipInit(out result); - return nint_t.TryParse(s, style, provider, out Unsafe.As(ref result)); + return nint_t.TryParse(s, style, provider, out Unsafe.As(ref result)); } // @@ -302,13 +292,13 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro public static nint TrailingZeroCount(nint value) => BitOperations.TrailingZeroCount(value); /// - unsafe int IBinaryInteger.GetShortestBitLength() + int IBinaryInteger.GetShortestBitLength() { - nint value = (nint)(_value); + nint value = _value; if (value >= 0) { - return (sizeof(nint_t) * 8) - BitOperations.LeadingZeroCount((nuint)(value)); + return (sizeof(nint_t) * 8) - BitOperations.LeadingZeroCount((nuint)value); } else { @@ -320,11 +310,16 @@ unsafe int IBinaryInteger.GetShortestBitLength() int IBinaryInteger.GetByteCount() => sizeof(nint_t); /// - unsafe bool IBinaryInteger.TryWriteBigEndian(Span destination, out int bytesWritten) + bool IBinaryInteger.TryWriteBigEndian(Span destination, out int bytesWritten) { if (destination.Length >= sizeof(nint_t)) { - nint_t value = BitConverter.IsLittleEndian ? BinaryPrimitives.ReverseEndianness((nint_t)(_value)) : (nint_t)(_value); + nint_t value = (nint_t)_value; + + if (BitConverter.IsLittleEndian) + { + value = BinaryPrimitives.ReverseEndianness(value); + } Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); bytesWritten = sizeof(nint_t); @@ -338,11 +333,16 @@ unsafe bool IBinaryInteger.TryWriteBigEndian(Span destination, out i } /// - unsafe bool IBinaryInteger.TryWriteLittleEndian(Span destination, out int bytesWritten) + bool IBinaryInteger.TryWriteLittleEndian(Span destination, out int bytesWritten) { if (destination.Length >= sizeof(nint_t)) { - nint_t value = BitConverter.IsLittleEndian ? (nint_t)(_value) : BinaryPrimitives.ReverseEndianness((nint_t)(_value)); + nint_t value = (nint_t)_value; + + if (!BitConverter.IsLittleEndian) + { + value = BinaryPrimitives.ReverseEndianness(value); + } Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); bytesWritten = sizeof(nint_t); diff --git a/src/libraries/System.Private.CoreLib/src/System/UIntPtr.cs b/src/libraries/System.Private.CoreLib/src/System/UIntPtr.cs index 0554ef8b90815..a3e7404e73395 100644 --- a/src/libraries/System.Private.CoreLib/src/System/UIntPtr.cs +++ b/src/libraries/System.Private.CoreLib/src/System/UIntPtr.cs @@ -11,7 +11,6 @@ using System.Runtime.Versioning; #pragma warning disable SA1121 // explicitly using type aliases instead of built-in types -#pragma warning disable CA1066 // Implement IEquatable when overriding Object.Equals #if TARGET_64BIT using nuint_t = System.UInt64; @@ -35,71 +34,69 @@ public readonly struct UIntPtr IMinMaxValue, IUnsignedNumber { - private readonly unsafe void* _value; // Do not rename (binary serialization) + private readonly nuint _value; [Intrinsic] - public static readonly UIntPtr Zero; + public static readonly nuint Zero; [NonVersionable] - public unsafe UIntPtr(uint value) + public UIntPtr(uint value) { - _value = (void*)value; + _value = value; } [NonVersionable] - public unsafe UIntPtr(ulong value) + public UIntPtr(ulong value) { #if TARGET_64BIT - _value = (void*)value; + _value = (nuint)value; #else - _value = (void*)checked((uint)value); + _value = checked((nuint)value); #endif } [NonVersionable] public unsafe UIntPtr(void* value) { - _value = value; + _value = (nuint)value; } - private unsafe UIntPtr(SerializationInfo info, StreamingContext context) + private UIntPtr(SerializationInfo info, StreamingContext context) { - ulong l = info.GetUInt64("value"); + ulong value = info.GetUInt64("value"); - if (Size == 4 && l > uint.MaxValue) +#if TARGET_32BIT + if (value > uint.MaxValue) + { throw new ArgumentException(SR.Serialization_InvalidPtrValue); + } +#endif - _value = (void*)l; + _value = (nuint)value; } void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { ArgumentNullException.ThrowIfNull(info); - info.AddValue("value", ToUInt64()); + ulong value = _value; + info.AddValue("value", value); } - public override unsafe bool Equals([NotNullWhen(true)] object? obj) - { - if (obj is UIntPtr) - { - return _value == ((UIntPtr)obj)._value; - } - return false; - } + public override bool Equals([NotNullWhen(true)] object? obj) => (obj is nuint other) && Equals(other); - public override unsafe int GetHashCode() + public override int GetHashCode() { #if TARGET_64BIT - ulong l = (ulong)_value; - return unchecked((int)l) ^ (int)(l >> 32); + ulong value = _value; + return value.GetHashCode(); #else - return unchecked((int)_value); + return (int)_value; #endif } [NonVersionable] - public unsafe uint ToUInt32() + public uint ToUInt32() { #if TARGET_64BIT return checked((uint)_value); @@ -109,59 +106,50 @@ public unsafe uint ToUInt32() } [NonVersionable] - public unsafe ulong ToUInt64() => (ulong)_value; + public ulong ToUInt64() => _value; [NonVersionable] - public static explicit operator UIntPtr(uint value) => - new UIntPtr(value); + public static explicit operator nuint(uint value) => value; [NonVersionable] - public static explicit operator UIntPtr(ulong value) => - new UIntPtr(value); + public static explicit operator nuint(ulong value) => checked((nuint)value); [NonVersionable] - public static unsafe explicit operator UIntPtr(void* value) => - new UIntPtr(value); + public static unsafe explicit operator nuint(void* value) => (nuint)value; [NonVersionable] - public static unsafe explicit operator void*(UIntPtr value) => - value._value; + public static unsafe explicit operator void*(nuint value) => (void*)value; [NonVersionable] - public static unsafe explicit operator uint(UIntPtr value) => + public static explicit operator uint(nuint value) + { #if TARGET_64BIT - checked((uint)value._value); + return checked((uint)value); #else - (uint)value._value; + return (uint)value; #endif + } [NonVersionable] - public static unsafe explicit operator ulong(UIntPtr value) => - (ulong)value._value; + public static explicit operator ulong(nuint value) => value; [NonVersionable] - public static unsafe bool operator ==(UIntPtr value1, UIntPtr value2) => - value1._value == value2._value; + public static bool operator ==(nuint value1, nuint value2) => value1 == value2; [NonVersionable] - public static unsafe bool operator !=(UIntPtr value1, UIntPtr value2) => - value1._value != value2._value; + public static bool operator !=(nuint value1, nuint value2) => value1 != value2; [NonVersionable] - public static UIntPtr Add(UIntPtr pointer, int offset) => - pointer + offset; + public static nuint Add(nuint pointer, int offset) => pointer + (nuint)offset; [NonVersionable] - public static unsafe UIntPtr operator +(UIntPtr pointer, int offset) => - (nuint)pointer._value + (nuint)offset; + public static nuint operator +(nuint pointer, int offset) => pointer + (nuint)offset; [NonVersionable] - public static UIntPtr Subtract(UIntPtr pointer, int offset) => - pointer - offset; + public static nuint Subtract(nuint pointer, int offset) => pointer - (nuint)offset; [NonVersionable] - public static unsafe UIntPtr operator -(UIntPtr pointer, int offset) => - (nuint)pointer._value - (nuint)offset; + public static nuint operator -(nuint pointer, int offset) => pointer - (nuint)offset; public static int Size { @@ -170,92 +158,95 @@ public static int Size } [NonVersionable] - public unsafe void* ToPointer() => _value; + public unsafe void* ToPointer() => (void*)_value; /// - public static UIntPtr MaxValue + public static nuint MaxValue { [NonVersionable] - get => (UIntPtr)nuint_t.MaxValue; + get => unchecked((nuint)nuint_t.MaxValue); } /// - public static UIntPtr MinValue + public static nuint MinValue { [NonVersionable] - get => (UIntPtr)nuint_t.MinValue; + get => unchecked((nuint)nuint_t.MinValue); } - public unsafe int CompareTo(object? value) + public int CompareTo(object? value) { - if (value is null) + if (value is nuint other) { - return 1; + return CompareTo(other); } - if (value is nuint i) + else if (value is null) { - if ((nuint)_value < i) return -1; - if ((nuint)_value > i) return 1; - return 0; + return 1; } throw new ArgumentException(SR.Arg_MustBeUIntPtr); } - public unsafe int CompareTo(UIntPtr value) => ((nuint_t)_value).CompareTo((nuint_t)value); + public int CompareTo(nuint value) + { + if (_value < value) return -1; + if (_value > value) return 1; + return 0; + } [NonVersionable] - public unsafe bool Equals(UIntPtr other) => (nuint)_value == (nuint)other; + public bool Equals(nuint other) => _value == other; - public unsafe override string ToString() => ((nuint_t)_value).ToString(); - public unsafe string ToString([StringSyntax(StringSyntaxAttribute.NumericFormat)] string? format) => ((nuint_t)_value).ToString(format); - public unsafe string ToString(IFormatProvider? provider) => ((nuint_t)_value).ToString(provider); - public unsafe string ToString([StringSyntax(StringSyntaxAttribute.NumericFormat)] string? format, IFormatProvider? provider) => ((nuint_t)_value).ToString(format, provider); + public override string ToString() => ((nuint_t)_value).ToString(); + public string ToString([StringSyntax(StringSyntaxAttribute.NumericFormat)] string? format) => ((nuint_t)_value).ToString(format); + public string ToString(IFormatProvider? provider) => ((nuint_t)_value).ToString(provider); + public string ToString([StringSyntax(StringSyntaxAttribute.NumericFormat)] string? format, IFormatProvider? provider) => ((nuint_t)_value).ToString(format, provider); - public unsafe bool TryFormat(Span destination, out int charsWritten, [StringSyntax(StringSyntaxAttribute.NumericFormat)] ReadOnlySpan format = default, IFormatProvider? provider = null) => + public bool TryFormat(Span destination, out int charsWritten, [StringSyntax(StringSyntaxAttribute.NumericFormat)] ReadOnlySpan format = default, IFormatProvider? provider = null) => ((nuint_t)_value).TryFormat(destination, out charsWritten, format, provider); - public static UIntPtr Parse(string s) => (UIntPtr)nuint_t.Parse(s); - public static UIntPtr Parse(string s, NumberStyles style) => (UIntPtr)nuint_t.Parse(s, style); - public static UIntPtr Parse(string s, IFormatProvider? provider) => (UIntPtr)nuint_t.Parse(s, provider); - public static UIntPtr Parse(string s, NumberStyles style, IFormatProvider? provider) => (UIntPtr)nuint_t.Parse(s, style, provider); - public static UIntPtr Parse(ReadOnlySpan s, IFormatProvider? provider) => (UIntPtr)nuint_t.Parse(s, provider); - public static UIntPtr Parse(ReadOnlySpan s, NumberStyles style = NumberStyles.Integer, IFormatProvider? provider = null) => (UIntPtr)nuint_t.Parse(s, style, provider); + public static nuint Parse(string s) => (nuint)nuint_t.Parse(s); + public static nuint Parse(string s, NumberStyles style) => (nuint)nuint_t.Parse(s, style); + public static nuint Parse(string s, IFormatProvider? provider) => (nuint)nuint_t.Parse(s, provider); + public static nuint Parse(string s, NumberStyles style, IFormatProvider? provider) => (nuint)nuint_t.Parse(s, style, provider); + public static nuint Parse(ReadOnlySpan s, IFormatProvider? provider) => (nuint)nuint_t.Parse(s, provider); + public static nuint Parse(ReadOnlySpan s, NumberStyles style = NumberStyles.Integer, IFormatProvider? provider = null) => (nuint)nuint_t.Parse(s, style, provider); - public static bool TryParse([NotNullWhen(true)] string? s, out UIntPtr result) + public static bool TryParse([NotNullWhen(true)] string? s, out nuint result) { Unsafe.SkipInit(out result); - return nuint_t.TryParse(s, out Unsafe.As(ref result)); + return nuint_t.TryParse(s, out Unsafe.As(ref result)); } - public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out UIntPtr result) + public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out nuint result) { Unsafe.SkipInit(out result); - return nuint_t.TryParse(s, provider, out Unsafe.As(ref result)); + return nuint_t.TryParse(s, provider, out Unsafe.As(ref result)); } - public static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out UIntPtr result) + public static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out nuint result) { Unsafe.SkipInit(out result); - return nuint_t.TryParse(s, style, provider, out Unsafe.As(ref result)); + return nuint_t.TryParse(s, style, provider, out Unsafe.As(ref result)); } - public static bool TryParse(ReadOnlySpan s, out UIntPtr result) + public static bool TryParse(ReadOnlySpan s, out nuint result) { Unsafe.SkipInit(out result); - return nuint_t.TryParse(s, out Unsafe.As(ref result)); + return nuint_t.TryParse(s, out Unsafe.As(ref result)); } - public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out UIntPtr result) + public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out nuint result) { Unsafe.SkipInit(out result); - return nuint_t.TryParse(s, provider, out Unsafe.As(ref result)); + return nuint_t.TryParse(s, provider, out Unsafe.As(ref result)); } - public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out UIntPtr result) + public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out nuint result) { Unsafe.SkipInit(out result); - return nuint_t.TryParse(s, style, provider, out Unsafe.As(ref result)); + return nuint_t.TryParse(s, style, provider, out Unsafe.As(ref result)); } // @@ -263,10 +254,10 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro // /// - static nuint IAdditionOperators.operator +(nuint left, nuint right) => (nuint)(left + right); + static nuint IAdditionOperators.operator +(nuint left, nuint right) => left + right; /// - static nuint IAdditionOperators.operator checked +(nuint left, nuint right) => checked((nuint)(left + right)); + static nuint IAdditionOperators.operator checked +(nuint left, nuint right) => checked(left + right); // // IAdditiveIdentity @@ -298,17 +289,22 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro public static nuint TrailingZeroCount(nuint value) => (nuint)BitOperations.TrailingZeroCount(value); /// - unsafe int IBinaryInteger.GetShortestBitLength() => (sizeof(nuint_t) * 8) - BitOperations.LeadingZeroCount((nuint)(_value)); + int IBinaryInteger.GetShortestBitLength() => (sizeof(nuint_t) * 8) - BitOperations.LeadingZeroCount(_value); /// int IBinaryInteger.GetByteCount() => sizeof(nuint_t); /// - unsafe bool IBinaryInteger.TryWriteBigEndian(Span destination, out int bytesWritten) + bool IBinaryInteger.TryWriteBigEndian(Span destination, out int bytesWritten) { if (destination.Length >= sizeof(nuint_t)) { - nuint_t value = BitConverter.IsLittleEndian ? BinaryPrimitives.ReverseEndianness((nuint_t)(_value)) : (nuint_t)(_value); + nuint_t value = (nuint_t)_value; + + if (BitConverter.IsLittleEndian) + { + value = BinaryPrimitives.ReverseEndianness(value); + } Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); bytesWritten = sizeof(nuint_t); @@ -322,11 +318,16 @@ unsafe bool IBinaryInteger.TryWriteBigEndian(Span destination, out } /// - unsafe bool IBinaryInteger.TryWriteLittleEndian(Span destination, out int bytesWritten) + bool IBinaryInteger.TryWriteLittleEndian(Span destination, out int bytesWritten) { if (destination.Length >= sizeof(nuint_t)) { - nuint_t value = BitConverter.IsLittleEndian ? (nuint_t)(_value) : BinaryPrimitives.ReverseEndianness((nuint_t)(_value)); + nuint_t value = (nuint_t)_value; + + if (!BitConverter.IsLittleEndian) + { + value = BinaryPrimitives.ReverseEndianness(value); + } Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); bytesWritten = sizeof(nuint_t); diff --git a/src/libraries/System.Runtime.Caching/src/CompatibilitySuppressions.xml b/src/libraries/System.Runtime.Caching/src/CompatibilitySuppressions.xml new file mode 100644 index 0000000000000..531ad4f0383c7 --- /dev/null +++ b/src/libraries/System.Runtime.Caching/src/CompatibilitySuppressions.xml @@ -0,0 +1,21 @@ + + + + CP0002 + M:System.Runtime.Caching.CacheEntryRemovedCallback.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Runtime.Caching.dll + lib/net7.0/System.Runtime.Caching.dll + + + CP0002 + M:System.Runtime.Caching.CacheEntryUpdateCallback.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Runtime.Caching.dll + lib/net7.0/System.Runtime.Caching.dll + + + CP0002 + M:System.Runtime.Caching.OnChangedCallback.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.Runtime.Caching.dll + lib/net7.0/System.Runtime.Caching.dll + + \ No newline at end of file diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 63dcc1d0b5cb9..bcfaa53f8fa3f 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -3469,14 +3469,14 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep } public readonly partial struct IntPtr : System.IComparable, System.IComparable, System.IEquatable, System.IFormattable, System.IParsable, System.ISpanFormattable, System.ISpanParsable, System.Numerics.IAdditionOperators, System.Numerics.IAdditiveIdentity, System.Numerics.IBinaryInteger, System.Numerics.IBinaryNumber, System.Numerics.IBitwiseOperators, System.Numerics.IComparisonOperators, System.Numerics.IDecrementOperators, System.Numerics.IDivisionOperators, System.Numerics.IEqualityOperators, System.Numerics.IIncrementOperators, System.Numerics.IMinMaxValue, System.Numerics.IModulusOperators, System.Numerics.IMultiplicativeIdentity, System.Numerics.IMultiplyOperators, System.Numerics.INumber, System.Numerics.INumberBase, System.Numerics.IShiftOperators, System.Numerics.ISignedNumber, System.Numerics.ISubtractionOperators, System.Numerics.IUnaryNegationOperators, System.Numerics.IUnaryPlusOperators, System.Runtime.Serialization.ISerializable { - private readonly int _dummyPrimitive; - public static readonly System.IntPtr Zero; + private readonly nint _dummyPrimitive; + public static readonly nint Zero; public IntPtr(int value) { throw null; } public IntPtr(long value) { throw null; } [System.CLSCompliantAttribute(false)] public unsafe IntPtr(void* value) { throw null; } - public static System.IntPtr MaxValue { get { throw null; } } - public static System.IntPtr MinValue { get { throw null; } } + public static nint MaxValue { get { throw null; } } + public static nint MinValue { get { throw null; } } public static int Size { get { throw null; } } static nint System.Numerics.IAdditiveIdentity.AdditiveIdentity { get { throw null; } } static nint System.Numerics.IMinMaxValue.MaxValue { get { throw null; } } @@ -3486,16 +3486,16 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep static nint System.Numerics.INumberBase.Zero { get { throw null; } } static nint System.Numerics.ISignedNumber.NegativeOne { get { throw null; } } public static nint Abs(nint value) { throw null; } - public static System.IntPtr Add(System.IntPtr pointer, int offset) { throw null; } + public static nint Add(nint pointer, int offset) { throw null; } public static nint Clamp(nint value, nint min, nint max) { throw null; } - public int CompareTo(System.IntPtr value) { throw null; } + public int CompareTo(nint value) { throw null; } public int CompareTo(object? value) { throw null; } public static nint CopySign(nint value, nint sign) { throw null; } public static nint CreateChecked(TOther value) where TOther : System.Numerics.INumberBase { throw null; } public static nint CreateSaturating(TOther value) where TOther : System.Numerics.INumberBase { throw null; } public static nint CreateTruncating(TOther value) where TOther : System.Numerics.INumberBase { throw null; } public static (nint Quotient, nint Remainder) DivRem(nint left, nint right) { throw null; } - public bool Equals(System.IntPtr other) { throw null; } + public bool Equals(nint other) { throw null; } public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } public override int GetHashCode() { throw null; } public static bool IsNegative(nint value) { throw null; } @@ -3506,29 +3506,29 @@ public InsufficientMemoryException(string? message, System.Exception? innerExcep public static nint MaxMagnitude(nint x, nint y) { throw null; } public static nint Min(nint x, nint y) { throw null; } public static nint MinMagnitude(nint x, nint y) { throw null; } - public static System.IntPtr operator +(System.IntPtr pointer, int offset) { throw null; } - public static bool operator ==(System.IntPtr value1, System.IntPtr value2) { throw null; } - public static explicit operator System.IntPtr (int value) { throw null; } - public static explicit operator System.IntPtr (long value) { throw null; } - public static explicit operator int (System.IntPtr value) { throw null; } - public static explicit operator long (System.IntPtr value) { throw null; } - [System.CLSCompliantAttribute(false)] - public unsafe static explicit operator void* (System.IntPtr value) { throw null; } - [System.CLSCompliantAttribute(false)] - public unsafe static explicit operator System.IntPtr (void* value) { throw null; } - public static bool operator !=(System.IntPtr value1, System.IntPtr value2) { throw null; } - public static System.IntPtr operator -(System.IntPtr pointer, int offset) { throw null; } - public static System.IntPtr Parse(System.ReadOnlySpan s, System.Globalization.NumberStyles style = System.Globalization.NumberStyles.Integer, System.IFormatProvider? provider = null) { throw null; } - public static System.IntPtr Parse(System.ReadOnlySpan s, System.IFormatProvider? provider) { throw null; } - public static System.IntPtr Parse(string s) { throw null; } - public static System.IntPtr Parse(string s, System.Globalization.NumberStyles style) { throw null; } - public static System.IntPtr Parse(string s, System.Globalization.NumberStyles style, System.IFormatProvider? provider) { throw null; } - public static System.IntPtr Parse(string s, System.IFormatProvider? provider) { throw null; } + public static nint operator +(nint pointer, int offset) { throw null; } + public static bool operator ==(nint value1, nint value2) { throw null; } + public static explicit operator nint (int value) { throw null; } + public static explicit operator nint (long value) { throw null; } + public static explicit operator int (nint value) { throw null; } + public static explicit operator long (nint value) { throw null; } + [System.CLSCompliantAttribute(false)] + public unsafe static explicit operator void* (nint value) { throw null; } + [System.CLSCompliantAttribute(false)] + public unsafe static explicit operator nint (void* value) { throw null; } + public static bool operator !=(nint value1, nint value2) { throw null; } + public static nint operator -(nint pointer, int offset) { throw null; } + public static nint Parse(System.ReadOnlySpan s, System.Globalization.NumberStyles style = System.Globalization.NumberStyles.Integer, System.IFormatProvider? provider = null) { throw null; } + public static nint Parse(System.ReadOnlySpan s, System.IFormatProvider? provider) { throw null; } + public static nint Parse(string s) { throw null; } + public static nint Parse(string s, System.Globalization.NumberStyles style) { throw null; } + public static nint Parse(string s, System.Globalization.NumberStyles style, System.IFormatProvider? provider) { throw null; } + public static nint Parse(string s, System.IFormatProvider? provider) { throw null; } public static nint PopCount(nint value) { throw null; } public static nint RotateLeft(nint value, int rotateAmount) { throw null; } public static nint RotateRight(nint value, int rotateAmount) { throw null; } public static int Sign(nint value) { throw null; } - public static System.IntPtr Subtract(System.IntPtr pointer, int offset) { throw null; } + public static nint Subtract(nint pointer, int offset) { throw null; } static nint System.Numerics.IAdditionOperators.operator +(nint left, nint right) { throw null; } static nint System.Numerics.IAdditionOperators.operator checked +(nint left, nint right) { throw null; } int System.Numerics.IBinaryInteger.GetByteCount() { throw null; } @@ -3583,12 +3583,12 @@ void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Ser public static nint TrailingZeroCount(nint value) { throw null; } public static bool TryCreate(TOther value, out nint result) where TOther : System.Numerics.INumberBase { throw null; } public bool TryFormat(System.Span destination, out int charsWritten, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] System.ReadOnlySpan format = default(System.ReadOnlySpan), System.IFormatProvider? provider = null) { throw null; } - public static bool TryParse(System.ReadOnlySpan s, System.Globalization.NumberStyles style, System.IFormatProvider? provider, out System.IntPtr result) { throw null; } - public static bool TryParse(System.ReadOnlySpan s, System.IFormatProvider? provider, out System.IntPtr result) { throw null; } - public static bool TryParse(System.ReadOnlySpan s, out System.IntPtr result) { throw null; } - public static bool TryParse([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? s, System.Globalization.NumberStyles style, System.IFormatProvider? provider, out System.IntPtr result) { throw null; } - public static bool TryParse([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? s, System.IFormatProvider? provider, out System.IntPtr result) { throw null; } - public static bool TryParse([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? s, out System.IntPtr result) { throw null; } + public static bool TryParse(System.ReadOnlySpan s, System.Globalization.NumberStyles style, System.IFormatProvider? provider, out nint result) { throw null; } + public static bool TryParse(System.ReadOnlySpan s, System.IFormatProvider? provider, out nint result) { throw null; } + public static bool TryParse(System.ReadOnlySpan s, out nint result) { throw null; } + public static bool TryParse([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? s, System.Globalization.NumberStyles style, System.IFormatProvider? provider, out nint result) { throw null; } + public static bool TryParse([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? s, System.IFormatProvider? provider, out nint result) { throw null; } + public static bool TryParse([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? s, out nint result) { throw null; } } public partial class InvalidCastException : System.SystemException { @@ -6374,13 +6374,13 @@ public TypeUnloadedException(string? message, System.Exception? innerException) [System.CLSCompliantAttribute(false)] public readonly partial struct UIntPtr : System.IComparable, System.IComparable, System.IEquatable, System.IFormattable, System.IParsable, System.ISpanFormattable, System.ISpanParsable, System.Numerics.IAdditionOperators, System.Numerics.IAdditiveIdentity, System.Numerics.IBinaryInteger, System.Numerics.IBinaryNumber, System.Numerics.IBitwiseOperators, System.Numerics.IComparisonOperators, System.Numerics.IDecrementOperators, System.Numerics.IDivisionOperators, System.Numerics.IEqualityOperators, System.Numerics.IIncrementOperators, System.Numerics.IMinMaxValue, System.Numerics.IModulusOperators, System.Numerics.IMultiplicativeIdentity, System.Numerics.IMultiplyOperators, System.Numerics.INumber, System.Numerics.INumberBase, System.Numerics.IShiftOperators, System.Numerics.ISubtractionOperators, System.Numerics.IUnaryNegationOperators, System.Numerics.IUnaryPlusOperators, System.Numerics.IUnsignedNumber, System.Runtime.Serialization.ISerializable { - private readonly int _dummyPrimitive; - public static readonly System.UIntPtr Zero; + private readonly nuint _dummyPrimitive; + public static readonly nuint Zero; public UIntPtr(uint value) { throw null; } public UIntPtr(ulong value) { throw null; } public unsafe UIntPtr(void* value) { throw null; } - public static System.UIntPtr MaxValue { get { throw null; } } - public static System.UIntPtr MinValue { get { throw null; } } + public static nuint MaxValue { get { throw null; } } + public static nuint MinValue { get { throw null; } } public static int Size { get { throw null; } } static nuint System.Numerics.IAdditiveIdentity.AdditiveIdentity { get { throw null; } } static nuint System.Numerics.IMinMaxValue.MaxValue { get { throw null; } } @@ -6388,43 +6388,43 @@ public TypeUnloadedException(string? message, System.Exception? innerException) static nuint System.Numerics.IMultiplicativeIdentity.MultiplicativeIdentity { get { throw null; } } static nuint System.Numerics.INumberBase.One { get { throw null; } } static nuint System.Numerics.INumberBase.Zero { get { throw null; } } - public static System.UIntPtr Add(System.UIntPtr pointer, int offset) { throw null; } + public static nuint Add(nuint pointer, int offset) { throw null; } public static nuint Clamp(nuint value, nuint min, nuint max) { throw null; } public int CompareTo(object? value) { throw null; } - public int CompareTo(System.UIntPtr value) { throw null; } + public int CompareTo(nuint value) { throw null; } public static nuint CreateChecked(TOther value) where TOther : System.Numerics.INumberBase { throw null; } public static nuint CreateSaturating(TOther value) where TOther : System.Numerics.INumberBase { throw null; } public static nuint CreateTruncating(TOther value) where TOther : System.Numerics.INumberBase { throw null; } public static (nuint Quotient, nuint Remainder) DivRem(nuint left, nuint right) { throw null; } public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } - public bool Equals(System.UIntPtr other) { throw null; } + public bool Equals(nuint other) { throw null; } public override int GetHashCode() { throw null; } public static bool IsPow2(nuint value) { throw null; } public static nuint LeadingZeroCount(nuint value) { throw null; } public static nuint Log2(nuint value) { throw null; } public static nuint Max(nuint x, nuint y) { throw null; } public static nuint Min(nuint x, nuint y) { throw null; } - public static System.UIntPtr operator +(System.UIntPtr pointer, int offset) { throw null; } - public static bool operator ==(System.UIntPtr value1, System.UIntPtr value2) { throw null; } - public static explicit operator System.UIntPtr (uint value) { throw null; } - public static explicit operator System.UIntPtr (ulong value) { throw null; } - public static explicit operator uint (System.UIntPtr value) { throw null; } - public static explicit operator ulong (System.UIntPtr value) { throw null; } - public unsafe static explicit operator void* (System.UIntPtr value) { throw null; } - public unsafe static explicit operator System.UIntPtr (void* value) { throw null; } - public static bool operator !=(System.UIntPtr value1, System.UIntPtr value2) { throw null; } - public static System.UIntPtr operator -(System.UIntPtr pointer, int offset) { throw null; } - public static System.UIntPtr Parse(System.ReadOnlySpan s, System.Globalization.NumberStyles style = System.Globalization.NumberStyles.Integer, System.IFormatProvider? provider = null) { throw null; } - public static System.UIntPtr Parse(System.ReadOnlySpan s, System.IFormatProvider? provider) { throw null; } - public static System.UIntPtr Parse(string s) { throw null; } - public static System.UIntPtr Parse(string s, System.Globalization.NumberStyles style) { throw null; } - public static System.UIntPtr Parse(string s, System.Globalization.NumberStyles style, System.IFormatProvider? provider) { throw null; } - public static System.UIntPtr Parse(string s, System.IFormatProvider? provider) { throw null; } + public static nuint operator +(nuint pointer, int offset) { throw null; } + public static bool operator ==(nuint value1, nuint value2) { throw null; } + public static explicit operator nuint (uint value) { throw null; } + public static explicit operator nuint (ulong value) { throw null; } + public static explicit operator uint (nuint value) { throw null; } + public static explicit operator ulong (nuint value) { throw null; } + public unsafe static explicit operator void* (nuint value) { throw null; } + public unsafe static explicit operator nuint (void* value) { throw null; } + public static bool operator !=(nuint value1, nuint value2) { throw null; } + public static nuint operator -(nuint pointer, int offset) { throw null; } + public static nuint Parse(System.ReadOnlySpan s, System.Globalization.NumberStyles style = System.Globalization.NumberStyles.Integer, System.IFormatProvider? provider = null) { throw null; } + public static nuint Parse(System.ReadOnlySpan s, System.IFormatProvider? provider) { throw null; } + public static nuint Parse(string s) { throw null; } + public static nuint Parse(string s, System.Globalization.NumberStyles style) { throw null; } + public static nuint Parse(string s, System.Globalization.NumberStyles style, System.IFormatProvider? provider) { throw null; } + public static nuint Parse(string s, System.IFormatProvider? provider) { throw null; } public static nuint PopCount(nuint value) { throw null; } public static nuint RotateLeft(nuint value, int rotateAmount) { throw null; } public static nuint RotateRight(nuint value, int rotateAmount) { throw null; } public static int Sign(nuint value) { throw null; } - public static System.UIntPtr Subtract(System.UIntPtr pointer, int offset) { throw null; } + public static nuint Subtract(nuint pointer, int offset) { throw null; } static nuint System.Numerics.IAdditionOperators.operator +(nuint left, nuint right) { throw null; } static nuint System.Numerics.IAdditionOperators.operator checked +(nuint left, nuint right) { throw null; } int System.Numerics.IBinaryInteger.GetByteCount() { throw null; } @@ -6483,12 +6483,12 @@ void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Ser public static nuint TrailingZeroCount(nuint value) { throw null; } public static bool TryCreate(TOther value, out nuint result) where TOther : System.Numerics.INumberBase { throw null; } public bool TryFormat(System.Span destination, out int charsWritten, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("NumericFormat")] System.ReadOnlySpan format = default(System.ReadOnlySpan), System.IFormatProvider? provider = null) { throw null; } - public static bool TryParse(System.ReadOnlySpan s, System.Globalization.NumberStyles style, System.IFormatProvider? provider, out System.UIntPtr result) { throw null; } - public static bool TryParse(System.ReadOnlySpan s, System.IFormatProvider? provider, out System.UIntPtr result) { throw null; } - public static bool TryParse(System.ReadOnlySpan s, out System.UIntPtr result) { throw null; } - public static bool TryParse([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? s, System.Globalization.NumberStyles style, System.IFormatProvider? provider, out System.UIntPtr result) { throw null; } - public static bool TryParse([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? s, System.IFormatProvider? provider, out System.UIntPtr result) { throw null; } - public static bool TryParse([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? s, out System.UIntPtr result) { throw null; } + public static bool TryParse(System.ReadOnlySpan s, System.Globalization.NumberStyles style, System.IFormatProvider? provider, out nuint result) { throw null; } + public static bool TryParse(System.ReadOnlySpan s, System.IFormatProvider? provider, out nuint result) { throw null; } + public static bool TryParse(System.ReadOnlySpan s, out nuint result) { throw null; } + public static bool TryParse([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? s, System.Globalization.NumberStyles style, System.IFormatProvider? provider, out nuint result) { throw null; } + public static bool TryParse([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? s, System.IFormatProvider? provider, out nuint result) { throw null; } + public static bool TryParse([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? s, out nuint result) { throw null; } } public partial class UnauthorizedAccessException : System.SystemException { diff --git a/src/libraries/System.Runtime/tests/System/IntPtrTests.cs b/src/libraries/System.Runtime/tests/System/IntPtrTests.cs index 25ad67a3b20c8..79f6bc1ca7400 100644 --- a/src/libraries/System.Runtime/tests/System/IntPtrTests.cs +++ b/src/libraries/System.Runtime/tests/System/IntPtrTests.cs @@ -4,6 +4,8 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.Linq; +using System.Reflection; using Xunit; namespace System.Tests @@ -15,197 +17,215 @@ public static class IntPtrTests [Fact] public static void Zero() { - VerifyPointer(IntPtr.Zero, 0); + Verify(nint.Zero, 0); } [Fact] public static void Ctor_Int() { int i = 42; - VerifyPointer(new IntPtr(i), i); - VerifyPointer((IntPtr)i, i); + Verify(new nint(i), i); + Verify(i, i); i = -1; - VerifyPointer(new IntPtr(i), i); - VerifyPointer((IntPtr)i, i); + Verify(new nint(i), i); + Verify(i, i); } [ConditionalFact(nameof(Is64Bit))] public static void Ctor_Long() { long l = 0x0fffffffffffffff; - VerifyPointer(new IntPtr(l), l); - VerifyPointer((IntPtr)l, l); + Verify(new nint(l), l); + Verify(checked((nint)l), l); } [ConditionalFact(nameof(Is64Bit))] public static unsafe void Ctor_VoidPointer_ToPointer() { - void* pv = new IntPtr(42).ToPointer(); - VerifyPointer(new IntPtr(pv), 42); - VerifyPointer((IntPtr)pv, 42); + void* pv = new nint(42).ToPointer(); + Verify(new nint(pv), 42); + Verify((nint)pv, 42); } [ConditionalFact(nameof(Is64Bit))] public static unsafe void Size() { - Assert.Equal(sizeof(void*), IntPtr.Size); + Assert.Equal(sizeof(void*), nint.Size); } public static IEnumerable Add_TestData() { - yield return new object[] { new IntPtr(42), 6, (long)48 }; - yield return new object[] { new IntPtr(40), 0, (long)40 }; - yield return new object[] { new IntPtr(38), -2, (long)36 }; + yield return new object[] { (nint)42, 6, (long)48 }; + yield return new object[] { (nint)40, 0, (long)40 }; + yield return new object[] { (nint)38, -2, (long)36 }; - yield return new object[] { new IntPtr(0x7fffffffffffffff), 5, unchecked((long)0x8000000000000004) }; /// Add should not throw an OverflowException + yield return new object[] { unchecked((nint)0x7fffffffffffffff), 5, unchecked((long)0x8000000000000004) }; /// Add should not throw an OverflowException } [ConditionalTheory(nameof(Is64Bit))] [MemberData(nameof(Add_TestData))] - public static void Add(IntPtr ptr, int offset, long expected) + public static void Add(nint value, int offset, long expected) { - IntPtr p1 = IntPtr.Add(ptr, offset); - VerifyPointer(p1, expected); + MethodInfo add = typeof(nint).GetMethod("Add"); - IntPtr p2 = ptr + offset; - VerifyPointer(p2, expected); + nint result = (nint)add.Invoke(null, new object[] { value, offset }); + Verify(result, expected); - IntPtr p3 = ptr; - p3 += offset; - VerifyPointer(p3, expected); + MethodInfo opAddition = typeof(nint).GetMethod("op_Addition"); + + result = (nint)opAddition.Invoke(null, new object[] { value, offset }); + Verify(result, expected); } public static IEnumerable Subtract_TestData() { - yield return new object[] { new IntPtr(42), 6, (long)36 }; - yield return new object[] { new IntPtr(40), 0, (long)40 }; - yield return new object[] { new IntPtr(38), -2, (long)40 }; + yield return new object[] { (nint)42, 6, (long)36 }; + yield return new object[] { (nint)40, 0, (long)40 }; + yield return new object[] { (nint)38, -2, (long)40 }; } [ConditionalTheory(nameof(Is64Bit))] [MemberData(nameof(Subtract_TestData))] - public static void Subtract(IntPtr ptr, int offset, long expected) + public static void Subtract(nint value, int offset, long expected) { - IntPtr p1 = IntPtr.Subtract(ptr, offset); - VerifyPointer(p1, expected); + MethodInfo subtract = typeof(nint).GetMethod("Subtract"); + + nint result = (nint)subtract.Invoke(null, new object[] { value, offset }); + Verify(result, expected); - IntPtr p2 = ptr - offset; - VerifyPointer(p2, expected); + MethodInfo opSubtraction = typeof(nint).GetMethod("op_Subtraction"); - IntPtr p3 = ptr; - p3 -= offset; - VerifyPointer(p3, expected); + result = (nint)opSubtraction.Invoke(null, new object[] { value, offset }); + Verify(result, expected); } public static IEnumerable Equals_TestData() { - yield return new object[] { new IntPtr(42), new IntPtr(42), true }; - yield return new object[] { new IntPtr(42), new IntPtr(43), false }; - yield return new object[] { new IntPtr(42), 42, false }; - yield return new object[] { new IntPtr(42), null, false }; + yield return new object[] { (nint)42, (nint)42, true }; + yield return new object[] { (nint)42, (nint)43, false }; + yield return new object[] { (nint)42, 42, false }; + yield return new object[] { (nint)42, null, false }; } [Theory] [MemberData(nameof(Equals_TestData))] - public static void EqualsTest(IntPtr ptr1, object obj, bool expected) + public static void EqualsTest(nint value, object obj, bool expected) { - if (obj is IntPtr) + if (obj is nint other) { - IntPtr ptr2 = (IntPtr)obj; - Assert.Equal(expected, ptr1 == ptr2); - Assert.Equal(!expected, ptr1 != ptr2); - Assert.Equal(expected, ptr1.GetHashCode().Equals(ptr2.GetHashCode())); + Assert.Equal(expected, value == other); + Assert.Equal(!expected, value != other); + Assert.Equal(expected, value.GetHashCode().Equals(other.GetHashCode())); - IEquatable iEquatable = ptr1; - Assert.Equal(expected, iEquatable.Equals((IntPtr)obj)); + IEquatable iEquatable = value; + Assert.Equal(expected, iEquatable.Equals(other)); } - Assert.Equal(expected, ptr1.Equals(obj)); - Assert.Equal(ptr1.GetHashCode(), ptr1.GetHashCode()); + Assert.Equal(expected, value.Equals(obj)); + Assert.Equal(value.GetHashCode(), value.GetHashCode()); } [ConditionalFact(nameof(Is64Bit))] - public static unsafe void ImplicitCast() + public static unsafe void TestExplicitCast() { - var ptr = new IntPtr(42); + nint value = 42; + + MethodInfo[] methods = typeof(nint).GetMethods(); + + MethodInfo opExplicitFromInt32 = typeof(nint).GetMethod("op_Explicit", new Type[] { typeof(int) }); + MethodInfo opExplicitToInt32 = methods.Single((methodInfo) => (methodInfo.Name == "op_Explicit") && (methodInfo.ReturnType == typeof(int))); + + int i = (int)opExplicitToInt32.Invoke(null, new object[] { value }); + Assert.Equal(42, i); + Assert.Equal(value, (nint)opExplicitFromInt32.Invoke(null, new object[] { i })); - uint i = (uint)ptr; - Assert.Equal(42u, i); - Assert.Equal(ptr, (IntPtr)i); + MethodInfo opExplicitFromInt64 = typeof(nint).GetMethod("op_Explicit", new Type[] { typeof(long) }); + MethodInfo opExplicitToInt64 = methods.Single((methodInfo) => (methodInfo.Name == "op_Explicit") && (methodInfo.ReturnType == typeof(long))); - ulong l = (ulong)ptr; + long l = (long)opExplicitToInt64.Invoke(null, new object[] { value }); Assert.Equal(42u, l); - Assert.Equal(ptr, (IntPtr)l); + Assert.Equal(value, (nint)opExplicitFromInt64.Invoke(null, new object[] { l })); - void* v = (void*)ptr; - Assert.Equal(ptr, (IntPtr)v); + MethodInfo opExplicitFromPointer = typeof(nint).GetMethod("op_Explicit", new Type[] { typeof(void*) }); + MethodInfo opExplicitToPointer = methods.Single((methodInfo) => (methodInfo.Name == "op_Explicit") && (methodInfo.ReturnType == typeof(void*))); - ptr = new IntPtr(0x7fffffffffffffff); - Assert.Throws(() => (int)ptr); + void* v = Pointer.Unbox(opExplicitToPointer.Invoke(null, new object[] { value })); + Assert.Equal(value, (nint)opExplicitFromPointer.Invoke(null, new object[] { Pointer.Box(v, typeof(void*)) })); + + value = unchecked((nint)0x7fffffffffffffff); + Exception ex = Assert.ThrowsAny(() => opExplicitToInt32.Invoke(null, new object[] { value })); + + if (ex is TargetInvocationException) + { + // RyuJIT throws TargetInvocationException wrapping an OverflowException + // while Mono directly throws the OverflowException + ex = ex.InnerException; + } + Assert.IsType(ex); } [ConditionalFact(nameof(Is64Bit))] public static void GetHashCodeRespectAllBits() { - var ptr1 = new IntPtr(0x123456FFFFFFFF); - var ptr2 = new IntPtr(0x654321FFFFFFFF); - Assert.NotEqual(ptr1.GetHashCode(), ptr2.GetHashCode()); + var value = unchecked((nint)0x123456FFFFFFFF); + var other = unchecked((nint)0x654321FFFFFFFF); + Assert.NotEqual(value.GetHashCode(), other.GetHashCode()); } - private static void VerifyPointer(IntPtr ptr, long expected) + private static void Verify(nint value, long expected) { - Assert.Equal(expected, ptr.ToInt64()); + Assert.Equal(expected, value.ToInt64()); int expected32 = unchecked((int)expected); if (expected32 != expected) { - Assert.Throws(() => ptr.ToInt32()); + Assert.Throws(() => value.ToInt32()); return; } - int i = ptr.ToInt32(); - Assert.Equal(expected32, ptr.ToInt32()); + int i = value.ToInt32(); + Assert.Equal(expected32, value.ToInt32()); - Assert.Equal(expected.ToString(), ptr.ToString()); - Assert.Equal(IntPtr.Size == 4 ? expected32.ToString("x") : expected.ToString("x"), ptr.ToString("x")); + Assert.Equal(expected.ToString(), value.ToString()); + Assert.Equal(nint.Size == 4 ? expected32.ToString("x") : expected.ToString("x"), value.ToString("x")); - Assert.Equal(ptr, new IntPtr(expected)); - Assert.True(ptr == new IntPtr(expected)); - Assert.False(ptr != new IntPtr(expected)); + Assert.Equal(value, checked((nint)expected)); + Assert.True(value == checked((nint)expected)); + Assert.False(value != checked((nint)expected)); - Assert.NotEqual(ptr, new IntPtr(expected + 1)); - Assert.False(ptr == new IntPtr(expected + 1)); - Assert.True(ptr != new IntPtr(expected + 1)); + Assert.NotEqual(value, checked((nint)expected + 1)); + Assert.False(value == checked((nint)expected + 1)); + Assert.True(value != checked((nint)expected + 1)); } - public static IntPtr RealMax => Is64Bit ? (IntPtr)long.MaxValue : (IntPtr)int.MaxValue; - public static IntPtr RealMin => Is64Bit ? (IntPtr)long.MinValue : (IntPtr)int.MinValue; + public static nint RealMax => Is64Bit ? unchecked((nint)long.MaxValue) : int.MaxValue; + public static nint RealMin => Is64Bit ? unchecked((nint)long.MinValue) : int.MinValue; [Fact] public static void Ctor_Empty() { - var i = new IntPtr(); + var i = new nint(); Assert.Equal(default, i); } [Fact] public static void Ctor_Value() { - IntPtr i = (IntPtr)41; - Assert.Equal((IntPtr)041, i); + nint i = 41; + Assert.Equal(041, i); } [Fact] public static void MaxValue() { - Assert.Equal(RealMax, IntPtr.MaxValue); + Assert.Equal(RealMax, nint.MaxValue); } [Fact] public static void MinValue() { - Assert.Equal(RealMin, IntPtr.MinValue); + Assert.Equal(RealMin, nint.MinValue); } [Theory] @@ -226,10 +246,10 @@ public static void MinValue() [InlineData(234, null, 1)] public static void CompareTo_Other_ReturnsExpected(int l, object value, int expected) { - var i = (IntPtr)l; + nint i = l; if (value is int intValue) { - var intPtrValue = (IntPtr)intValue; + nint intPtrValue = intValue; Assert.Equal(expected, Math.Sign(i.CompareTo(intPtrValue))); Assert.Equal(-expected, Math.Sign(intPtrValue.CompareTo(i))); @@ -246,7 +266,7 @@ public static void CompareTo_Other_ReturnsExpected(int l, object value, int expe [InlineData((long)234)] public static void CompareTo_ObjectNotIntPtr_ThrowsArgumentException(object value) { - AssertExtensions.Throws(null, () => ((IntPtr)123).CompareTo(value)); + AssertExtensions.Throws(null, () => ((nint)123).CompareTo(value)); } public static IEnumerable ToString_TestData() @@ -255,21 +275,21 @@ public static IEnumerable ToString_TestData() { foreach (string defaultSpecifier in new[] { "G", "G\0", "\0N222", "\0", "", "R" }) { - yield return new object[] { IntPtr.MinValue, defaultSpecifier, defaultFormat, Is64Bit ? "-9223372036854775808" : "-2147483648" }; - yield return new object[] { (IntPtr)(-4567), defaultSpecifier, defaultFormat, "-4567" }; - yield return new object[] { (IntPtr)0, defaultSpecifier, defaultFormat, "0" }; - yield return new object[] { (IntPtr)4567, defaultSpecifier, defaultFormat, "4567" }; - yield return new object[] { IntPtr.MaxValue, defaultSpecifier, defaultFormat, Is64Bit ? "9223372036854775807" : "2147483647" }; + yield return new object[] { nint.MinValue, defaultSpecifier, defaultFormat, Is64Bit ? "-9223372036854775808" : "-2147483648" }; + yield return new object[] { (nint)(-4567), defaultSpecifier, defaultFormat, "-4567" }; + yield return new object[] { (nint)0, defaultSpecifier, defaultFormat, "0" }; + yield return new object[] { (nint)4567, defaultSpecifier, defaultFormat, "4567" }; + yield return new object[] { nint.MaxValue, defaultSpecifier, defaultFormat, Is64Bit ? "9223372036854775807" : "2147483647" }; } - yield return new object[] { (IntPtr)4567, "D", defaultFormat, "4567" }; - yield return new object[] { (IntPtr)4567, "D99", defaultFormat, "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004567" }; - yield return new object[] { (IntPtr)4567, "D99\09", defaultFormat, "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004567" }; - yield return new object[] { (IntPtr)(-4567), "D99\09", defaultFormat, "-000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004567" }; + yield return new object[] { (nint)4567, "D", defaultFormat, "4567" }; + yield return new object[] { (nint)4567, "D99", defaultFormat, "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004567" }; + yield return new object[] { (nint)4567, "D99\09", defaultFormat, "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004567" }; + yield return new object[] { (nint)(-4567), "D99\09", defaultFormat, "-000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004567" }; - yield return new object[] { (IntPtr)0x2468, "x", defaultFormat, "2468" }; - yield return new object[] { (IntPtr)(-0x2468), "x", defaultFormat, Is64Bit ? "ffffffffffffdb98" : "ffffdb98" }; - yield return new object[] { (IntPtr)2468, "N", defaultFormat, string.Format("{0:N}", 2468.00) }; + yield return new object[] { (nint)0x2468, "x", defaultFormat, "2468" }; + yield return new object[] { (nint)(-0x2468), "x", defaultFormat, Is64Bit ? "ffffffffffffdb98" : "ffffdb98" }; + yield return new object[] { (nint)2468, "N", defaultFormat, string.Format("{0:N}", 2468.00) }; } var customFormat = new NumberFormatInfo() @@ -284,16 +304,16 @@ public static IEnumerable ToString_TestData() PercentDecimalSeparator = ".", PercentDecimalDigits = 5 }; - yield return new object[] { (IntPtr)(-2468), "N", customFormat, "#2*468~00" }; - yield return new object[] { (IntPtr)2468, "N", customFormat, "2*468~00" }; - yield return new object[] { (IntPtr)123, "E", customFormat, "1~230000E&002" }; - yield return new object[] { (IntPtr)123, "F", customFormat, "123~00" }; - yield return new object[] { (IntPtr)123, "P", customFormat, "12,300.00000 @" }; + yield return new object[] { (nint)(-2468), "N", customFormat, "#2*468~00" }; + yield return new object[] { (nint)2468, "N", customFormat, "2*468~00" }; + yield return new object[] { (nint)123, "E", customFormat, "1~230000E&002" }; + yield return new object[] { (nint)123, "F", customFormat, "123~00" }; + yield return new object[] { (nint)123, "P", customFormat, "12,300.00000 @" }; } [Theory] [MemberData(nameof(ToString_TestData))] - public static void ToStringTest(IntPtr i, string format, IFormatProvider provider, string expected) + public static void ToStringTest(nint i, string format, IFormatProvider provider, string expected) { // Format is case insensitive string upperFormat = format.ToUpperInvariant(); @@ -326,7 +346,7 @@ public static void ToStringTest(IntPtr i, string format, IFormatProvider provide [Fact] public static void ToString_InvalidFormat_ThrowsFormatException() { - IntPtr i = (IntPtr)123; + nint i = 123; Assert.Throws(() => i.ToString("Y")); // Invalid format Assert.Throws(() => i.ToString("Y", null)); // Invalid format } @@ -343,55 +363,55 @@ public static IEnumerable Parse_Valid_TestData() NumberFormatInfo emptyNegativeFormat = new NumberFormatInfo() { NegativeSign = "" }; // None - yield return new object[] { "0", NumberStyles.None, null, (IntPtr)0 }; - yield return new object[] { "0000000000000000000000000000000000000000000000000000000000", NumberStyles.None, null, (IntPtr)0 }; - yield return new object[] { "0000000000000000000000000000000000000000000000000000000001", NumberStyles.None, null, (IntPtr)1 }; - yield return new object[] { "2147483647", NumberStyles.None, null, (IntPtr)2147483647 }; - yield return new object[] { "02147483647", NumberStyles.None, null, (IntPtr)2147483647 }; - yield return new object[] { "00000000000000000000000000000000000000000000000002147483647", NumberStyles.None, null, (IntPtr)2147483647 }; - yield return new object[] { "123\0\0", NumberStyles.None, null, (IntPtr)123 }; + yield return new object[] { "0", NumberStyles.None, null, (nint)0 }; + yield return new object[] { "0000000000000000000000000000000000000000000000000000000000", NumberStyles.None, null, (nint)0 }; + yield return new object[] { "0000000000000000000000000000000000000000000000000000000001", NumberStyles.None, null, (nint)1 }; + yield return new object[] { "2147483647", NumberStyles.None, null, (nint)2147483647 }; + yield return new object[] { "02147483647", NumberStyles.None, null, (nint)2147483647 }; + yield return new object[] { "00000000000000000000000000000000000000000000000002147483647", NumberStyles.None, null, (nint)2147483647 }; + yield return new object[] { "123\0\0", NumberStyles.None, null, (nint)123 }; // All lengths decimal foreach (bool neg in new[] { false, true }) { string s = neg ? "-" : ""; - var result = 0; - for (var i = 1; i <= 10; i++) + int result = 0; + for (int i = 1; i <= 10; i++) { result = result * 10 + (i % 10); s += (i % 10).ToString(); - yield return new object[] { s, NumberStyles.Integer, null, (IntPtr)(neg ? result * -1 : result) }; + yield return new object[] { s, NumberStyles.Integer, null, (nint)(neg ? result * -1 : result) }; } } // All lengths hexadecimal { string s = ""; - var result = 0; - for (var i = 1; i <= 8; i++) + int result = 0; + for (int i = 1; i <= 8; i++) { result = (result * 16) + (i % 16); s += (i % 16).ToString("X"); - yield return new object[] { s, NumberStyles.HexNumber, null, (IntPtr)result }; + yield return new object[] { s, NumberStyles.HexNumber, null, (nint)result }; } } // HexNumber - yield return new object[] { "123", NumberStyles.HexNumber, null, (IntPtr)0x123 }; - yield return new object[] { "abc", NumberStyles.HexNumber, null, (IntPtr)0xabc }; - yield return new object[] { "ABC", NumberStyles.HexNumber, null, (IntPtr)0xabc }; - yield return new object[] { "12", NumberStyles.HexNumber, null, (IntPtr)0x12 }; + yield return new object[] { "123", NumberStyles.HexNumber, null, (nint)0x123 }; + yield return new object[] { "abc", NumberStyles.HexNumber, null, (nint)0xabc }; + yield return new object[] { "ABC", NumberStyles.HexNumber, null, (nint)0xabc }; + yield return new object[] { "12", NumberStyles.HexNumber, null, (nint)0x12 }; if (Is64Bit) { - yield return new object[] { "8000000000000000", NumberStyles.HexNumber, null, IntPtr.MinValue }; - yield return new object[] { "7FFFFFFFFFFFFFFF", NumberStyles.HexNumber, null, IntPtr.MaxValue }; + yield return new object[] { "8000000000000000", NumberStyles.HexNumber, null, nint.MinValue }; + yield return new object[] { "7FFFFFFFFFFFFFFF", NumberStyles.HexNumber, null, nint.MaxValue }; } else { - yield return new object[] { "80000000", NumberStyles.HexNumber, null, IntPtr.MinValue }; - yield return new object[] { "7FFFFFFF", NumberStyles.HexNumber, null, IntPtr.MaxValue }; + yield return new object[] { "80000000", NumberStyles.HexNumber, null, nint.MinValue }; + yield return new object[] { "7FFFFFFF", NumberStyles.HexNumber, null, nint.MaxValue }; } // Currency @@ -401,17 +421,17 @@ public static IEnumerable Parse_Valid_TestData() CurrencyGroupSeparator = "|", NumberGroupSeparator = "/" }; - yield return new object[] { "$1|000", NumberStyles.Currency, currencyFormat, (IntPtr)1000 }; - yield return new object[] { "$1000", NumberStyles.Currency, currencyFormat, (IntPtr)1000 }; - yield return new object[] { "$ 1000", NumberStyles.Currency, currencyFormat, (IntPtr)1000 }; - yield return new object[] { "1000", NumberStyles.Currency, currencyFormat, (IntPtr)1000 }; - yield return new object[] { "$(1000)", NumberStyles.Currency, currencyFormat, (IntPtr)(-1000) }; - yield return new object[] { "($1000)", NumberStyles.Currency, currencyFormat, (IntPtr)(-1000) }; - yield return new object[] { "$-1000", NumberStyles.Currency, currencyFormat, (IntPtr)(-1000) }; - yield return new object[] { "-$1000", NumberStyles.Currency, currencyFormat, (IntPtr)(-1000) }; + yield return new object[] { "$1|000", NumberStyles.Currency, currencyFormat, (nint)1000 }; + yield return new object[] { "$1000", NumberStyles.Currency, currencyFormat, (nint)1000 }; + yield return new object[] { "$ 1000", NumberStyles.Currency, currencyFormat, (nint)1000 }; + yield return new object[] { "1000", NumberStyles.Currency, currencyFormat, (nint)1000 }; + yield return new object[] { "$(1000)", NumberStyles.Currency, currencyFormat, (nint)(-1000) }; + yield return new object[] { "($1000)", NumberStyles.Currency, currencyFormat, (nint)(-1000) }; + yield return new object[] { "$-1000", NumberStyles.Currency, currencyFormat, (nint)(-1000) }; + yield return new object[] { "-$1000", NumberStyles.Currency, currencyFormat, (nint)(-1000) }; NumberFormatInfo emptyCurrencyFormat = new NumberFormatInfo() { CurrencySymbol = "" }; - yield return new object[] { "100", NumberStyles.Currency, emptyCurrencyFormat, (IntPtr)100 }; + yield return new object[] { "100", NumberStyles.Currency, emptyCurrencyFormat, (nint)100 }; // If CurrencySymbol and Negative are the same, NegativeSign is preferred NumberFormatInfo sameCurrencyNegativeSignFormat = new NumberFormatInfo() @@ -419,127 +439,127 @@ public static IEnumerable Parse_Valid_TestData() NegativeSign = "|", CurrencySymbol = "|" }; - yield return new object[] { "|1000", NumberStyles.AllowCurrencySymbol | NumberStyles.AllowLeadingSign, sameCurrencyNegativeSignFormat, (IntPtr)(-1000) }; + yield return new object[] { "|1000", NumberStyles.AllowCurrencySymbol | NumberStyles.AllowLeadingSign, sameCurrencyNegativeSignFormat, (nint)(-1000) }; // Any - yield return new object[] { "123", NumberStyles.Any, null, (IntPtr)123 }; + yield return new object[] { "123", NumberStyles.Any, null, (nint)123 }; // AllowLeadingSign - yield return new object[] { "-2147483648", NumberStyles.AllowLeadingSign, null, (IntPtr)(-2147483648) }; - yield return new object[] { "-123", NumberStyles.AllowLeadingSign, null, (IntPtr)(-123) }; - yield return new object[] { "+0", NumberStyles.AllowLeadingSign, null, (IntPtr)0 }; - yield return new object[] { "-0", NumberStyles.AllowLeadingSign, null, (IntPtr)0 }; - yield return new object[] { "+123", NumberStyles.AllowLeadingSign, null, (IntPtr)123 }; + yield return new object[] { "-2147483648", NumberStyles.AllowLeadingSign, null, (nint)(-2147483648) }; + yield return new object[] { "-123", NumberStyles.AllowLeadingSign, null, (nint)(-123) }; + yield return new object[] { "+0", NumberStyles.AllowLeadingSign, null, (nint)0 }; + yield return new object[] { "-0", NumberStyles.AllowLeadingSign, null, (nint)0 }; + yield return new object[] { "+123", NumberStyles.AllowLeadingSign, null, (nint)123 }; // If PositiveSign and NegativeSign are the same, PositiveSign is preferred - yield return new object[] { "|123", NumberStyles.AllowLeadingSign, samePositiveNegativeFormat, (IntPtr)123 }; + yield return new object[] { "|123", NumberStyles.AllowLeadingSign, samePositiveNegativeFormat, (nint)123 }; // Empty PositiveSign or NegativeSign - yield return new object[] { "100", NumberStyles.AllowLeadingSign, emptyPositiveFormat, (IntPtr)100 }; - yield return new object[] { "100", NumberStyles.AllowLeadingSign, emptyNegativeFormat, (IntPtr)100 }; + yield return new object[] { "100", NumberStyles.AllowLeadingSign, emptyPositiveFormat, (nint)100 }; + yield return new object[] { "100", NumberStyles.AllowLeadingSign, emptyNegativeFormat, (nint)100 }; // AllowTrailingSign - yield return new object[] { "123", NumberStyles.AllowTrailingSign, null, (IntPtr)123 }; - yield return new object[] { "123+", NumberStyles.AllowTrailingSign, null, (IntPtr)123 }; - yield return new object[] { "123-", NumberStyles.AllowTrailingSign, null, (IntPtr)(-123) }; + yield return new object[] { "123", NumberStyles.AllowTrailingSign, null, (nint)123 }; + yield return new object[] { "123+", NumberStyles.AllowTrailingSign, null, (nint)123 }; + yield return new object[] { "123-", NumberStyles.AllowTrailingSign, null, (nint)(-123) }; // If PositiveSign and NegativeSign are the same, PositiveSign is preferred - yield return new object[] { "123|", NumberStyles.AllowTrailingSign, samePositiveNegativeFormat, (IntPtr)123 }; + yield return new object[] { "123|", NumberStyles.AllowTrailingSign, samePositiveNegativeFormat, (nint)123 }; // Empty PositiveSign or NegativeSign - yield return new object[] { "100", NumberStyles.AllowTrailingSign, emptyPositiveFormat, (IntPtr)100 }; - yield return new object[] { "100", NumberStyles.AllowTrailingSign, emptyNegativeFormat, (IntPtr)100 }; + yield return new object[] { "100", NumberStyles.AllowTrailingSign, emptyPositiveFormat, (nint)100 }; + yield return new object[] { "100", NumberStyles.AllowTrailingSign, emptyNegativeFormat, (nint)100 }; // AllowLeadingWhite and AllowTrailingWhite - yield return new object[] { " 123", NumberStyles.AllowLeadingWhite, null, (IntPtr)123 }; - yield return new object[] { " 123 ", NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, null, (IntPtr)123 }; - yield return new object[] { "123 ", NumberStyles.AllowTrailingWhite, null, (IntPtr)123 }; - yield return new object[] { "123 \0\0", NumberStyles.AllowTrailingWhite, null, (IntPtr)123 }; - yield return new object[] { " 2147483647 ", NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, null, (IntPtr)2147483647 }; - yield return new object[] { " -2147483648 ", NumberStyles.Integer, null, (IntPtr)(-2147483648) }; + yield return new object[] { " 123", NumberStyles.AllowLeadingWhite, null, (nint)123 }; + yield return new object[] { " 123 ", NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, null, (nint)123 }; + yield return new object[] { "123 ", NumberStyles.AllowTrailingWhite, null, (nint)123 }; + yield return new object[] { "123 \0\0", NumberStyles.AllowTrailingWhite, null, (nint)123 }; + yield return new object[] { " 2147483647 ", NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, null, (nint)2147483647 }; + yield return new object[] { " -2147483648 ", NumberStyles.Integer, null, (nint)(-2147483648) }; foreach (char c in new[] { (char)0x9, (char)0xA, (char)0xB, (char)0xC, (char)0xD }) { string cs = c.ToString(); - yield return new object[] { cs + cs + "123" + cs + cs, NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, null, (IntPtr)123 }; + yield return new object[] { cs + cs + "123" + cs + cs, NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, null, (nint)123 }; } - yield return new object[] { " 0 ", NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, null, (IntPtr)0 }; - yield return new object[] { " 000000000 ", NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, null, (IntPtr)0 }; + yield return new object[] { " 0 ", NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, null, (nint)0 }; + yield return new object[] { " 000000000 ", NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, null, (nint)0 }; // AllowThousands NumberFormatInfo thousandsFormat = new NumberFormatInfo() { NumberGroupSeparator = "|" }; - yield return new object[] { "1000", NumberStyles.AllowThousands, thousandsFormat, (IntPtr)1000 }; - yield return new object[] { "1|0|0|0", NumberStyles.AllowThousands, thousandsFormat, (IntPtr)1000 }; - yield return new object[] { "1|||", NumberStyles.AllowThousands, thousandsFormat, (IntPtr)1 }; + yield return new object[] { "1000", NumberStyles.AllowThousands, thousandsFormat, (nint)1000 }; + yield return new object[] { "1|0|0|0", NumberStyles.AllowThousands, thousandsFormat, (nint)1000 }; + yield return new object[] { "1|||", NumberStyles.AllowThousands, thousandsFormat, (nint)1 }; NumberFormatInfo IntegerNumberSeparatorFormat = new NumberFormatInfo() { NumberGroupSeparator = "1" }; - yield return new object[] { "1111", NumberStyles.AllowThousands, IntegerNumberSeparatorFormat, (IntPtr)1111 }; + yield return new object[] { "1111", NumberStyles.AllowThousands, IntegerNumberSeparatorFormat, (nint)1111 }; // AllowExponent - yield return new object[] { "1E2", NumberStyles.AllowExponent, null, (IntPtr)100 }; - yield return new object[] { "1E+2", NumberStyles.AllowExponent, null, (IntPtr)100 }; - yield return new object[] { "1e2", NumberStyles.AllowExponent, null, (IntPtr)100 }; - yield return new object[] { "1E0", NumberStyles.AllowExponent, null, (IntPtr)1 }; - yield return new object[] { "(1E2)", NumberStyles.AllowExponent | NumberStyles.AllowParentheses, null, (IntPtr)(-100) }; - yield return new object[] { "-1E2", NumberStyles.AllowExponent | NumberStyles.AllowLeadingSign, null, (IntPtr)(-100) }; + yield return new object[] { "1E2", NumberStyles.AllowExponent, null, (nint)100 }; + yield return new object[] { "1E+2", NumberStyles.AllowExponent, null, (nint)100 }; + yield return new object[] { "1e2", NumberStyles.AllowExponent, null, (nint)100 }; + yield return new object[] { "1E0", NumberStyles.AllowExponent, null, (nint)1 }; + yield return new object[] { "(1E2)", NumberStyles.AllowExponent | NumberStyles.AllowParentheses, null, (nint)(-100) }; + yield return new object[] { "-1E2", NumberStyles.AllowExponent | NumberStyles.AllowLeadingSign, null, (nint)(-100) }; NumberFormatInfo negativeFormat = new NumberFormatInfo() { PositiveSign = "|" }; - yield return new object[] { "1E|2", NumberStyles.AllowExponent, negativeFormat, (IntPtr)100 }; + yield return new object[] { "1E|2", NumberStyles.AllowExponent, negativeFormat, (nint)100 }; // AllowParentheses - yield return new object[] { "123", NumberStyles.AllowParentheses, null, (IntPtr)123 }; - yield return new object[] { "(123)", NumberStyles.AllowParentheses, null, (IntPtr)(-123) }; + yield return new object[] { "123", NumberStyles.AllowParentheses, null, (nint)123 }; + yield return new object[] { "(123)", NumberStyles.AllowParentheses, null, (nint)(-123) }; // AllowDecimalPoint NumberFormatInfo decimalFormat = new NumberFormatInfo() { NumberDecimalSeparator = "|" }; - yield return new object[] { "67|", NumberStyles.AllowDecimalPoint, decimalFormat, (IntPtr)67 }; + yield return new object[] { "67|", NumberStyles.AllowDecimalPoint, decimalFormat, (nint)67 }; - // NumberFormatInfo has a custom property with length > (IntPtr)1 + // NumberFormatInfo has a custom property with length > (nint)1 NumberFormatInfo IntegerCurrencyFormat = new NumberFormatInfo() { CurrencySymbol = "123" }; - yield return new object[] { "123123", NumberStyles.AllowCurrencySymbol, IntegerCurrencyFormat, (IntPtr)123 }; + yield return new object[] { "123123", NumberStyles.AllowCurrencySymbol, IntegerCurrencyFormat, (nint)123 }; - yield return new object[] { "123123", NumberStyles.AllowLeadingSign, new NumberFormatInfo() { PositiveSign = "1" }, (IntPtr)23123 }; - yield return new object[] { "123123", NumberStyles.AllowLeadingSign, new NumberFormatInfo() { NegativeSign = "1" }, (IntPtr)(-23123) }; - yield return new object[] { "123123", NumberStyles.AllowLeadingSign, new NumberFormatInfo() { PositiveSign = "123" }, (IntPtr)123 }; - yield return new object[] { "123123", NumberStyles.AllowLeadingSign, new NumberFormatInfo() { NegativeSign = "123" }, (IntPtr)(-123) }; - yield return new object[] { "123123", NumberStyles.AllowLeadingSign, new NumberFormatInfo() { PositiveSign = "12312" }, (IntPtr)3 }; - yield return new object[] { "123123", NumberStyles.AllowLeadingSign, new NumberFormatInfo() { NegativeSign = "12312" }, (IntPtr)(-3) }; + yield return new object[] { "123123", NumberStyles.AllowLeadingSign, new NumberFormatInfo() { PositiveSign = "1" }, (nint)23123 }; + yield return new object[] { "123123", NumberStyles.AllowLeadingSign, new NumberFormatInfo() { NegativeSign = "1" }, (nint)(-23123) }; + yield return new object[] { "123123", NumberStyles.AllowLeadingSign, new NumberFormatInfo() { PositiveSign = "123" }, (nint)123 }; + yield return new object[] { "123123", NumberStyles.AllowLeadingSign, new NumberFormatInfo() { NegativeSign = "123" }, (nint)(-123) }; + yield return new object[] { "123123", NumberStyles.AllowLeadingSign, new NumberFormatInfo() { PositiveSign = "12312" }, (nint)3 }; + yield return new object[] { "123123", NumberStyles.AllowLeadingSign, new NumberFormatInfo() { NegativeSign = "12312" }, (nint)(-3) }; } [Theory] [MemberData(nameof(Parse_Valid_TestData))] - public static void Parse_Valid(string value, NumberStyles style, IFormatProvider provider, IntPtr expected) + public static void Parse_Valid(string value, NumberStyles style, IFormatProvider provider, nint expected) { - IntPtr result; + nint result; // Default style and provider if (style == NumberStyles.Integer && provider == null) { - Assert.True(IntPtr.TryParse(value, out result)); + Assert.True(nint.TryParse(value, out result)); Assert.Equal(expected, result); - Assert.Equal(expected, IntPtr.Parse(value)); + Assert.Equal(expected, nint.Parse(value)); } // Default provider if (provider == null) { - Assert.Equal(expected, IntPtr.Parse(value, style)); + Assert.Equal(expected, nint.Parse(value, style)); // Substitute default NumberFormatInfo - Assert.True(IntPtr.TryParse(value, style, new NumberFormatInfo(), out result)); + Assert.True(nint.TryParse(value, style, new NumberFormatInfo(), out result)); Assert.Equal(expected, result); - Assert.Equal(expected, IntPtr.Parse(value, style, new NumberFormatInfo())); + Assert.Equal(expected, nint.Parse(value, style, new NumberFormatInfo())); } // Default style if (style == NumberStyles.Integer) { - Assert.Equal(expected, IntPtr.Parse(value, provider)); + Assert.Equal(expected, nint.Parse(value, provider)); } // Full overloads - Assert.True(IntPtr.TryParse(value, style, provider, out result)); + Assert.True(nint.TryParse(value, style, provider, out result)); Assert.Equal(expected, result); - Assert.Equal(expected, IntPtr.Parse(value, style, provider)); + Assert.Equal(expected, nint.Parse(value, style, provider)); } public static IEnumerable Parse_Invalid_TestData() @@ -580,7 +600,7 @@ public static IEnumerable Parse_Invalid_TestData() yield return new object[] { "\0\0123", NumberStyles.Integer, null, typeof(FormatException) }; yield return new object[] { "\0\0123", NumberStyles.Any, null, typeof(FormatException) }; - // String has IntPtrernal zeros + // String has internal zeros yield return new object[] { "1\023", NumberStyles.Integer, null, typeof(FormatException) }; yield return new object[] { "1\023", NumberStyles.Any, null, typeof(FormatException) }; @@ -682,13 +702,13 @@ public static IEnumerable Parse_Invalid_TestData() yield return new object[] { "+ ", NumberStyles.Integer, null, typeof(FormatException) }; yield return new object[] { "- ", NumberStyles.Integer, null, typeof(FormatException) }; - // NumberFormatInfo has a custom property with length > (IntPtr)1 + // NumberFormatInfo has a custom property with length > (nint)1 NumberFormatInfo IntegerCurrencyFormat = new NumberFormatInfo() { CurrencySymbol = "123" }; yield return new object[] { "123", NumberStyles.AllowCurrencySymbol, IntegerCurrencyFormat, typeof(FormatException) }; yield return new object[] { "123", NumberStyles.AllowLeadingSign, new NumberFormatInfo() { PositiveSign = "123" }, typeof(FormatException) }; yield return new object[] { "123", NumberStyles.AllowLeadingSign, new NumberFormatInfo() { NegativeSign = "123" }, typeof(FormatException) }; - // Decimals not in range of IntPtr32 + // Decimals not in range of Int32 foreach (string s in new[] { @@ -720,10 +740,10 @@ public static IEnumerable Parse_Invalid_TestData() } } - // Hexadecimals not in range of IntPtr32 + // Hexadecimals not in range of Int32 foreach (string s in new[] { - "10000000000000000", // ulong.MaxValue + (IntPtr)1 + "10000000000000000", // ulong.MaxValue + (nint)1 "FFFFFFFFFFFFFFFF0", // extra digit after ulong.MaxValue "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000" // really big @@ -748,37 +768,37 @@ public static IEnumerable Parse_Invalid_TestData() public static void Parse_Invalid(string value, NumberStyles style, IFormatProvider provider, Type exceptionType) { if (2 == 2E10) { } - IntPtr result; + nint result; // Default style and provider if (style == NumberStyles.Integer && provider == null) { - Assert.False(IntPtr.TryParse(value, out result)); + Assert.False(nint.TryParse(value, out result)); Assert.Equal(default, result); - Assert.Throws(exceptionType, () => IntPtr.Parse(value)); + Assert.Throws(exceptionType, () => nint.Parse(value)); } // Default provider if (provider == null) { - Assert.Throws(exceptionType, () => IntPtr.Parse(value, style)); + Assert.Throws(exceptionType, () => nint.Parse(value, style)); // Substitute default NumberFormatInfo - Assert.False(IntPtr.TryParse(value, style, new NumberFormatInfo(), out result)); + Assert.False(nint.TryParse(value, style, new NumberFormatInfo(), out result)); Assert.Equal(default, result); - Assert.Throws(exceptionType, () => IntPtr.Parse(value, style, new NumberFormatInfo())); + Assert.Throws(exceptionType, () => nint.Parse(value, style, new NumberFormatInfo())); } // Default style if (style == NumberStyles.Integer) { - Assert.Throws(exceptionType, () => IntPtr.Parse(value, provider)); + Assert.Throws(exceptionType, () => nint.Parse(value, provider)); } // Full overloads - Assert.False(IntPtr.TryParse(value, style, provider, out result)); + Assert.False(nint.TryParse(value, style, provider, out result)); Assert.Equal(default, result); - Assert.Throws(exceptionType, () => IntPtr.Parse(value, style, provider)); + Assert.Throws(exceptionType, () => nint.Parse(value, style, provider)); } [Theory] @@ -786,12 +806,12 @@ public static void Parse_Invalid(string value, NumberStyles style, IFormatProvid [InlineData(unchecked((NumberStyles)0xFFFFFC00), "style")] public static void TryParse_InvalidNumberStyle_ThrowsArgumentException(NumberStyles style, string paramName) { - IntPtr result = (IntPtr)0; - AssertExtensions.Throws(paramName, () => IntPtr.TryParse("1", style, null, out result)); - Assert.Equal(default(IntPtr), result); + nint result = (nint)0; + AssertExtensions.Throws(paramName, () => nint.TryParse("1", style, null, out result)); + Assert.Equal(default(nint), result); - AssertExtensions.Throws(paramName, () => IntPtr.Parse("1", style)); - AssertExtensions.Throws(paramName, () => IntPtr.Parse("1", style, null)); + AssertExtensions.Throws(paramName, () => nint.Parse("1", style)); + AssertExtensions.Throws(paramName, () => nint.Parse("1", style, null)); } public static IEnumerable Parse_ValidWithOffsetCount_TestData() @@ -811,15 +831,15 @@ public static IEnumerable Parse_ValidWithOffsetCount_TestData() NumberFormatInfo emptyNegativeFormat = new NumberFormatInfo() { NegativeSign = "" }; // None - yield return new object[] { "2147483647", 1, 9, NumberStyles.None, null, (IntPtr)147483647 }; - yield return new object[] { "2147483647", 1, 1, NumberStyles.None, null, (IntPtr)1 }; - yield return new object[] { "123\0\0", 2, 2, NumberStyles.None, null, (IntPtr)3 }; + yield return new object[] { "2147483647", 1, 9, NumberStyles.None, null, (nint)147483647 }; + yield return new object[] { "2147483647", 1, 1, NumberStyles.None, null, (nint)1 }; + yield return new object[] { "123\0\0", 2, 2, NumberStyles.None, null, (nint)3 }; // Hex - yield return new object[] { "abc", 0, 1, NumberStyles.HexNumber, null, (IntPtr)0xa }; - yield return new object[] { "ABC", 1, 1, NumberStyles.HexNumber, null, (IntPtr)0xB }; - yield return new object[] { "FFFFFFFF", 6, 2, NumberStyles.HexNumber, null, (IntPtr)0xFF }; - yield return new object[] { "FFFFFFFF", 0, 1, NumberStyles.HexNumber, null, (IntPtr)0xF }; + yield return new object[] { "abc", 0, 1, NumberStyles.HexNumber, null, (nint)0xa }; + yield return new object[] { "ABC", 1, 1, NumberStyles.HexNumber, null, (nint)0xB }; + yield return new object[] { "FFFFFFFF", 6, 2, NumberStyles.HexNumber, null, (nint)0xFF }; + yield return new object[] { "FFFFFFFF", 0, 1, NumberStyles.HexNumber, null, (nint)0xF }; // Currency yield return new object[] { "-$1000", 1, 5, NumberStyles.Currency, new NumberFormatInfo() @@ -827,11 +847,11 @@ public static IEnumerable Parse_ValidWithOffsetCount_TestData() CurrencySymbol = "$", CurrencyGroupSeparator = "|", NumberGroupSeparator = "/" - }, (IntPtr)1000 }; + }, (nint)1000 }; NumberFormatInfo emptyCurrencyFormat = new NumberFormatInfo() { CurrencySymbol = "" }; - yield return new object[] { "100", 1, 2, NumberStyles.Currency, emptyCurrencyFormat, (IntPtr)0 }; - yield return new object[] { "100", 0, 1, NumberStyles.Currency, emptyCurrencyFormat, (IntPtr)1 }; + yield return new object[] { "100", 1, 2, NumberStyles.Currency, emptyCurrencyFormat, (nint)0 }; + yield return new object[] { "100", 0, 1, NumberStyles.Currency, emptyCurrencyFormat, (nint)1 }; // If CurrencySymbol and Negative are the same, NegativeSign is preferred NumberFormatInfo sameCurrencyNegativeSignFormat = new NumberFormatInfo() @@ -839,41 +859,41 @@ public static IEnumerable Parse_ValidWithOffsetCount_TestData() NegativeSign = "|", CurrencySymbol = "|" }; - yield return new object[] { "1000", 1, 3, NumberStyles.AllowCurrencySymbol | NumberStyles.AllowLeadingSign, sameCurrencyNegativeSignFormat, (IntPtr)0 }; - yield return new object[] { "|1000", 0, 2, NumberStyles.AllowCurrencySymbol | NumberStyles.AllowLeadingSign, sameCurrencyNegativeSignFormat, (IntPtr)(-1) }; + yield return new object[] { "1000", 1, 3, NumberStyles.AllowCurrencySymbol | NumberStyles.AllowLeadingSign, sameCurrencyNegativeSignFormat, (nint)0 }; + yield return new object[] { "|1000", 0, 2, NumberStyles.AllowCurrencySymbol | NumberStyles.AllowLeadingSign, sameCurrencyNegativeSignFormat, (nint)(-1) }; // Any - yield return new object[] { "123", 0, 2, NumberStyles.Any, null, (IntPtr)12 }; + yield return new object[] { "123", 0, 2, NumberStyles.Any, null, (nint)12 }; // AllowLeadingSign - yield return new object[] { "-2147483648", 0, 10, NumberStyles.AllowLeadingSign, null, (IntPtr)(-214748364) }; + yield return new object[] { "-2147483648", 0, 10, NumberStyles.AllowLeadingSign, null, (nint)(-214748364) }; // AllowTrailingSign - yield return new object[] { "123-", 0, 3, NumberStyles.AllowTrailingSign, null, (IntPtr)123 }; + yield return new object[] { "123-", 0, 3, NumberStyles.AllowTrailingSign, null, (nint)123 }; // AllowExponent - yield return new object[] { "1E2", 0, 1, NumberStyles.AllowExponent, null, (IntPtr)1 }; - yield return new object[] { "1E+2", 3, 1, NumberStyles.AllowExponent, null, (IntPtr)2 }; - yield return new object[] { "(1E2)", 1, 3, NumberStyles.AllowExponent | NumberStyles.AllowParentheses, null, (IntPtr)1E2 }; - yield return new object[] { "-1E2", 1, 3, NumberStyles.AllowExponent | NumberStyles.AllowLeadingSign, null, (IntPtr)1E2 }; + yield return new object[] { "1E2", 0, 1, NumberStyles.AllowExponent, null, (nint)1 }; + yield return new object[] { "1E+2", 3, 1, NumberStyles.AllowExponent, null, (nint)2 }; + yield return new object[] { "(1E2)", 1, 3, NumberStyles.AllowExponent | NumberStyles.AllowParentheses, null, (nint)1E2 }; + yield return new object[] { "-1E2", 1, 3, NumberStyles.AllowExponent | NumberStyles.AllowLeadingSign, null, (nint)1E2 }; } [Theory] [MemberData(nameof(Parse_ValidWithOffsetCount_TestData))] - public static void Parse_Span_Valid(string value, int offset, int count, NumberStyles style, IFormatProvider provider, IntPtr expected) + public static void Parse_Span_Valid(string value, int offset, int count, NumberStyles style, IFormatProvider provider, nint expected) { - IntPtr result; + nint result; // Default style and provider if (style == NumberStyles.Integer && provider == null) { - Assert.True(IntPtr.TryParse(value.AsSpan(offset, count), out result)); + Assert.True(nint.TryParse(value.AsSpan(offset, count), out result)); Assert.Equal(expected, result); } - Assert.Equal(expected, IntPtr.Parse(value.AsSpan(offset, count), style, provider)); + Assert.Equal(expected, nint.Parse(value.AsSpan(offset, count), style, provider)); - Assert.True(IntPtr.TryParse(value.AsSpan(offset, count), style, provider, out result)); + Assert.True(nint.TryParse(value.AsSpan(offset, count), style, provider, out result)); Assert.Equal(expected, result); } @@ -883,18 +903,18 @@ public static void Parse_Span_Invalid(string value, NumberStyles style, IFormatP { if (value != null) { - IntPtr result; + nint result; // Default style and provider if (style == NumberStyles.Integer && provider == null) { - Assert.False(IntPtr.TryParse(value.AsSpan(), out result)); + Assert.False(nint.TryParse(value.AsSpan(), out result)); Assert.Equal(default, result); } Assert.Throws(exceptionType, () => int.Parse(value.AsSpan(), style, provider)); - Assert.False(IntPtr.TryParse(value.AsSpan(), style, provider, out result)); + Assert.False(nint.TryParse(value.AsSpan(), style, provider, out result)); Assert.Equal(default, result); } } @@ -907,7 +927,7 @@ public static void ToString_N_F_EmptyNumberGroup_Success(string specifier) var nfi = (NumberFormatInfo)NumberFormatInfo.InvariantInfo.Clone(); nfi.NumberGroupSizes = new int[0]; nfi.NumberGroupSeparator = ","; - Assert.Equal("1234", ((IntPtr)1234).ToString($"{specifier}0", nfi)); + Assert.Equal("1234", ((nint)1234).ToString($"{specifier}0", nfi)); } [Fact] @@ -916,7 +936,7 @@ public static void ToString_P_EmptyPercentGroup_Success() var nfi = (NumberFormatInfo)NumberFormatInfo.InvariantInfo.Clone(); nfi.PercentGroupSizes = new int[0]; nfi.PercentSymbol = "%"; - Assert.Equal("123400 %", ((IntPtr)1234).ToString("P0", nfi)); + Assert.Equal("123400 %", ((nint)1234).ToString("P0", nfi)); } [Fact] @@ -925,12 +945,12 @@ public static void ToString_C_EmptyPercentGroup_Success() var nfi = (NumberFormatInfo)NumberFormatInfo.InvariantInfo.Clone(); nfi.CurrencyGroupSizes = new int[0]; nfi.CurrencySymbol = "$"; - Assert.Equal("$1234", ((IntPtr)1234).ToString("C0", nfi)); + Assert.Equal("$1234", ((nint)1234).ToString("C0", nfi)); } [Theory] [MemberData(nameof(ToString_TestData))] - public static void TryFormat(IntPtr i, string format, IFormatProvider provider, string expected) + public static void TryFormat(nint i, string format, IFormatProvider provider, string expected) { char[] actual; int charsWritten; diff --git a/src/libraries/System.Runtime/tests/System/UIntPtrTests.cs b/src/libraries/System.Runtime/tests/System/UIntPtrTests.cs index bd35fe0192cb5..08051f2f6b74c 100644 --- a/src/libraries/System.Runtime/tests/System/UIntPtrTests.cs +++ b/src/libraries/System.Runtime/tests/System/UIntPtrTests.cs @@ -4,6 +4,8 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.Linq; +using System.Reflection; using System.Runtime.CompilerServices; using Xunit; @@ -16,188 +18,210 @@ public static class UIntPtrTests [Fact] public static void Zero() { - VerifyPointer(UIntPtr.Zero, 0); + VerifyPointer(nuint.Zero, 0); } [Fact] public static void Ctor_UInt() { uint i = 42; - VerifyPointer(new UIntPtr(i), i); - VerifyPointer((UIntPtr)i, i); + VerifyPointer(new nuint(i), i); + VerifyPointer(i, i); } [ConditionalFact(nameof(Is64Bit))] public static void Ctor_ULong() { ulong l = 0x0fffffffffffffff; - VerifyPointer(new UIntPtr(l), l); - VerifyPointer((UIntPtr)l, l); + VerifyPointer(new nuint(l), l); + VerifyPointer((nuint)l, l); } [ConditionalFact(nameof(Is64Bit))] public static unsafe void TestCtor_VoidPointer_ToPointer() { - void* pv = new UIntPtr(42).ToPointer(); + void* pv = new nuint(42).ToPointer(); - VerifyPointer(new UIntPtr(pv), 42); - VerifyPointer((UIntPtr)pv, 42); + VerifyPointer(new nuint(pv), 42); + VerifyPointer((nuint)pv, 42); } [ConditionalFact(nameof(Is64Bit))] public static unsafe void TestSize() { - Assert.Equal(sizeof(void*), UIntPtr.Size); + Assert.Equal(sizeof(void*), nuint.Size); } public static IEnumerable Add_TestData() { - yield return new object[] { new UIntPtr(42), 6, (ulong)48 }; - yield return new object[] { new UIntPtr(40), 0, (ulong)40 }; - yield return new object[] { new UIntPtr(38), -2, (ulong)36 }; + yield return new object[] { (nuint)42, 6, (ulong)48 }; + yield return new object[] { (nuint)40, 0, (ulong)40 }; + yield return new object[] { (nuint)38, -2, (ulong)36 }; - yield return new object[] { new UIntPtr(0xffffffffffffffff), 5, unchecked(0x0000000000000004) }; /// Add should not throw an OverflowException + yield return new object[] { unchecked((nuint)0xffffffffffffffff), 5, unchecked(0x0000000000000004) }; /// Add should not throw an OverflowException } [ConditionalTheory(nameof(Is64Bit))] [MemberData(nameof(Add_TestData))] - public static void Add(UIntPtr ptr, int offset, ulong expected) + public static void Add(nuint value, int offset, ulong expected) { - UIntPtr p1 = UIntPtr.Add(ptr, offset); - VerifyPointer(p1, expected); + MethodInfo add = typeof(nuint).GetMethod("Add"); - UIntPtr p2 = ptr + offset; - VerifyPointer(p2, expected); + nuint result = (nuint)add.Invoke(null, new object[] { value, offset }); + VerifyPointer(result, expected); - UIntPtr p3 = ptr; - p3 += offset; - VerifyPointer(p3, expected); + MethodInfo opAddition = typeof(nuint).GetMethod("op_Addition"); + + result = (nuint)opAddition.Invoke(null, new object[] { value, offset }); + VerifyPointer(result, expected); } public static IEnumerable Subtract_TestData() { - yield return new object[] { new UIntPtr(42), 6, (ulong)36 }; - yield return new object[] { new UIntPtr(40), 0, (ulong)40 }; - yield return new object[] { new UIntPtr(38), -2, (ulong)40 }; + yield return new object[] { (nuint)42, 6, (ulong)36 }; + yield return new object[] { (nuint)40, 0, (ulong)40 }; + yield return new object[] { (nuint)38, -2, (ulong)40 }; } [ConditionalTheory(nameof(Is64Bit))] [MemberData(nameof(Subtract_TestData))] - public static void Subtract(UIntPtr ptr, int offset, ulong expected) + public static void Subtract(nuint value, int offset, ulong expected) { - UIntPtr p1 = UIntPtr.Subtract(ptr, offset); - VerifyPointer(p1, expected); + MethodInfo subtract = typeof(nuint).GetMethod("Subtract"); + + nuint result = (nuint)subtract.Invoke(null, new object[] { value, offset }); + VerifyPointer(result, expected); - UIntPtr p2 = ptr - offset; - VerifyPointer(p2, expected); + MethodInfo opSubtraction = typeof(nuint).GetMethod("op_Subtraction"); - UIntPtr p3 = ptr; - p3 -= offset; - VerifyPointer(p3, expected); + result = (nuint)opSubtraction.Invoke(null, new object[] { value, offset }); + VerifyPointer(result, expected); } public static IEnumerable Equals_TestData() { - yield return new object[] { new UIntPtr(42), new UIntPtr(42), true }; - yield return new object[] { new UIntPtr(42), new UIntPtr(43), false }; - yield return new object[] { new UIntPtr(42), 42, false }; - yield return new object[] { new UIntPtr(42), null, false }; + yield return new object[] { (nuint)42, (nuint)42, true }; + yield return new object[] { (nuint)42, (nuint)43, false }; + yield return new object[] { (nuint)42, 42, false }; + yield return new object[] { (nuint)42, null, false }; } [Theory] [MemberData(nameof(Equals_TestData))] - public static void EqualsTest(UIntPtr ptr1, object obj, bool expected) + public static void EqualsTest(nuint value, object obj, bool expected) { - if (obj is UIntPtr) + if (obj is nuint other) { - UIntPtr ptr2 = (UIntPtr)obj; - Assert.Equal(expected, ptr1 == ptr2); - Assert.Equal(!expected, ptr1 != ptr2); - Assert.Equal(expected, ptr1.GetHashCode().Equals(ptr2.GetHashCode())); + Assert.Equal(expected, value == other); + Assert.Equal(!expected, value != other); + Assert.Equal(expected, value.GetHashCode().Equals(other.GetHashCode())); - IEquatable iEquatable = ptr1; - Assert.Equal(expected, iEquatable.Equals((UIntPtr)obj)); + IEquatable iEquatable = value; + Assert.Equal(expected, iEquatable.Equals((nuint)obj)); } - Assert.Equal(expected, ptr1.Equals(obj)); - Assert.Equal(ptr1.GetHashCode(), ptr1.GetHashCode()); + Assert.Equal(expected, value.Equals(obj)); + Assert.Equal(value.GetHashCode(), value.GetHashCode()); } [ConditionalFact(nameof(Is64Bit))] - public static unsafe void TestImplicitCast() + public static unsafe void TestExplicitCast() { - var ptr = new UIntPtr(42); + nuint value = 42u; + + MethodInfo[] methods = typeof(nuint).GetMethods(); - uint i = (uint)ptr; + MethodInfo opExplicitFromUInt32 = typeof(nuint).GetMethod("op_Explicit", new Type[] { typeof(uint) }); + MethodInfo opExplicitToUInt32 = methods.Single((methodInfo) => (methodInfo.Name == "op_Explicit") && (methodInfo.ReturnType == typeof(uint))); + + uint i = (uint)opExplicitToUInt32.Invoke(null, new object[] { value }); Assert.Equal(42u, i); - Assert.Equal(ptr, (UIntPtr)i); + Assert.Equal(value, (nuint)opExplicitFromUInt32.Invoke(null, new object[] { i })); + + MethodInfo opExplicitFromUInt64 = typeof(nuint).GetMethod("op_Explicit", new Type[] { typeof(ulong) }); + MethodInfo opExplicitToUInt64 = methods.Single((methodInfo) => (methodInfo.Name == "op_Explicit") && (methodInfo.ReturnType == typeof(ulong))); - ulong l = (ulong)ptr; + ulong l = (ulong)opExplicitToUInt64.Invoke(null, new object[] { value }); Assert.Equal(42u, l); - Assert.Equal(ptr, (UIntPtr)l); + Assert.Equal(value, (nuint)opExplicitFromUInt64.Invoke(null, new object[] { l })); + + MethodInfo opExplicitFromPointer = typeof(nuint).GetMethod("op_Explicit", new Type[] { typeof(void*) }); + MethodInfo opExplicitToPointer = methods.Single((methodInfo) => (methodInfo.Name == "op_Explicit") && (methodInfo.ReturnType == typeof(void*))); - void* v = (void*)ptr; - Assert.Equal(ptr, (UIntPtr)v); + void* v = Pointer.Unbox(opExplicitToPointer.Invoke(null, new object[] { value })); + Assert.Equal(value, (nuint)opExplicitFromPointer.Invoke(null, new object[] { Pointer.Box(v, typeof(void*)) })); - ptr = new UIntPtr(0x7fffffffffffffff); - Assert.Throws(() => (uint)ptr); + value = unchecked((nuint)0x7fffffffffffffff); + Exception ex = Assert.ThrowsAny(() => opExplicitToUInt32.Invoke(null, new object[] { value })); + + + if (ex is TargetInvocationException) + { + // RyuJIT throws TargetInvocationException wrapping an OverflowException + // while Mono directly throws the OverflowException + ex = ex.InnerException; + } + Assert.IsType(ex); } [ConditionalFact(nameof(Is64Bit))] public static void GetHashCodeRespectAllBits() { - var ptr1 = new UIntPtr(0x123456FFFFFFFF); - var ptr2 = new UIntPtr(0x654321FFFFFFFF); - Assert.NotEqual(ptr1.GetHashCode(), ptr2.GetHashCode()); + var value = unchecked((nuint)0x123456FFFFFFFF); + var other = unchecked((nuint)0x654321FFFFFFFF); + Assert.NotEqual(value.GetHashCode(), other.GetHashCode()); } - private static void VerifyPointer(UIntPtr ptr, ulong expected) + private static void VerifyPointer(nuint value, ulong expected) { - Assert.Equal(expected, ptr.ToUInt64()); + Assert.Equal(expected, value.ToUInt64()); uint expected32 = unchecked((uint)expected); if (expected32 != expected) { - Assert.Throws(() => ptr.ToUInt32()); + Assert.Throws(() => value.ToUInt32()); return; } - Assert.Equal(expected32, ptr.ToUInt32()); + Assert.Equal(expected32, value.ToUInt32()); - Assert.Equal(expected.ToString(), ptr.ToString()); + Assert.Equal(expected.ToString(), value.ToString()); - Assert.Equal(ptr, new UIntPtr(expected)); - Assert.True(ptr == new UIntPtr(expected)); - Assert.False(ptr != new UIntPtr(expected)); + Assert.Equal(value, checked((nuint)expected)); + Assert.True(value == checked((nuint)expected)); + Assert.False(value != checked((nuint)expected)); - Assert.NotEqual(ptr, new UIntPtr(expected + 1)); - Assert.False(ptr == new UIntPtr(expected + 1)); - Assert.True(ptr != new UIntPtr(expected + 1)); + Assert.NotEqual(value, checked((nuint)expected + 1)); + Assert.False(value == checked((nuint)expected + 1)); + Assert.True(value != checked((nuint)expected + 1)); } + public static nuint RealMax => Is64Bit ? unchecked((nuint)ulong.MaxValue) : uint.MaxValue; + public static nuint RealMin => Is64Bit ? unchecked((nuint)ulong.MinValue) : uint.MinValue; + [Fact] public static void Ctor_Empty() { - var i = new UIntPtr(); - Assert.Equal((UIntPtr)0, i); + var i = new nuint(); + Assert.Equal((nuint)0, i); } [Fact] public static void Ctor_Value() { - UIntPtr i = (UIntPtr)41; - Assert.Equal((UIntPtr)41, i); + nuint i = 41; + Assert.Equal((nuint)41, i); } [Fact] public static void MaxValue() { - Assert.Equal(UIntPtr.Size == 4 ? (UIntPtr)uint.MaxValue : (UIntPtr)ulong.MaxValue, UIntPtr.MaxValue); + Assert.Equal(RealMax, nuint.MaxValue); } [Fact] public static void MinValue() { - Assert.Equal((UIntPtr)0, UIntPtr.MinValue); + Assert.Equal(RealMin, nuint.MinValue); } [Theory] @@ -209,10 +233,10 @@ public static void MinValue() [InlineData(234u, null, 1)] public static void CompareTo_Other_ReturnsExpected(uint i0, object value, int expected) { - var i = (UIntPtr)i0; + nuint i = i0; if (value is uint uintValue) { - var uintPtrValue = (UIntPtr)uintValue; + nuint uintPtrValue = uintValue; Assert.Equal(expected, Math.Sign(i.CompareTo(uintPtrValue))); Assert.Equal(expected, Math.Sign(i.CompareTo((object)uintPtrValue))); @@ -226,9 +250,9 @@ public static void CompareTo_Other_ReturnsExpected(uint i0, object value, int ex [Theory] [InlineData("a")] [InlineData(234)] - public static void CompareTo_ObjectNotUIntPtr_ThrowsArgumentException(object value) + public static void CompareTo_ObjectNotnuint_ThrowsArgumentException(object value) { - AssertExtensions.Throws(null, () => ((UIntPtr)123).CompareTo(value)); + AssertExtensions.Throws(null, () => ((nuint)123).CompareTo(value)); } public static IEnumerable ToString_TestData() @@ -237,16 +261,16 @@ public static IEnumerable ToString_TestData() { foreach (string defaultSpecifier in new[] { "G", "G\0", "\0N222", "\0", "", "R" }) { - yield return new object[] { (UIntPtr)0, defaultSpecifier, defaultFormat, "0" }; - yield return new object[] { (UIntPtr)4567, defaultSpecifier, defaultFormat, "4567" }; - yield return new object[] { UIntPtr.MaxValue, defaultSpecifier, defaultFormat, Is64Bit ? "18446744073709551615" : "4294967295" }; + yield return new object[] { (nuint)0, defaultSpecifier, defaultFormat, "0" }; + yield return new object[] { (nuint)4567, defaultSpecifier, defaultFormat, "4567" }; + yield return new object[] { nuint.MaxValue, defaultSpecifier, defaultFormat, Is64Bit ? "18446744073709551615" : "4294967295" }; } - yield return new object[] { (UIntPtr)4567, "D", defaultFormat, "4567" }; - yield return new object[] { (UIntPtr)4567, "D18", defaultFormat, "000000000000004567" }; + yield return new object[] { (nuint)4567, "D", defaultFormat, "4567" }; + yield return new object[] { (nuint)4567, "D18", defaultFormat, "000000000000004567" }; - yield return new object[] { (UIntPtr)0x2468, "x", defaultFormat, "2468" }; - yield return new object[] { (UIntPtr)2468, "N", defaultFormat, string.Format("{0:N}", 2468.00) }; + yield return new object[] { (nuint)0x2468, "x", defaultFormat, "2468" }; + yield return new object[] { (nuint)2468, "N", defaultFormat, string.Format("{0:N}", 2468.00) }; } var customFormat = new NumberFormatInfo() @@ -261,15 +285,15 @@ public static IEnumerable ToString_TestData() PercentDecimalSeparator = ".", PercentDecimalDigits = 5 }; - yield return new object[] { (UIntPtr)2468, "N", customFormat, "2*468~00" }; - yield return new object[] { (UIntPtr)123, "E", customFormat, "1~230000E&002" }; - yield return new object[] { (UIntPtr)123, "F", customFormat, "123~00" }; - yield return new object[] { (UIntPtr)123, "P", customFormat, "12,300.00000 @" }; + yield return new object[] { (nuint)2468, "N", customFormat, "2*468~00" }; + yield return new object[] { (nuint)123, "E", customFormat, "1~230000E&002" }; + yield return new object[] { (nuint)123, "F", customFormat, "123~00" }; + yield return new object[] { (nuint)123, "P", customFormat, "12,300.00000 @" }; } [Theory] [MemberData(nameof(ToString_TestData))] - public static void ToStringTest(UIntPtr i, string format, IFormatProvider provider, string expected) + public static void ToStringTest(nuint i, string format, IFormatProvider provider, string expected) { // Format is case insensitive string upperFormat = format.ToUpperInvariant(); @@ -302,19 +326,19 @@ public static void ToStringTest(UIntPtr i, string format, IFormatProvider provid [Fact] public static void ToString_InvalidFormat_ThrowsFormatException() { - UIntPtr i = (UIntPtr)123; + nuint i = 123; Assert.Throws(() => i.ToString("Y")); // Invalid format Assert.Throws(() => i.ToString("Y", null)); // Invalid format } public static IEnumerable Parse_Valid_TestData() { - // Reuse all IntPtr test data that's relevant + // Reuse all nint test data that's relevant foreach (object[] objs in IntPtrTests.Parse_Valid_TestData()) { - if ((long)(IntPtr)objs[3] < 0) continue; - var intPtr = (IntPtr)objs[3]; - yield return new object[] { objs[0], objs[1], objs[2], Unsafe.As(ref intPtr) }; + if ((long)(nint)objs[3] < 0) continue; + var intPtr = (nint)objs[3]; + yield return new object[] { objs[0], objs[1], objs[2], Unsafe.As(ref intPtr) }; } // All lengths decimal @@ -325,7 +349,7 @@ public static IEnumerable Parse_Valid_TestData() { result = (uint)(result * 10 + (i % 10)); s += (i % 10).ToString(); - yield return new object[] { s, NumberStyles.Integer, null, (UIntPtr)result }; + yield return new object[] { s, NumberStyles.Integer, null, (nuint)result }; } } @@ -341,49 +365,49 @@ public static IEnumerable Parse_Valid_TestData() } } - // And test boundary conditions for IntPtr - yield return new object[] { Is64Bit ? "18446744073709551615" : "4294967295", NumberStyles.Integer, null, UIntPtr.MaxValue }; - yield return new object[] { Is64Bit ? "+18446744073709551615" : "+4294967295", NumberStyles.Integer, null, UIntPtr.MaxValue }; - yield return new object[] { Is64Bit ? " +18446744073709551615 " : " +4294967295 ", NumberStyles.Integer, null, UIntPtr.MaxValue }; - yield return new object[] { Is64Bit ? "FFFFFFFFFFFFFFFF" : "FFFFFFFF", NumberStyles.HexNumber, null, UIntPtr.MaxValue }; - yield return new object[] { Is64Bit ? " FFFFFFFFFFFFFFFF " : " FFFFFFFF ", NumberStyles.HexNumber, null, UIntPtr.MaxValue }; + // And test boundary conditions for nuint + yield return new object[] { Is64Bit ? "18446744073709551615" : "4294967295", NumberStyles.Integer, null, nuint.MaxValue }; + yield return new object[] { Is64Bit ? "+18446744073709551615" : "+4294967295", NumberStyles.Integer, null, nuint.MaxValue }; + yield return new object[] { Is64Bit ? " +18446744073709551615 " : " +4294967295 ", NumberStyles.Integer, null, nuint.MaxValue }; + yield return new object[] { Is64Bit ? "FFFFFFFFFFFFFFFF" : "FFFFFFFF", NumberStyles.HexNumber, null, nuint.MaxValue }; + yield return new object[] { Is64Bit ? " FFFFFFFFFFFFFFFF " : " FFFFFFFF ", NumberStyles.HexNumber, null, nuint.MaxValue }; } [Theory] [MemberData(nameof(Parse_Valid_TestData))] - public static void Parse_Valid(string value, NumberStyles style, IFormatProvider provider, UIntPtr expected) + public static void Parse_Valid(string value, NumberStyles style, IFormatProvider provider, nuint expected) { - UIntPtr result; + nuint result; // Default style and provider if (style == NumberStyles.Integer && provider == null) { - Assert.True(UIntPtr.TryParse(value, out result)); + Assert.True(nuint.TryParse(value, out result)); Assert.Equal(expected, result); - Assert.Equal(expected, UIntPtr.Parse(value)); + Assert.Equal(expected, nuint.Parse(value)); } // Default provider if (provider == null) { - Assert.Equal(expected, UIntPtr.Parse(value, style)); + Assert.Equal(expected, nuint.Parse(value, style)); // Substitute default NumberFormatInfo - Assert.True(UIntPtr.TryParse(value, style, new NumberFormatInfo(), out result)); + Assert.True(nuint.TryParse(value, style, new NumberFormatInfo(), out result)); Assert.Equal(expected, result); - Assert.Equal(expected, UIntPtr.Parse(value, style, new NumberFormatInfo())); + Assert.Equal(expected, nuint.Parse(value, style, new NumberFormatInfo())); } // Default style if (style == NumberStyles.Integer) { - Assert.Equal(expected, UIntPtr.Parse(value, provider)); + Assert.Equal(expected, nuint.Parse(value, provider)); } // Full overloads - Assert.True(UIntPtr.TryParse(value, style, provider, out result)); + Assert.True(nuint.TryParse(value, style, provider, out result)); Assert.Equal(expected, result); - Assert.Equal(expected, UIntPtr.Parse(value, style, provider)); + Assert.Equal(expected, nuint.Parse(value, style, provider)); } public static IEnumerable Parse_Invalid_TestData() @@ -397,37 +421,37 @@ public static IEnumerable Parse_Invalid_TestData() [MemberData(nameof(Parse_Invalid_TestData))] public static void Parse_Invalid(string value, NumberStyles style, IFormatProvider provider, Type exceptionType) { - UIntPtr result; + nuint result; // Default style and provider if (style == NumberStyles.Integer && provider == null) { - Assert.False(UIntPtr.TryParse(value, out result)); + Assert.False(nuint.TryParse(value, out result)); Assert.Equal(default, result); - Assert.Throws(exceptionType, () => UIntPtr.Parse(value)); + Assert.Throws(exceptionType, () => nuint.Parse(value)); } // Default provider if (provider == null) { - Assert.Throws(exceptionType, () => UIntPtr.Parse(value, style)); + Assert.Throws(exceptionType, () => nuint.Parse(value, style)); // Substitute default NumberFormatInfo - Assert.False(UIntPtr.TryParse(value, style, new NumberFormatInfo(), out result)); + Assert.False(nuint.TryParse(value, style, new NumberFormatInfo(), out result)); Assert.Equal(default, result); - Assert.Throws(exceptionType, () => UIntPtr.Parse(value, style, new NumberFormatInfo())); + Assert.Throws(exceptionType, () => nuint.Parse(value, style, new NumberFormatInfo())); } // Default style if (style == NumberStyles.Integer) { - Assert.Throws(exceptionType, () => UIntPtr.Parse(value, provider)); + Assert.Throws(exceptionType, () => nuint.Parse(value, provider)); } // Full overloads - Assert.False(UIntPtr.TryParse(value, style, provider, out result)); + Assert.False(nuint.TryParse(value, style, provider, out result)); Assert.Equal(default, result); - Assert.Throws(exceptionType, () => UIntPtr.Parse(value, style, provider)); + Assert.Throws(exceptionType, () => nuint.Parse(value, style, provider)); } [Theory] @@ -435,12 +459,12 @@ public static void Parse_Invalid(string value, NumberStyles style, IFormatProvid [InlineData(unchecked((NumberStyles)0xFFFFFC00), "style")] public static void TryParse_InvalidNumberStyle_ThrowsArgumentException(NumberStyles style, string paramName) { - UIntPtr result = (UIntPtr)0; - AssertExtensions.Throws(paramName, () => UIntPtr.TryParse("1", style, null, out result)); - Assert.Equal(default(UIntPtr), result); + nuint result = 0; + AssertExtensions.Throws(paramName, () => nuint.TryParse("1", style, null, out result)); + Assert.Equal(default(nuint), result); - AssertExtensions.Throws(paramName, () => UIntPtr.Parse("1", style)); - AssertExtensions.Throws(paramName, () => UIntPtr.Parse("1", style, null)); + AssertExtensions.Throws(paramName, () => nuint.Parse("1", style)); + AssertExtensions.Throws(paramName, () => nuint.Parse("1", style, null)); } public static IEnumerable Parse_ValidWithOffsetCount_TestData() @@ -450,31 +474,31 @@ public static IEnumerable Parse_ValidWithOffsetCount_TestData() yield return new object[] { inputs[0], 0, ((string)inputs[0]).Length, inputs[1], inputs[2], inputs[3] }; } - yield return new object[] { "123", 0, 2, NumberStyles.Integer, null, (UIntPtr)12 }; - yield return new object[] { "123", 1, 2, NumberStyles.Integer, null, (UIntPtr)23 }; - yield return new object[] { "4294967295", 0, 1, NumberStyles.Integer, null, (UIntPtr)4 }; - yield return new object[] { "4294967295", 9, 1, NumberStyles.Integer, null, (UIntPtr)5 }; - yield return new object[] { "12", 0, 1, NumberStyles.HexNumber, null, (UIntPtr)0x1 }; - yield return new object[] { "12", 1, 1, NumberStyles.HexNumber, null, (UIntPtr)0x2 }; - yield return new object[] { "$1,000", 1, 3, NumberStyles.Currency, new NumberFormatInfo() { CurrencySymbol = "$" }, (UIntPtr)10 }; + yield return new object[] { "123", 0, 2, NumberStyles.Integer, null, (nuint)12 }; + yield return new object[] { "123", 1, 2, NumberStyles.Integer, null, (nuint)23 }; + yield return new object[] { "4294967295", 0, 1, NumberStyles.Integer, null, (nuint)4 }; + yield return new object[] { "4294967295", 9, 1, NumberStyles.Integer, null, (nuint)5 }; + yield return new object[] { "12", 0, 1, NumberStyles.HexNumber, null, (nuint)0x1 }; + yield return new object[] { "12", 1, 1, NumberStyles.HexNumber, null, (nuint)0x2 }; + yield return new object[] { "$1,000", 1, 3, NumberStyles.Currency, new NumberFormatInfo() { CurrencySymbol = "$" }, (nuint)10 }; } [Theory] [MemberData(nameof(Parse_ValidWithOffsetCount_TestData))] - public static void Parse_Span_Valid(string value, int offset, int count, NumberStyles style, IFormatProvider provider, UIntPtr expected) + public static void Parse_Span_Valid(string value, int offset, int count, NumberStyles style, IFormatProvider provider, nuint expected) { - UIntPtr result; + nuint result; // Default style and provider if (style == NumberStyles.Integer && provider == null) { - Assert.True(UIntPtr.TryParse(value.AsSpan(offset, count), out result)); + Assert.True(nuint.TryParse(value.AsSpan(offset, count), out result)); Assert.Equal(expected, result); } - Assert.Equal(expected, UIntPtr.Parse(value.AsSpan(offset, count), style, provider)); + Assert.Equal(expected, nuint.Parse(value.AsSpan(offset, count), style, provider)); - Assert.True(UIntPtr.TryParse(value.AsSpan(offset, count), style, provider, out result)); + Assert.True(nuint.TryParse(value.AsSpan(offset, count), style, provider, out result)); Assert.Equal(expected, result); } @@ -484,25 +508,25 @@ public static void Parse_Span_Invalid(string value, NumberStyles style, IFormatP { if (value != null) { - UIntPtr result; + nuint result; // Default style and provider if (style == NumberStyles.Integer && provider == null) { - Assert.False(UIntPtr.TryParse(value.AsSpan(), out result)); + Assert.False(nuint.TryParse(value.AsSpan(), out result)); Assert.Equal(default, result); } - Assert.Throws(exceptionType, () => UIntPtr.Parse(value.AsSpan(), style, provider)); + Assert.Throws(exceptionType, () => nuint.Parse(value.AsSpan(), style, provider)); - Assert.False(UIntPtr.TryParse(value.AsSpan(), style, provider, out result)); + Assert.False(nuint.TryParse(value.AsSpan(), style, provider, out result)); Assert.Equal(default, result); } } [Theory] [MemberData(nameof(ToString_TestData))] - public static void TryFormat(UIntPtr i, string format, IFormatProvider provider, string expected) + public static void TryFormat(nuint i, string format, IFormatProvider provider, string expected) { char[] actual; int charsWritten; diff --git a/src/libraries/System.ServiceModel.Syndication/src/CompatibilitySuppressions.xml b/src/libraries/System.ServiceModel.Syndication/src/CompatibilitySuppressions.xml index 8c59af9e8cb93..9c30d11f2c34e 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/CompatibilitySuppressions.xml +++ b/src/libraries/System.ServiceModel.Syndication/src/CompatibilitySuppressions.xml @@ -102,4 +102,16 @@ lib/netstandard2.0/System.ServiceModel.Syndication.dll lib/net462/System.ServiceModel.Syndication.dll + + CP0002 + M:System.ServiceModel.Syndication.TryParseDateTimeCallback.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.ServiceModel.Syndication.dll + lib/net7.0/System.ServiceModel.Syndication.dll + + + CP0002 + M:System.ServiceModel.Syndication.TryParseUriCallback.#ctor(System.Object,System.IntPtr) + lib/net6.0/System.ServiceModel.Syndication.dll + lib/net7.0/System.ServiceModel.Syndication.dll + \ No newline at end of file diff --git a/src/libraries/System.ServiceProcess.ServiceController/src/CompatibilitySuppressions.xml b/src/libraries/System.ServiceProcess.ServiceController/src/CompatibilitySuppressions.xml index c8e86cf869dbe..638e5bb77ee7b 100644 --- a/src/libraries/System.ServiceProcess.ServiceController/src/CompatibilitySuppressions.xml +++ b/src/libraries/System.ServiceProcess.ServiceController/src/CompatibilitySuppressions.xml @@ -21,4 +21,10 @@ runtimes/win/lib/netstandard2.0/System.ServiceProcess.ServiceController.dll true + + CP0002 + M:System.ServiceProcess.ServiceBase.ServiceMainCallback(System.Int32,System.IntPtr) + lib/net6.0/System.ServiceProcess.ServiceController.dll + lib/net7.0/System.ServiceProcess.ServiceController.dll + \ No newline at end of file diff --git a/src/libraries/System.Speech/src/CompatibilitySuppressions.xml b/src/libraries/System.Speech/src/CompatibilitySuppressions.xml new file mode 100644 index 0000000000000..b667bd360eef2 --- /dev/null +++ b/src/libraries/System.Speech/src/CompatibilitySuppressions.xml @@ -0,0 +1,45 @@ + + + + CP0002 + M:System.Speech.Synthesis.TtsEngine.ITtsEngineSite.Write(System.IntPtr,System.Int32) + lib/net6.0/System.Speech.dll + lib/net7.0/System.Speech.dll + + + CP0006 + M:System.Speech.Synthesis.TtsEngine.ITtsEngineSite.Write(System.IntPtr,System.Int32) + lib/net6.0/System.Speech.dll + lib/net7.0/System.Speech.dll + + + CP0002 + M:System.Speech.Synthesis.TtsEngine.SpeechEventInfo.#ctor(System.Int16,System.Int16,System.Int32,System.IntPtr) + lib/net6.0/System.Speech.dll + lib/net7.0/System.Speech.dll + + + CP0002 + M:System.Speech.Synthesis.TtsEngine.TtsEngineSsml.GetOutputFormat(System.Speech.Synthesis.TtsEngine.SpeakOutputFormat,System.IntPtr) + lib/net6.0/System.Speech.dll + lib/net7.0/System.Speech.dll + + + CP0002 + M:System.Speech.Synthesis.TtsEngine.TtsEngineSsml.Speak(System.Speech.Synthesis.TtsEngine.TextFragment[],System.IntPtr,System.Speech.Synthesis.TtsEngine.ITtsEngineSite) + lib/net6.0/System.Speech.dll + lib/net7.0/System.Speech.dll + + + CP0005 + M:System.Speech.Synthesis.TtsEngine.TtsEngineSsml.GetOutputFormat(System.Speech.Synthesis.TtsEngine.SpeakOutputFormat,System.IntPtr) + lib/net6.0/System.Speech.dll + lib/net7.0/System.Speech.dll + + + CP0005 + M:System.Speech.Synthesis.TtsEngine.TtsEngineSsml.Speak(System.Speech.Synthesis.TtsEngine.TextFragment[],System.IntPtr,System.Speech.Synthesis.TtsEngine.ITtsEngineSite) + lib/net6.0/System.Speech.dll + lib/net7.0/System.Speech.dll + + \ No newline at end of file diff --git a/src/libraries/System.Windows.Extensions/src/CompatibilitySuppressions.xml b/src/libraries/System.Windows.Extensions/src/CompatibilitySuppressions.xml index d05c6dd5c6fbc..e619274d554c8 100644 --- a/src/libraries/System.Windows.Extensions/src/CompatibilitySuppressions.xml +++ b/src/libraries/System.Windows.Extensions/src/CompatibilitySuppressions.xml @@ -1,6 +1,5 @@  - PKV006 .NETCoreApp,Version=v3.1 @@ -9,4 +8,16 @@ PKV007 .NETCoreApp,Version=v3.1-win + + CP0002 + M:System.Security.Cryptography.X509Certificates.X509Certificate2UI.DisplayCertificate(System.Security.Cryptography.X509Certificates.X509Certificate2,System.IntPtr) + lib/net6.0/System.Windows.Extensions.dll + lib/net7.0/System.Windows.Extensions.dll + + + CP0002 + M:System.Security.Cryptography.X509Certificates.X509Certificate2UI.SelectFromCollection(System.Security.Cryptography.X509Certificates.X509Certificate2Collection,System.String,System.String,System.Security.Cryptography.X509Certificates.X509SelectionFlag,System.IntPtr) + lib/net6.0/System.Windows.Extensions.dll + lib/net7.0/System.Windows.Extensions.dll + \ No newline at end of file