Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use GeneratedDllImport in System.Speech
  • Loading branch information
elinor-fung committed Nov 22, 2021
commit 9fbcbafacfdc05f5e5929e58f120f6f90177a306
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal static partial class WinMM
/// <param name="hwo">Handle to the waveform-audio output device. If the function
/// succeeds, the handle is no longer valid after this call.</param>
/// <returns>MMSYSERR</returns>
[DllImport(Libraries.WinMM)]
internal static extern MMSYSERR waveOutClose(IntPtr hwo);
[GeneratedDllImport(Libraries.WinMM)]
internal static partial MMSYSERR waveOutClose(IntPtr hwo);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ internal struct WAVEOUTCAPS
/// information about the capabilities of the device.</param>
/// <param name="cbwoc">Size, in bytes, of the WAVEOUTCAPS structure.</param>
/// <returns>MMSYSERR</returns>
#pragma warning disable DLLIMPORTGENANALYZER015 // Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time
// TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we support non-blittable types.
[DllImport(Libraries.WinMM)]
internal static extern MMSYSERR waveOutGetDevCaps(IntPtr uDeviceID, ref WAVEOUTCAPS caps, int cbwoc);
#pragma warning restore DLLIMPORTGENANALYZER015
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal static partial class WinMM
/// </summary>
/// <returns>The number of devices indicates success. Zero indicates that
/// no devices are present or that an error occurred.</returns>
[DllImport(Libraries.WinMM)]
internal static extern int waveOutGetNumDevs();
[GeneratedDllImport(Libraries.WinMM)]
internal static partial int waveOutGetNumDevs();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal enum MM_MSG
/// mechanism.</param>
/// <param name="fdwOpen">Flags for opening the device.</param>
/// <returns>MMSYSERR</returns>
[DllImport(Libraries.WinMM)]
internal static extern MMSYSERR waveOutOpen(ref IntPtr phwo, int uDeviceID, byte[] pwfx, WaveOutProc dwCallback, IntPtr dwInstance, uint fdwOpen);
[GeneratedDllImport(Libraries.WinMM)]
internal static partial MMSYSERR waveOutOpen(ref IntPtr phwo, int uDeviceID, byte[] pwfx, WaveOutProc dwCallback, IntPtr dwInstance, uint fdwOpen);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static partial class WinMM
/// </summary>
/// <param name="hwo">Handle to the waveform-audio output device.</param>
/// <returns>MMSYSERR</returns>
[DllImport(Libraries.WinMM)]
internal static extern MMSYSERR waveOutPause(IntPtr hwo);
[GeneratedDllImport(Libraries.WinMM)]
internal static partial MMSYSERR waveOutPause(IntPtr hwo);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ internal struct WAVEHDR
/// respect to the sample size.</param>
/// <param name="cbwh">Size, in bytes, of the WaveHeader structure.</param>
/// <returns>MMSYSERR</returns>
[DllImport(Libraries.WinMM)]
internal static extern MMSYSERR waveOutPrepareHeader(IntPtr hwo, IntPtr pwh, int cbwh);
[GeneratedDllImport(Libraries.WinMM)]
internal static partial MMSYSERR waveOutPrepareHeader(IntPtr hwo, IntPtr pwh, int cbwh);

/// <summary>
/// This function cleans up the preparation performed by waveOutPrepareHeader.
Expand All @@ -46,7 +46,7 @@ internal struct WAVEHDR
/// to be cleaned up.</param>
/// <param name="cbwh">Size, in bytes, of the WaveHeader structure.</param>
/// <returns>MMSYSERR</returns>
[DllImport(Libraries.WinMM)]
internal static extern MMSYSERR waveOutUnprepareHeader(IntPtr hwo, IntPtr pwh, int cbwh);
[GeneratedDllImport(Libraries.WinMM)]
internal static partial MMSYSERR waveOutUnprepareHeader(IntPtr hwo, IntPtr pwh, int cbwh);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static partial class WinMM
/// </summary>
/// <param name="hwo">Handle to the waveform-audio output device.</param>
/// <returns>MMSYSERR</returns>
[DllImport(Libraries.WinMM)]
internal static extern MMSYSERR waveOutReset(IntPtr hwo);
[GeneratedDllImport(Libraries.WinMM)]
internal static partial MMSYSERR waveOutReset(IntPtr hwo);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal static partial class WinMM
/// </summary>
/// <param name="hwo">Handle to the waveform-audio output device.</param>
/// <returns>MMSYSERR</returns>
[DllImport(Libraries.WinMM)]
internal static extern MMSYSERR waveOutRestart(IntPtr hwo);
[GeneratedDllImport(Libraries.WinMM)]
internal static partial MMSYSERR waveOutRestart(IntPtr hwo);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal static partial class WinMM
/// about the data block.</param>
/// <param name="cbwh">Size, in bytes, of the WaveHeader structure.</param>
/// <returns>MMSYSERR</returns>
[DllImport(Libraries.WinMM)]
internal static extern MMSYSERR waveOutWrite(IntPtr hwo, IntPtr pwh, int cbwh);
[GeneratedDllImport(Libraries.WinMM)]
internal static partial MMSYSERR waveOutWrite(IntPtr hwo, IntPtr pwh, int cbwh);
}
}
6 changes: 4 additions & 2 deletions src/libraries/System.Speech/src/System.Speech.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-windows;$(NetCoreAppMinimum);netstandard2.0</TargetFrameworks>
<!-- CS0649: uninitialized interop type fields -->
<!-- SA1129: https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3277 -->
<NoWarn>$(NoWarn);CS0649;SA1129;CA1847</NoWarn>
<!-- CA1846: Prefer 'AsSpan' over 'Substring' when span-based overloads are available -->
<NoWarn>$(NoWarn);CS0649;SA1129;CA1846;CA1847</NoWarn>
<Nullable>annotations</Nullable>
<SetIsTrimmable>false</SetIsTrimmable>
<IsPackable>true</IsPackable>
Expand Down Expand Up @@ -259,14 +260,15 @@ System.Speech.Recognition.SpeechRecognizer</PackageDescription>
<Reference Include="System.Diagnostics.Debug" />
<Reference Include="System.Diagnostics.TraceSource" />
<Reference Include="System.IO.FileSystem" />
<Reference Include="System.Memory" />
<Reference Include="System.Net.Primitives" />
<Reference Include="System.Net.Requests" />
<Reference Include="System.Net.WebClient" />
<Reference Include="System.ObjectModel" />
<Reference Include="System.Resources.ResourceManager" />
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Extensions" />
<Reference Include="System.Runtime.InteropServices" />
<Reference Include="System.Runtime.CompilerServices.Unsafe" />
<Reference Include="System.Runtime.InteropServices" />
<Reference Include="System.Runtime.Serialization.Formatters" />
<Reference Include="System.Threading" />
Expand Down