-
Notifications
You must be signed in to change notification settings - Fork 51
Version 3 #355
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
base: main
Are you sure you want to change the base?
Conversation
Significantly refactored the codebase to improve test structure and enhance functionality. Key updates include: - Updated test classes to use Xunit Fixtures, V3 and improved output management. - Implemented nullable reference types for better null handling. - Standardized async/await usage across the codebase. - Enhanced event handling for Chromecast discovery with new event args. - Improved logging with structured messages for better tracking. - Refined media and queue management functionalities. - Replaced Tmds.MDns with Zeroconf for mDNS discovery. - Added XML documentation for clarity on usage. - Cleaned up unused usings and redundant code.
- Updated channel access properties in `ChromecastClient` to use concrete types. - Simplified `DisconnectAsync` method by removing status channel clearing logic. - Completely removed interfaces: `IChromecastClient`, `IConnectionChannel`, `IHeartbeatChannel`, `IMediaChannel`, `IReceiverChannel`, `IStatusChannel`, and `IStatusMessage`. - Modified `StatusMessage` class to remove `IStatusMessage` implementation. - Moved `EditTracksInfoRequest` class to `Sharpcaster.Messages.Media` namespace for better organization.
- Updated `MdnsChromecastLocatorTester.cs` to change timeout from 1 ms to 1 µs and removed skip attribute from a test. - Added new tests in `MediaChannelTester.cs` for media commands with single media files and queues; updated using directives. - Made `Logger` property nullable in `ChromecastChannel.cs` and adjusted constructor accordingly. - Enhanced `HeartbeatChannel.cs` to implement `IDisposable` for better resource management with a timer. - Changed `_logger` field to nullable in `ChromeCastClient.cs` and refined error handling. - Improved response resolution in `ChromecastLocator.cs` for better discovery timeout handling. - Introduced `MediaCommandEnumConverter` for JSON serialization of the `MediaCommand` enum. - Updated `IChromecastChannel.cs` to make `Logger` property nullable. - Modified character casing logic in `Message.cs` to use `CultureInfo.InvariantCulture`. - Significantly redefined media commands in `MediaCommand.cs` with a new flags enum and added extension methods. - Changed `SupportedMediaCommands` type in `MediaStatus.cs` from int to the new `MediaCommand` enum for structured representation.
- Updated `Sharpcaster.Test.Aot.csproj` to remove package references and update `Microsoft.Testing.Platform.MSBuild`. - Added `ConfigureAwait(false)` to asynchronous calls in `ChromecastChannel.cs`, `ConnectionChannel.cs`, `HeartbeatChannel.cs`, `MediaChannel.cs`, `ReceiverChannel.cs`, and `SpotifyChannel.cs` for improved performance. - Refactored `ComputeMd5Hash` in `SpotifyChannel.cs` for modern syntax. - Simplified methods in `ChromeCastClient.cs` using expression-bodied members for clarity. - Changed `ChromecastApplication` and `ChromecastStatus` to use `ReadOnlyCollection` for better encapsulation. - Updated `GetCommandNames` in `MediaCommand.cs` to return `IReadOnlyCollection`. - Added `GlobalSuppressions.cs` to manage code analysis warnings. - Enhanced `Sharpcaster.csproj` with new property groups for warning suppression. - Various minor refactorings and improvements for overall code quality.
- Simplified message object creation in JsonTesting.cs. - Added AdsTester.cs for Xunit tests on media loading and ad functionalities. - Updated MediaChannel.cs to use nullable MediaStatus and added new ad management methods. - Enhanced SharpcasteSerializationContext.cs with new message types for serialization. - Created new message classes for ad and track management. - Changed collections in ChromecastApplication.cs and ChromecastStatus.cs to allow flexible manipulation.
Hi there, That said, I am keen on watching your progress here, because I do share some of your learning goals with my own ("Home Audio") usage of C# and Microsoft tooling. What's your plan and thinking around "C# analyzer rules"? (I recently did some experiments with code generators on my own here) I am somehow busy (with non software things) the next weeks but let me know (here or by mentioning) if I can help out with anything (e.g. cross reading the doku and/or testing giving feedback on the migration to 3.0 ....). to 'implement REST interface' (from discussions): As mentioned above, my main usage of the Sharpcaster code is a pure - very short living - client application (currently in a TUI using SpectreConsole - looking forward to make it available for linux and/or embedded somehow ....). So I do not see the advantages of a "REST controlled (micro)service" yet. In my case this would certainly increase complexity as this service is another point of software containing "state" which can go wrong and decrease my goal of 'always working' like using a physical CD player. |
C# Analyzer rules my plan is to enable all of them and either fix (performance optimization regarding logging) or suppress specific rules if they don't make sense (for example removing underscore from Enums). embedded/Linux/container scenarios. I will at least quickly validate all of those and see what's the current status and if it's not working document why. Code generation is interesting. Currently only using that for json parts (to get the AOT) but might make sense to switch the protobuf implementation to that direction. But not sure about that. |
This commit introduces a comprehensive AOT (Ahead-of-Time) compilation guide in `AOT-README.md`, detailing prerequisites, build scripts, and platform-specific instructions. New functionalities for casting media and managing media queues are added in `MediaController.cs` and `QueueController.cs`, utilizing the Spectre.Console library for improved UI. The application flow is managed in `ApplicationFlows.cs`, while `ApplicationState.cs` maintains the application state, including device connections and logging. Command-line argument support is enhanced in `CommandLineArgs.cs`, and JSON serialization is handled in `ConsoleJsonContext.cs`. The `Program.cs` file is updated for dependency injection and application entry management, supporting both interactive and command-line modes. Documentation in `README.md` is expanded with detailed usage instructions and troubleshooting tips. Improvements in command execution and device discovery are made in `CommandExecutor.cs` and `DeviceService.cs`, along with the introduction of `UIHelper.cs` for better console UI management. A new `build-aot.ps1` script is added for AOT builds, and the project file `SharpCaster.Console.csproj` is modified to include AOT compatibility settings. The solution file `SharpCaster.sln` is updated to reflect the new project structure and dependencies.
Updated `build-aot.yml` to define a workflow for building Ahead-of-Time (AOT) executables for the SharpCaster project. Introduced a matrix strategy to support multiple OS (Windows, Linux, macOS) and architectures (x64, arm64). The workflow includes steps for code checkout, .NET setup, dependency installation, project restoration, AOT executable building, testing, artifact preparation, and uploading. Added a release step to create GitHub releases with packaged executables in appropriate formats based on the target platform.
Modified pull request branches to only 'main'. Added a new "Verify executable" job to check for the built executable's existence and size, replacing the previous "Test executable" job. Updated artifact preparation to log executable size without calculating it for the artifact name.
@RobertK66 thanks for the mention of SpectreConsole. After looking into it and also Aspire (because they have nice UI) I got the idea to finally build AOT compiled console version of the application. Would be great if you could give it a spin. The published binaries can be found here: https://github.com/Tapanila/SharpCaster/actions/runs/16538586428 |
Changed executable names in `build-aot.yml` for Windows, Linux, and macOS from `SharpCaster.Console.exe` and `SharpCaster.Console` to `sharpcaster.exe` and `sharpcaster`. Added a new step to rename the executable after publishing, with checks for the original file's existence and feedback on the renaming process.
- Updated `build-aot.yml` to rename executables for Windows and Unix. - Added `ShowVersion` property in `CommandLineArgs.cs` for version display. - Enhanced `CommandLineParser` to handle `--version` and `-v` commands. - Updated help text to include version command information. - Implemented `ShowVersion` method to display version and build details. - Modified `Program.cs` to check for `ShowVersion` flag in arguments. - Updated `README.md` to document new features and improvements. - Adjusted `CommandExecutor` to support the new version command. - Set project version to `3.0.0` in `SharpCaster.Console.csproj`. - Updated `UIHelper` to show application version in the console interface.
- Removed permissions section from `settings.local.json`. - Updated `.gitignore` to include `settings.local.json`. - Expanded `CLAUDE.md` with details on the SharpCaster Console Application. - Added `DeviceIpAddress` property in `CommandLineArgs.cs` for direct IP connections. - Enhanced command line parser to support `--ip` and `-i` options. - Introduced `IsIPAddress` method for IP validation in `CommandLineArgs.cs`. - Updated help text in `CommandLineArgs.cs` to reflect new options. - Changed version output to refer to the application as `sharpcaster`. - Modified command handling in `CommandExecutor.cs` for direct IP connections. - Updated connection messages to indicate connection method (name or IP). - Added `CreateDeviceFromIpAddress` method in `CommandExecutor.cs`. - Improved command execution logic to handle new options and error messages.
- Introduced `CastColor` struct with methods for RGBA, RGB, hex, and HSL color creation, including implicit conversions and JSON serialization. - Added `CastColorTester.cs` for unit tests covering various `CastColor` functionalities. - Updated `TextTrackStyle` to use `CastColor` properties instead of strings for color attributes. - Enhanced `MediaChannelTester.cs` with a test for loading media with subtitles using `TextTrackStyle`. - Modified `LoadAsync` method in `MediaChannel.cs` to accept optional active track IDs.
- Introduced a new static class `CastColors` for predefined color values, replacing `CastColor.Colors` references in tests. - Simplified access to Chromecast status by replacing `GetChromecastStatus()` method with a `ChromecastStatus` property. - Changed return types of several methods from `MediaStatus` to `MediaStatus?` to support nullability. - Made the `CastColor` constructor public for flexible instantiation. - Enhanced null handling in `GetMediaStatusAsync()`. - Updated project file to suppress CA1819 warnings related to properties in collections.
Updated logging messages for consistent casing and enhanced null checks across multiple files. Modified `GetChannel` to return a nullable type. Added null checks in converter classes and improved error handling in `SslStreamExtensions` and `TaskExtensions`. Made `QueueGetItemsMessage.Ids` nullable and sealed the `ReceptionMessageAttribute` class. Enhanced `CastColor` to implement `IEquatable<CastColor>`. Introduced `MediaCommandExtensions` for better command retrieval and updated the project file to manage additional warnings.
This commit introduces structured logging using `LoggerMessage.Define` in the `HeartbeatChannel`, `MediaChannel`, `ReceiverChannel`, and `ChromeCastClient` classes. Direct logging calls have been replaced with static logging actions to enhance performance and maintainability. Key changes include: - New logging actions for events in `HeartbeatChannel.cs` such as Pong messages and heartbeat timer management. - Addition of structured logging for error handling in `MediaChannel.cs`. - Introduction of a logging action for invalid volume levels in `ReceiverChannel.cs`. - Multiple logging actions defined in `ChromeCastClient.cs` for various events, improving clarity and performance of the logging mechanism.
Updated method signatures and documentation in the `Sharpcaster.Channels` namespace and `IChromecastChannel` interface. Changed parameter names in `OnMessageReceivedAsync` from `message` to `messagePayload` and added a new `type` parameter for better context. Also, modified the `ChromecastChannel` constructor documentation to include a `logger` parameter, enhancing clarity and usability.
- Changed `GOOGLE_AD_URL` to use `skippablelinear` ads. - Marked `TestSkipAd` method as skipped due to issues. - Marked `SkipAdAsync` as obsolete, suggesting GitHub issues for needs. - Updated ad skip logic to check skippability after 5 seconds. - Added `JsonIgnore` to `ContentId` for better JSON serialization.
- Updated skip ad functionality in AdsTester.cs to send user actions. - Added new tests in MediaChannelTester.cs for media control features. - Introduced queue management tests in QueueTester.cs for various operations. - Improved user action handling in MediaChannel.cs; marked SendUserActionAsync as obsolete. - Removed EditTracksInfoRequest and StreamTransferMessage from serialization context in SharpcasteSerializationContext.cs. - Simplified EditTracksInfoMessage structure for active track IDs and text track styles. - Refactored UserActionMessage to inherit from a new base class. - Changed PlaybackRate type from int to double in MediaStatus.cs for precision. - Made several properties nullable in MusicTrackMetadata.cs for flexible metadata handling.
Updated `SetMute` and volume-setting methods to include `MediaSessionId` in `SetVolumeMessage`, improving association with specific media sessions. Modified `MediaSessionId` and `SessionId` properties to be nullable for better handling of absent identifiers. Changed `SetVolumeMessage` to inherit from `MediaSessionMessage` to reflect the new structure.
This commit updates several package references across multiple project files to newer versions. Key changes include: - Upgraded `Microsoft.Extensions.Logging.Console`, `Microsoft.Extensions.Logging.Debug`, and `Microsoft.Extensions.DependencyInjection` in `SharpCaster.Console.csproj` from `9.0.7` to `9.0.8`. - Updated `Microsoft.Testing.Extensions.TrxReport` and `Microsoft.Testing.Platform.MSBuild` in `Sharpcaster.Test.Aot.csproj` from `1.7.3` to `1.8.1`, and added `MSTest.TestFramework` version `3.10.1`. - Updated `Microsoft.Extensions.Logging.Abstractions` in `Sharpcaster.Test.csproj` from `9.0.7` to `9.0.8`, and `System.Text.Json` from `9.0.7` to `9.0.8`. - Updated `Microsoft.Extensions.DependencyInjection`, `Microsoft.Extensions.Logging.Abstractions`, and `System.Text.Json` in `Sharpcaster.csproj` from `9.0.7` to `9.0.8`, and `Roslynator.Analyzers` from `4.13.1` to `4.14.0`.
Updated documentation in `CLAUDE.md` to reflect new volume control methods (`SetVolumeAsync` and `SetMuteAsync`) and command usage. Improved application launch logic in `MediaController.cs` to prevent unnecessary relaunches and added UI prompts for new volume commands. Modified `CommandExecutor` to handle new volume commands with error handling, and updated `ApplicationState` to track current application ID. Enhanced `MediaChannel` and `ReceiverChannel` with methods for setting volume and mute state. Updated media metadata classes to support nullable properties for better flexibility. Added new tests in `MediaChannelTester.cs` and `ReceiverChannelTester.cs` to validate the functionality of the new volume control features.
- Added `TestingJoiningMultipleTimes` to verify application launch behavior and exception handling in `ComplicatedCasesTester.cs`. - Renamed constructor parameter from `log` to `logger` in `ConnectionChannel.cs` for clarity. - Enhanced `OnMessageReceivedAsync` to log debug messages before disconnecting the client. - Updated `DisconnectAsync` in `ChromeCastClient.cs` to set exceptions for waiting tasks on disconnection.
- Updated `TestQueueShuffleAsync` to use `RetryFact` for retries. - Upgraded `Microsoft.Testing.Platform.MSBuild` to version 1.8.2. - Introduced `SafeInvokeEvent` for safe asynchronous event handling. - Replaced direct event invocations with `SafeInvokeEvent` in multiple channels.
- Added `StreamType` property to `Media` for buffering. - Renamed and modified `TestingJoiningMultipleTimes` for better control. - Introduced new test for launching applications after disconnecting. - Enhanced `StopApplication` to log warnings when no app is running. - Improved logging in `DisconnectAsync` for task cancellations. - Changed return type of `LaunchApplicationAsync` to allow null status.
Updated `CastMediaAsync` to include sample media options ("Sample Video", "Sample Audio", "Custom URL") and improved media type detection. Added error handling for invalid URL choices and ensured correct media receiver launch. Removed references to `ClearApplicationState` in multiple classes to streamline application state management, enhancing overall user experience and robustness of the feature.
- Enhanced `DeviceService` to check for existing applications before accessing namespaces, launching a default media receiver if none are found. - Updated `ChromecastStatus` and made properties `Applications`, `Volume`, and `Application` nullable for better error handling.
- Changed `StatusChanged` event handler to async in `ComplicatedCasesTester.cs` and added `TestWaiting10SecondsAfterConnect` for media playback verification. - Updated NuGet package versions in `Sharpcaster.Test.csproj`, including `xunit` packages. - Renamed `OnMessageReceivedAsync` to `OnMessageReceived` in multiple channel classes, changing return type from `Task` to `void` for simpler method signatures. - Refactored message receiving logic in `ChromeCastClient.cs` to use the new synchronous method. - Updated `IChromecastChannel.cs` interface to reflect method signature changes. - Updated `Google.Protobuf` package version in `Sharpcaster.csproj`.
- Introduced `TestHeartbeatWithLongDelaysAndMediaControl` in `ChromecastConnectionTester.cs` to validate heartbeat during long media playback delays. - Added `RestartTimeoutTimer` method in `HeartbeatChannel.cs` for better control of the heartbeat timeout mechanism. - Modified `ChromeCastClient.cs` to restart the heartbeat timer instead of stopping it when processing messages from other channels. - Removed unnecessary stream flush operation in `ChromeCastClient.cs` to enhance performance.
Added a new test method `TestMediaStatusWithGermanUmlautTitle` to validate the parsing of a `MEDIA_STATUS` message containing German umlaut characters. This includes new using directives for necessary namespaces and assertions to ensure correct deserialization and property verification of the media object and its title.
This commit introduces a new progressive discovery mechanism for finding Chromecast devices, replacing the previous single timeout approach. Key changes include updated method signatures, enhanced logging for the discovery process, and modifications to test cases to support the new functionality. Timeout values have been adjusted for a more flexible and efficient scanning process, improving the overall performance and reliability of device discovery.
- Updated constructor to use TaskCreationOptions.RunContinuationsAsynchronously for better async handling. - Changed SetResult and SetException methods to TrySetResult and TrySetException to avoid exceptions when tasks are already completed. - Removed the TaskCompletionMethod enum as it is no longer needed.
- Removed unnecessary code in `DeviceService` - Increased delay in `MdnsChromecastLocatorTester` for event capture from 5100ms to 5200ms. - Updated `TestNewProgressiveDiscovery` to assert at least 3 discovered Chromecast devices. - Added application stop call in `MediaChannelTester` and reduced wait time for application pause check to 300ms. - Added `ConfigureAwait(false)` in `ChromeCastClient` for improved async performance.
added dotnet 9 to copilot
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
… support (#371) This PR implements three user-requested enhancements to the SharpCaster console application to improve the user experience and provide more complete media information. ## Changes Made ### 1. Media Volume and Mute Status in Status Commands Both the command-line `status` command and interactive mode "Get media status" now display media stream volume information alongside the existing device volume information. **Command-line example:** ```bash $ sharpcaster "Living Room TV" status Device: Living Room TV Volume: 75% (Muted: False) # Device volume Media State: Playing Title: Big Buck Bunny Current Time: 45.2s Duration: 120.0s Progress: 37.7% Media Volume: 80% (Muted: False) # NEW: Media stream volume ``` **Interactive mode enhancement:** The status table in Media Controls → "Get media status" now includes: - Media Volume: Shows the media stream volume level - Media Muted: Shows whether the media stream is muted ### 2. Custom Title Input for Custom URLs When casting custom URLs in interactive mode, users can now specify a custom title instead of being limited to the hardcoded "Custom Media" title. **User flow:** ``` ? Select media to cast: Custom URL ? Enter media URL: https://example.com/my-video.mp4 ? Enter media title (or press Enter for default): My Awesome Video ✅ Media loaded and playing successfully! ``` The title prompt allows empty input and defaults to "Custom Media" for backward compatibility. ### 3. Navigation Menu Verification Verified that all cast-related menus already have proper "Back to main menu" options: - ✅ Media Controls menu - ✅ Queue Management menu ## Technical Details - **Null-safe implementation**: Uses proper null-conditional operators (`?.`) to handle cases where media volume information might not be available - **Consistent formatting**: Media volume uses the same percentage formatting (`:P0`) as device volume for consistency - **Error handling**: Gracefully displays "Not available" when media volume information is unavailable - **UI consistency**: Interactive mode uses Spectre.Console styling patterns matching the existing codebase ## User Impact These enhancements provide users with: 1. **Complete media information**: Both device and media stream volume levels are now visible 2. **Better customization**: Custom titles for personal media improve organization and identification 3. **Improved user experience**: More informative status displays and intuitive navigation The changes maintain backward compatibility and follow existing code patterns for error handling and UI consistency. <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/Tapanila/SharpCaster/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * When casting a custom URL, you can now enter a custom media title; pressing Enter uses the default “Custom Media.” * Media status displays now include media-specific volume (as a percentage) and mute state (Yes/No). If media volume data isn’t available, a clear “Not available” message is shown. * These updates appear in both the media controls view and console status output for clearer, more informative playback feedback. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Tapanila <1529210+Tapanila@users.noreply.github.com>
Main goals:
This might be really long running task and I don't know how much I will be focusing on this.
If you have any features that you would like to have now is great time to request those