-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C#12 & .NET 8 updates #81
Draft
alafleur-genetec
wants to merge
27
commits into
main
Choose a base branch
from
code-refactoring-to-c#12
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- file-scoped namespaces
Encapsulated FileCryptingManagerExtensions, StreamMediaType, and StreamUsageType classes within the new Genetec.Dap.CodeSamples namespace in their respective files.
Simplified the null check for `LastExitTime` in `GetTimeAndAttendance` method in `Program.cs` by directly assigning `null` using the ternary operator. Removed unnecessary `using Client;` and `using Genetec.Sdk.Diagnostics.Logging.Core;` directives from `SamplePlugin.cs`. Note: The `VoidResponse` class in `VoidResponse.cs` was incorrectly changed to a semicolon-ended definition, which needs correction.
Replaced the use of `new[] { ... }` with the shorthand array initialization syntax `[ ... ]` across various parts of the code. This includes changes in the initialization of `IEnumerable` collections, `Guid` arrays, and other array types. The changes improve code readability and consistency.
Changed the initialization of `List` and `ObservableCollection` properties from using the `new` keyword with constructors to using array initializer syntax `[]` across multiple classes and files. - **Program.cs**: - `AlarmInstance` class: Updated `AttachedEntities` and `DynamicUrls` properties. - `Program` class: Updated `References` property. - **BasicPluginDescriptor.cs**: - `BasicPluginDescriptor` class: Updated `ApplicationId` property. - **SampleCustomActionView.xaml.cs**: - `SampleCustomActionView` class: Updated `EncoderCommands` property. - **SamplePluginDescriptor.cs**: - `SamplePluginDescriptor` class: Updated `ApplicationId` property. - **CustomReportFilter.xaml.cs**: - `CustomReportFilter` class: Updated `CustomEvents` property. - **CustomReportPage.cs**: - `CustomReportPage` class: Updated `Fields` and `EntityTypes` properties. - **SamplePlugin.cs**: - `SamplePlugin` class: Updated `SupportedQueries` and `SupportedCustomReports` properties. - **VCard.cs**: - `VCard` class: Updated `Emails` property.
Modified the `QueryAndDisplayVideoSequence` method to use a verbatim string literal for the `TimeSpan` format string, ensuring proper escaping of backslashes. Updated the `class Program` to construct XML content using a multi-line string literal, enhancing readability and maintainability by eliminating string concatenation.
Replaced `var` with explicit type declarations in `foreach` loops and variable assignments to enhance code readability, type safety, and maintainability. Added missing `using` directives for `System.Collections.Generic` and `System.Drawing` namespaces to ensure all necessary types are available. Ensured consistent use of explicit type declarations across various methods and classes.
Simplified constructors across multiple classes by directly using parameters for initialization, removing the need for private fields. Key changes include: - `BouncingBallOverlay` and `TimecodeOverlay` now use `cameraId` directly. - `VideoExport` now uses `engine` directly. - Various report handlers now pass parameters directly to the base class constructor. - `AggregateReportExporter` initializes `m_exporters` list directly. - `CsvReportExporter`, `MarkdownReportExporter`, and `XmlReportExporter` now use `writer` directly. - `SampleTileView` initializes `m_view` inline. - `AlarmTimelineEvent` uses constructor parameters to initialize properties.
Refactored the initialization of the CustomActionTypeDescriptor object for the LaunchEncoderCommand action. Properties Description, SupportedActionUsage, and HandleByServer are now set using an object initializer, enhancing code conciseness and readability.
Changed namespaces in HtmlReportExporter.cs and JsonReportExporter.cs from Genetec.Dap.CodeSamples to Genetec.Sdk.ReportExport. Removed public access modifiers from class declarations in HtmlReportExporter.cs, JsonReportExporter.cs, MarkdownReportExporter.cs, and XmlReportExporter.cs, making them internal. Updated constructors in MarkdownReportExporter and XmlReportExporter to use class keyword without public access modifier.
Updated the LangVersion property from 10 to 12 in multiple .csproj files. This change is applied to both Debug and Release configurations. The affected project files include: - FileCryptingManagerSample.csproj - MediaFileSample.csproj - OverlaySample.csproj - PlaybackSequenceQuerierSample.csproj - PlaybackStreamReaderSample.csproj - PtzCoordinatesManagerSample.csproj - VideoExportSample.csproj - VideoSourceFilterSample.csproj - AccessControlRawEventQuerySample.csproj - AccessControlReportQuerySample.csproj - AccessControlUnitManagerSample.csproj - AccessControlUnitSample.csproj - AccessEventMonitoringSample.csproj - AccessVerifierSample.csproj - ActivityTrailsSample.csproj - AlarmActivityQuerySample.csproj - AlarmMonitoringSample.csproj - AuditTrailsSample.csproj - CameraConfigurationSample.csproj - CameraSample.csproj - CopyConfiguratonSample.csproj - CustomEntitySample.csproj - CustomEventSample.csproj - CustomFieldSample.csproj - DiagnosticServerSample.csproj - DisplayInTileSample.csproj - CustomActionSample.csproj - CustomReportSample.csproj - PluginConfigurationSample.csproj - BackgroundProcessSample.csproj - BadgePrinterSample.csproj - CardholderCredentialReaderSample.csproj - CardholderFieldsExtractorSample.csproj - CommandManagerSample.csproj - ConfigPageSample.csproj - ControlsSample.csproj - CredentialBuilderSample.csproj - CredentialReaderSample.csproj - DashboardWidgetSample.csproj - ImageExtractorSample.csproj - OptionsExtensionSample.csproj - PageTaskSample.csproj - ReportExporterSample.csproj - TaskSample.csproj - TilePropertiesSample.csproj - TileViewSample.csproj - TileWidgetSample.csproj - TimelineProviderSample.csproj
Simplified object instantiation for `Guid` and `Size` across multiple files: - Updated `Guid` instantiation in various files including `BouncingBallOverlay.cs`, `TimecodeOverlay.cs`, and others. - Updated `IncidentData` instantiation in `Program.cs`. - Updated `Size` instantiation in `ClockWidget.cs`. Also made minor formatting adjustments, such as removing unnecessary whitespace.
Converted the following classes to records for better immutability and concise syntax: - `TimeAttendance` in `Program.cs` - `VideoFileInfo` in `Program.cs` - `ArchivedVisitorData` in `ArchivedVisitorData.cs` - `AccessControlReportRecord` in `AccessControlReportRecord.cs` - `ZoneActivityRecord` in `ZoneActivityRecord.cs` - `HealthEvent` in `HealthEvent.cs` - `IntrusionDetectionRecord` in `IntrusionDetectionRecord.cs`
Encapsulated main logic within an async RunSample method. Moved connection details and Engine initialization inside RunSample. Relocated LogOnAsync call and subsequent logic to RunSample. Added connection state check and entity processing in RunSample. Called LoadAreas and LoadFiles within RunSample to cache entities. Handled retrieval and processing of Area and File entities in RunSample. Moved console output for login failure and exit prompt to RunSample. Added await RunSample() to main program flow.
Refactored several methods in `Program.cs` to include an `Engine` parameter, ensuring explicit dependency injection. Updated `RunSample` to initialize and pass the `Engine` instance to `LoadCamerasIntoCache`, `GetCameraConfigurations`, `LoadAreas`, and `LoadFiles`. Modified `DisplayToConsole` methods for `CameraConfiguration` and `Area` to use the `Engine` parameter. These changes enhance code modularity, readability, and maintainability.
Encapsulated main logic into an async RunSample method called at the start of Main. Moved connection details, Engine initialization, and LogOnAsync handling inside RunSample. Nested PTZ camera operations within RunSample, ensuring execution only on successful logon. Scoped FindPtzCamera and LoadNetworks methods within RunSample. Added checks for camera presets and appropriate messages for various failure states. Included IsPtzCamera predicate within FindPtzCamera. Final exit message moved inside RunSample.
Updated Microsoft.Windows.Compatibility package to version 8.0.8 for latest features and bug fixes. Added LoggerSample.exe.gconfig to always copy to output directory during build for runtime configuration.
Updated project references and package dependencies across multiple .csproj files to support .NET 8.0 for Windows. Key changes include: - Updated `Microsoft.Windows.Compatibility` package from `8.0.6` to `8.0.8`. - Added `FrameworkReference` to `Microsoft.WindowsDesktop.App.WPF` for WPF applications. - Added and removed references to essential .NET assemblies (`System`, `System.Core`, `PresentationCore`, `PresentationFramework`, `WindowsBase`, `System.Drawing`, `System.Data.DataSetExtensions`). - Added `Microsoft.Bcl.AsyncInterfaces` package reference to some projects. - Removed `DebugType` property for `net481` configurations in `VisitorManagerSample.csproj`. - Added a `Target` named `CopyCertificates` to copy certificates post-build. These changes ensure compatibility with .NET 8.0, streamline project files, and improve maintainability.
Introduced the `MediaPlayerApp` class in `MediaPlayerApp.cs` to encapsulate media player functionality, including initialization, event handling, and user interactions. Refactored `Program.cs` to utilize this new class, simplifying the main method and delegating media player and window management responsibilities. Retained `DisplayControls` and `ReadFilePath` methods in `Program.cs` for user input and control instructions. Improved code organization and readability with the new class structure.
- Moved namespace declaration to the top of the file. - Moved `using System;` directive below the namespace.
Updated .csproj files to add essential .NET and WPF references, and upgraded Microsoft.Windows.Compatibility package to version 8.0.8. Added FrameworkReference to Microsoft.WindowsDesktop.App.WPF for .NET 8.0 compatibility. Refactored Program.cs to encapsulate main logic in async Task RunSample() method, improving code structure and readability. Updated LangVersion in CustomIconSample.csproj from 9 to 12.
alafleur-genetec
requested review from
dcraciunas
and removed request for
dcraciunas
September 29, 2024 01:44
dcraciunas
approved these changes
Sep 30, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.