Add EventLog Reader to the System.Diagnostics.EventLog dll/package (dotnet/corefx...
authorTomasz Heimowski <tomek.heimowski@gmail.com>
Tue, 8 Jan 2019 08:12:24 +0000 (09:12 +0100)
committerAnirudh Agnihotry <anirudhagnihotry098@gmail.com>
Tue, 8 Jan 2019 08:12:24 +0000 (00:12 -0800)
commit613355ac48c9efedf4162d0dd6975e01795b9d4d
tree79b67de205f695220ad22728365ea6067ff926b8
parent0edaaaef91485a9ef05b4097dd22e46c2852dd0d
Add EventLog Reader to the System.Diagnostics.EventLog dll/package (dotnet/corefx#33662)

* Adding EventLog Reader to the System.Diagnostics.EventLog dll/package.

This addresses issue  https://github.com/dotnet/corefx/issues/31358

The code came from https://github.com/PowerShell/PowerShell/tree/master/src/Microsoft.PowerShell.CoreCLR.Eventing, which in turn came from the .NET Desktop framework Dll System.Core.dll.   It was slightly modified to conform to codeing conventions, but there should be no semantic changes.

Note that System.Diagnostic.EventLog already exists as a Nuget package and is part of the Microsoft.Windows.Compatability Nuget package.    Previously this package/DLL only containd the 'write' APIs associated with the Windows EventLog.  This adds the EventLogReader and associated classes.

This package is mostly useful for .NET Core users who need to read the windows EventLog.

This PR is not ready to check in because there are no tests for the reader functionality.  This is where we need some community help.  Basicaly we need
some tests (fill out hte EventReaderTests.cs file).

If you are willing to help please leave a comment to that effect.  You can pull this pull request to your fork and immediately start adding tests.    We will
figure out how to get all edits pushed in when that time arrives.

* Application Event Log Record test

* Application Event Log Query Record test

* Nested Event Log tests

* Event Log Watcher tests

* Fix copyright headers

* Ran VS formatter on all files

* Combine tests using Theory in EventLogReaderTests

* Add more tests

* Reach 60% Code coverage

* - Removes SecurityCritical and SecuritySafeCritical attributes
- Removes unecessary or duplicated comments
- Removed extra blank lines
- Use nameof on ArgumentNullException calls

* Fix XML doc

* Remove dead EventPropertyContext

* Test fixes

* - Fix failing tests, moves test statements to ..Throws/..ReturnsEmpty
- Uses exact type rather than var
- lower case for variable name
- Remove [UnmanagedType.Bool] when redundant in UnsafeNativeMethods

 Conflicts:
src/System.Diagnostics.EventLog/tests/EventLogReaderTests/EventLogSessionTests.cs

* - Minor comment cleanup
- using goes outside of namespace

* - Removes SuppressUnmanagedCodeSecurityAttribute attribute
- Minor comment and spacing cleanup

* - Move tests to proper folder and add coverage

* Add more test coverage and apply some review feedbacks

* - Switch condition for two more tests to IsElevatedAndSupportsEventLogs
- Simplify ReadEventPsh using ReadEvent rather than duplicated code block
- Remove comment
- Add comment explaining why I comment out: session.ClearLog(logName: "Application")
- Remove and sort usings
- code cleanup

* Attempt to fix CI failures

* Skip test on netfx fixing FormatDescription bug

* Add test for EventLogSesstion.ClearLog(..)

* Add missing Dispose on EventRecord

Commit migrated from https://github.com/dotnet/corefx/commit/ca9550b649151c30698fbd6e0445f50d3b7385d4
46 files changed:
src/libraries/System.Diagnostics.EventLog/ref/System.Diagnostics.EventLog.cs
src/libraries/System.Diagnostics.EventLog/ref/System.Diagnostics.EventLog.csproj
src/libraries/System.Diagnostics.EventLog/src/PinvokeAnalyzerExceptionList.analyzerdata [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/Resources/Strings.resx
src/libraries/System.Diagnostics.EventLog/src/System.Diagnostics.EventLog.csproj
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/CoTaskMemSafeHandle.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/CoTaskMemUnicodeSafeHandle.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventBookmark.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventKeyword.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLevel.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogConfiguration.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogException.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogHandle.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogInformation.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogLink.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogPropertySelector.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogQuery.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogReader.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogRecord.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogSession.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogStatus.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogWatcher.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventMetadata.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventOpcode.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventProperty.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventRecord.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventRecordWrittenEventArgs.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventTask.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/NativeWrapper.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/ProviderMetadata.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/ProviderMetadataCachedInformation.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/UnsafeNativeMethods.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/Winmeta.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/tests/EventLogTests/EventLogEntryWrittenTest.cs
src/libraries/System.Diagnostics.EventLog/tests/Helpers.cs
src/libraries/System.Diagnostics.EventLog/tests/System.Diagnostics.EventLog.Tests.csproj
src/libraries/System.Diagnostics.EventLog/tests/System/Diagnostics/Reader/EventLogConfigurationTests.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/tests/System/Diagnostics/Reader/EventLogExceptionTests.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/tests/System/Diagnostics/Reader/EventLogInformationTests.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/tests/System/Diagnostics/Reader/EventLogPropertySelectorTests.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/tests/System/Diagnostics/Reader/EventLogQueryTests.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/tests/System/Diagnostics/Reader/EventLogReaderTests.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/tests/System/Diagnostics/Reader/EventLogRecordTests.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/tests/System/Diagnostics/Reader/EventLogSessionTests.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/tests/System/Diagnostics/Reader/EventLogWatcherTests.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.EventLog/tests/System/Diagnostics/Reader/ProviderMetadataTests.cs [new file with mode: 0644]