From 1d349adada19c05caca2518cd998c1364af77002 Mon Sep 17 00:00:00 2001 From: David Hall Date: Thu, 5 Oct 2023 19:19:05 -0600 Subject: [PATCH] Added nullability to IMAPI --- PInvoke/IMAPI/IMAPIv2.cs | 30 +++++++++++++++--------------- PInvoke/IMAPI/IMAPIv2FS.cs | 29 +++++++++++++++-------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/PInvoke/IMAPI/IMAPIv2.cs b/PInvoke/IMAPI/IMAPIv2.cs index bbfb169b..9c31814c 100644 --- a/PInvoke/IMAPI/IMAPIv2.cs +++ b/PInvoke/IMAPI/IMAPIv2.cs @@ -62,7 +62,7 @@ public static partial class IMAPI { /// Initializes a new instance of the class. /// The update. - public DDiscFormat2DataEventsSink(Action onUpdate) + public DDiscFormat2DataEventsSink(Action? onUpdate) { if (onUpdate is not null) Update += onUpdate; } @@ -90,7 +90,7 @@ public static partial class IMAPI /// /// To stop the write process, call the IDiscFormat2Data::CancelWrite method. /// - public event Action Update; + public event Action? Update; void DDiscFormat2DataEvents.Update(IDiscFormat2Data @object, IDiscFormat2DataEventArgs progress) => Update?.Invoke(@object, progress); } @@ -130,7 +130,7 @@ public static partial class IMAPI { /// Initializes a new instance of the class. /// The on update. - public DDiscFormat2EraseEventsSink(Action onUpdate) + public DDiscFormat2EraseEventsSink(Action? onUpdate) { if (onUpdate is not null) Update += onUpdate; } @@ -144,7 +144,7 @@ public static partial class IMAPI /// can affect the projected duration of the erasure. /// /// - public event Action Update; + public event Action? Update; void DDiscFormat2EraseEvents.Update(IDiscFormat2Erase @object, int elapsedSeconds, int estimatedTotalSeconds) => Update?.Invoke(@object, elapsedSeconds, estimatedTotalSeconds); } @@ -185,7 +185,7 @@ public static partial class IMAPI { /// Initializes a new instance of the class. /// The on update. - public DDiscFormat2RawCDEventsSink(Action onUpdate) + public DDiscFormat2RawCDEventsSink(Action? onUpdate) { if (onUpdate is not null) Update += onUpdate; } @@ -197,7 +197,7 @@ public static partial class IMAPI /// /// To stop the write process, call the IDiscFormat2RawCD::CancelWrite method. /// - public event Action Update; + public event Action? Update; void DDiscFormat2RawCDEvents.Update(IDiscFormat2RawCD @object, IDiscFormat2RawCDEventArgs progress) => Update?.Invoke(@object, progress); } @@ -236,7 +236,7 @@ public static partial class IMAPI { /// Initializes a new instance of the class. /// The on update. - public DDiscFormat2TrackAtOnceEventsSink(Action onUpdate) + public DDiscFormat2TrackAtOnceEventsSink(Action? onUpdate) { if (onUpdate is not null) Update += onUpdate; } @@ -246,7 +246,7 @@ public static partial class IMAPI /// Notifications are sent in response to calling the IDiscFormat2TrackAtOnce::AddAudioTrack method. /// To stop the write process, call the IDiscFormat2TrackAtOnce::CancelAddTrack method. /// - public event Action Update; + public event Action? Update; void DDiscFormat2TrackAtOnceEvents.Update(IDiscFormat2TrackAtOnce @object, IDiscFormat2TrackAtOnceEventArgs progress) => Update?.Invoke(@object, progress); } @@ -295,17 +295,17 @@ public static partial class IMAPI /// Initializes a new instance of the class. /// The delegate to call when a device is added. /// The delegate to call when a device is removed. - public DDiscMaster2EventsSink(Action onAdded, Action onRemoved) + public DDiscMaster2EventsSink(Action? onAdded, Action? onRemoved) { if (onAdded is not null) NotifyDeviceAdded += onAdded; if (onRemoved is not null) NotifyDeviceRemoved += onRemoved; } /// Receives notification when an optical media device is added to the computer. - public event Action NotifyDeviceAdded; + public event Action? NotifyDeviceAdded; /// Receives notification when an optical media device is removed from the computer. - public event Action NotifyDeviceRemoved; + public event Action? NotifyDeviceRemoved; void DDiscMaster2Events.NotifyDeviceAdded(IDiscMaster2 @object, string uniqueId) => NotifyDeviceAdded?.Invoke(@object, uniqueId); void DDiscMaster2Events.NotifyDeviceRemoved(IDiscMaster2 @object, string uniqueId) => NotifyDeviceRemoved?.Invoke(@object, uniqueId); @@ -357,7 +357,7 @@ public static partial class IMAPI { /// Initializes a new instance of the class. /// The on update. - public DWriteEngine2EventsSink(Action onUpdate) + public DWriteEngine2EventsSink(Action? onUpdate) { if (onUpdate is not null) Update += onUpdate; } @@ -379,7 +379,7 @@ public static partial class IMAPI /// /// To stop the write process, call the IWriteEngine2::CancelWrite method. /// - public event Action Update; + public event Action? Update; void DWriteEngine2Events.Update(IWriteEngine2 @object, IWriteEngine2EventArgs progress) => Update?.Invoke(@object, progress); } @@ -3772,7 +3772,7 @@ public static partial class IMAPI // https://docs.microsoft.com/en-us/windows/win32/api/imapi2/nf-imapi2-irawcdimagecreator-addsubcoderwgenerator HRESULT // AddSubcodeRWGenerator( IStream *subcode ); [DispId(0x203)] - void AddSubcodeRWGenerator(IStream subcode); + void AddSubcodeRWGenerator(IStream? subcode); /// Gets or sets the value that defines the type of image file that will be generated. /// An IMAPI_FORMAT2_RAW_CD_DATA_SECTOR_TYPE enumeration that defines the type of image file. @@ -4056,7 +4056,7 @@ public static partial class IMAPI /// // https://docs.microsoft.com/en-us/windows/win32/api/imapi2/nf-imapi2-irawcdimagetrackinfo-put_isrc HRESULT put_ISRC( BSTR value ); [DispId(0x104)] - bool ISRC { set; [return: MarshalAs(UnmanagedType.BStr)] get; } + string? ISRC { set; [return: MarshalAs(UnmanagedType.BStr)] get; } /// /// Sets the digital audio copy "Allowed" bit to one of three values on the resulting media. Please see the diff --git a/PInvoke/IMAPI/IMAPIv2FS.cs b/PInvoke/IMAPI/IMAPIv2FS.cs index 0cf33f81..30410fa9 100644 --- a/PInvoke/IMAPI/IMAPIv2FS.cs +++ b/PInvoke/IMAPI/IMAPIv2FS.cs @@ -1,3 +1,4 @@ +#pragma warning disable IDE1006 // Naming Styles using System.Collections; using System.Runtime.CompilerServices; using System.Runtime.InteropServices.ComTypes; @@ -172,7 +173,7 @@ public static partial class IMAPI { /// Initializes a new instance of the class. /// The delegate to assign to the event. - public DFileSystemImageEventsSink(Action onUpdate) + public DFileSystemImageEventsSink(Action? onUpdate) { if (onUpdate is not null) Update += onUpdate; } @@ -220,7 +221,7 @@ public static partial class IMAPI /// /// /// - public event Action Update; + public event Action? Update; void DFileSystemImageEvents.Update(IFileSystemImage @object, string currentFile, long copiedSectors, long totalSectors) => Update?.Invoke(@object, currentFile, copiedSectors, totalSectors); } @@ -290,7 +291,7 @@ public static partial class IMAPI { /// Initializes a new instance of the class. /// The delegate to call on import update. - public DFileSystemImageImportEventsSink(Action onUpdateImport) + public DFileSystemImageImportEventsSink(Action? onUpdateImport) { if (onUpdateImport is not null) UpdateImport += onUpdateImport; } @@ -323,7 +324,7 @@ public static partial class IMAPI /// Import notifications are generated only for files and directories, and not for associated named streams. /// If the currentItem is a directory, it contains a back slash '' at the end. /// - public event Action UpdateImport; + public event Action? UpdateImport; void DFileSystemImageImportEvents.UpdateImport(IFileSystemImage @object, FsiFileSystems fileSystem, string currentItem, long importedDirectoryItems, long totalDirectoryItems, long importedFileItems, long totalFileItems) => UpdateImport?.Invoke(@object, fileSystem, currentItem, importedDirectoryItems, totalDirectoryItems, importedFileItems, totalFileItems); @@ -689,14 +690,14 @@ public static partial class IMAPI // https://docs.microsoft.com/en-us/windows/win32/api/imapi2fs/nf-imapi2fs-ifilesystemimage-get_importedvolumename HRESULT // get_ImportedVolumeName( BSTR *pVal ); [DispId(5)] - string ImportedVolumeName { [return: MarshalAs(UnmanagedType.BStr)] get; } + string? ImportedVolumeName { [return: MarshalAs(UnmanagedType.BStr)] get; } /// Retrieves the boot image that you want to add to the file system image. /// An IBootOptions interface of the boot image to add to the disc. Is NULL if a boot image has not been specified. // https://docs.microsoft.com/en-us/windows/win32/api/imapi2fs/nf-imapi2fs-ifilesystemimage-get_bootimageoptions HRESULT // get_BootImageOptions( IBootOptions **pVal ); [DispId(6)] - IBootOptions BootImageOptions { [return: MarshalAs(UnmanagedType.Interface)] get; set; } + IBootOptions? BootImageOptions { [return: MarshalAs(UnmanagedType.Interface)] get; set; } /// Retrieves the number of files in the file system image. /// Number of files in the file system image. @@ -908,7 +909,7 @@ public static partial class IMAPI // https://docs.microsoft.com/en-us/windows/win32/api/imapi2fs/nf-imapi2fs-ifilesystemimage-identifyfilesystemsondisc HRESULT // IdentifyFileSystemsOnDisc( IDiscRecorder2 *discRecorder, FsiFileSystems *fileSystems ); [DispId(19)] - FsiFileSystems IdentifyFileSystemsOnDisc(IDiscRecorder2 discRecorder); + FsiFileSystems IdentifyFileSystemsOnDisc(IDiscRecorder2? discRecorder); /// Retrieves the file system to import by default. /// One or more file system values. For possible values, see the FsiFileSystems enumeration type. @@ -1206,14 +1207,14 @@ public static partial class IMAPI // https://docs.microsoft.com/en-us/windows/win32/api/imapi2fs/nf-imapi2fs-ifilesystemimage-get_importedvolumename HRESULT // get_ImportedVolumeName( BSTR *pVal ); [DispId(5)] - new string ImportedVolumeName { [return: MarshalAs(UnmanagedType.BStr)] get; } + new string? ImportedVolumeName { [return: MarshalAs(UnmanagedType.BStr)] get; } /// Retrieves the boot image that you want to add to the file system image. /// An IBootOptions interface of the boot image to add to the disc. Is NULL if a boot image has not been specified. // https://docs.microsoft.com/en-us/windows/win32/api/imapi2fs/nf-imapi2fs-ifilesystemimage-get_bootimageoptions HRESULT // get_BootImageOptions( IBootOptions **pVal ); [DispId(6)] - new IBootOptions BootImageOptions { [return: MarshalAs(UnmanagedType.Interface)] get; set; } + new IBootOptions? BootImageOptions { [return: MarshalAs(UnmanagedType.Interface)] get; set; } /// Retrieves the number of files in the file system image. /// Number of files in the file system image. @@ -1425,7 +1426,7 @@ public static partial class IMAPI // https://docs.microsoft.com/en-us/windows/win32/api/imapi2fs/nf-imapi2fs-ifilesystemimage-identifyfilesystemsondisc HRESULT // IdentifyFileSystemsOnDisc( IDiscRecorder2 *discRecorder, FsiFileSystems *fileSystems ); [DispId(19)] - new FsiFileSystems IdentifyFileSystemsOnDisc(IDiscRecorder2 discRecorder); + new FsiFileSystems IdentifyFileSystemsOnDisc(IDiscRecorder2? discRecorder); /// Retrieves the file system to import by default. /// One or more file system values. For possible values, see the FsiFileSystems enumeration type. @@ -1742,14 +1743,14 @@ public static partial class IMAPI // https://docs.microsoft.com/en-us/windows/win32/api/imapi2fs/nf-imapi2fs-ifilesystemimage-get_importedvolumename HRESULT // get_ImportedVolumeName( BSTR *pVal ); [DispId(5)] - new string ImportedVolumeName { [return: MarshalAs(UnmanagedType.BStr)] get; } + new string? ImportedVolumeName { [return: MarshalAs(UnmanagedType.BStr)] get; } /// Retrieves the boot image that you want to add to the file system image. /// An IBootOptions interface of the boot image to add to the disc. Is NULL if a boot image has not been specified. // https://docs.microsoft.com/en-us/windows/win32/api/imapi2fs/nf-imapi2fs-ifilesystemimage-get_bootimageoptions HRESULT // get_BootImageOptions( IBootOptions **pVal ); [DispId(6)] - new IBootOptions BootImageOptions { [return: MarshalAs(UnmanagedType.Interface)] get; set; } + new IBootOptions? BootImageOptions { [return: MarshalAs(UnmanagedType.Interface)] get; set; } /// Retrieves the number of files in the file system image. /// Number of files in the file system image. @@ -1961,7 +1962,7 @@ public static partial class IMAPI // https://docs.microsoft.com/en-us/windows/win32/api/imapi2fs/nf-imapi2fs-ifilesystemimage-identifyfilesystemsondisc HRESULT // IdentifyFileSystemsOnDisc( IDiscRecorder2 *discRecorder, FsiFileSystems *fileSystems ); [DispId(19)] - new FsiFileSystems IdentifyFileSystemsOnDisc(IDiscRecorder2 discRecorder); + new FsiFileSystems IdentifyFileSystemsOnDisc(IDiscRecorder2? discRecorder); /// Retrieves the file system to import by default. /// One or more file system values. For possible values, see the FsiFileSystems enumeration type. @@ -3540,7 +3541,7 @@ public static partial class IMAPI // https://docs.microsoft.com/en-us/windows/win32/api/imapi2fs/nf-imapi2fs-ifsinamedstreams-get_item HRESULT get_Item( LONG // index, IFsiFileItem2 **item ); [DispId(0)] - IFsiFileItem2 this[int index] { [return: MarshalAs(UnmanagedType.Interface)] get; } + IFsiFileItem2? this[int index] { [return: MarshalAs(UnmanagedType.Interface)] get; } /// Returns the number of the named streams associated with a file in the file system image. /// Pointer to a value indicating the total number of named streams in the collection.