Skip to content

Commit 97f7e68

Browse files
authored
Use GeneratedDllImport in System.Diagnostics.EventLog (#61990)
1 parent 7cfcbb0 commit 97f7e68

18 files changed

+241
-312
lines changed

src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ClearEventLog.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal static partial class Interop
88
{
99
internal static partial class Advapi32
1010
{
11-
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
12-
public static extern bool ClearEventLog(SafeEventLogReadHandle hEventLog, string lpBackupFileName);
11+
[GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
12+
public static partial bool ClearEventLog(SafeEventLogReadHandle hEventLog, string lpBackupFileName);
1313
}
1414
}

src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CloseEventLog.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal static partial class Interop
88
{
99
internal static partial class Advapi32
1010
{
11-
[DllImport(Libraries.Advapi32, SetLastError = true)]
12-
internal static extern bool CloseEventLog(IntPtr hEventLog);
11+
[GeneratedDllImport(Libraries.Advapi32, SetLastError = true)]
12+
internal static partial bool CloseEventLog(IntPtr hEventLog);
1313
}
1414
}

src/libraries/Common/src/Interop/Windows/Advapi32/Interop.DeregisterEventSource.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal static partial class Interop
88
{
99
internal static partial class Advapi32
1010
{
11-
[DllImport(Libraries.Advapi32, SetLastError = true)]
12-
internal static extern bool DeregisterEventSource(IntPtr hEventLog);
11+
[GeneratedDllImport(Libraries.Advapi32, SetLastError = true)]
12+
internal static partial bool DeregisterEventSource(IntPtr hEventLog);
1313
}
1414
}

src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetNumberOfEventLogRecords.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal static partial class Interop
88
{
99
internal static partial class Advapi32
1010
{
11-
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
12-
public static extern bool GetNumberOfEventLogRecords(SafeEventLogReadHandle hEventLog, out int NumberOfRecords);
11+
[GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
12+
public static partial bool GetNumberOfEventLogRecords(SafeEventLogReadHandle hEventLog, out int NumberOfRecords);
1313
}
1414
}

src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetOldestEventLogRecord.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ internal static partial class Interop
88
{
99
internal static partial class Advapi32
1010
{
11-
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
11+
[GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
1212
[return: MarshalAs(UnmanagedType.Bool)]
13-
public static extern bool GetOldestEventLogRecord(SafeEventLogReadHandle hEventLog, out int OldestRecord);
13+
public static partial bool GetOldestEventLogRecord(SafeEventLogReadHandle hEventLog, out int OldestRecord);
1414
}
1515
}

src/libraries/Common/src/Interop/Windows/Advapi32/Interop.NotifyChangeEventLog.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ internal static partial class Interop
88
{
99
internal static partial class Advapi32
1010
{
11-
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
11+
[GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
1212
[return: MarshalAs(UnmanagedType.Bool)]
13-
public static extern bool NotifyChangeEventLog(SafeEventLogReadHandle hEventLog, SafeWaitHandle hEvent);
13+
public static partial bool NotifyChangeEventLog(SafeEventLogReadHandle hEventLog, SafeWaitHandle hEvent);
1414
}
1515
}

src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenEventLog.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal static partial class Interop
88
{
99
internal static partial class Advapi32
1010
{
11-
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
12-
internal static extern SafeEventLogReadHandle OpenEventLog(string lpUNCServerName, string lpSourceName);
11+
[GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
12+
internal static partial SafeEventLogReadHandle OpenEventLog(string lpUNCServerName, string lpSourceName);
1313
}
1414
}

src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ReadEventLog.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ internal static partial class Advapi32
1212
internal const int FORWARDS_READ = 0x4;
1313
internal const int BACKWARDS_READ = 0x8;
1414

15-
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
15+
[GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
1616
[return: MarshalAs(UnmanagedType.Bool)]
17-
public static extern bool ReadEventLog(
17+
public static partial bool ReadEventLog(
1818
SafeEventLogReadHandle hEventLog,
1919
int dwReadFlags,
2020
int dwRecordOffset,

src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegisterEventSource.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal static partial class Interop
88
{
99
internal static partial class Advapi32
1010
{
11-
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
12-
internal static extern SafeEventLogWriteHandle RegisterEventSource(string lpUNCServerName, string lpSourceName);
11+
[GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
12+
internal static partial SafeEventLogWriteHandle RegisterEventSource(string lpUNCServerName, string lpSourceName);
1313
}
1414
}

src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ReportEvent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ internal static partial class Interop
99
{
1010
internal static partial class Advapi32
1111
{
12-
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
13-
public static extern bool ReportEvent(
12+
[GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
13+
public static partial bool ReportEvent(
1414
SafeEventLogWriteHandle hEventLog,
1515
short wType,
1616
ushort wcategory,

0 commit comments

Comments
 (0)