Skip to content

.NET 10, HostApplicationBuilder in samples, ReactiveUI -> use RxAppBuilder, ...#55

Open
gszdev wants to merge 10 commits intodapplo:masterfrom
gszdev:previews/dev_net_10
Open

.NET 10, HostApplicationBuilder in samples, ReactiveUI -> use RxAppBuilder, ...#55
gszdev wants to merge 10 commits intodapplo:masterfrom
gszdev:previews/dev_net_10

Conversation

@gszdev
Copy link
Copy Markdown
Contributor

@gszdev gszdev commented Mar 27, 2026

  • added support for .NET 10
  • added support for HostApplicationBuilder to samples
  • updated depencencies (nuget packages)
  • ReactiveUI -> use RxAppBuilder
  • added slnx files

- added support for HostApplicationBuilder to samples
- updated depencencies (nuget packages)
- added slnx files
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request upgrades the solution to .NET 10.0, updates various dependencies to their latest versions, and introduces support for HostApplicationBuilder across several sample projects. Additionally, it migrates the solution to the .slnx format and adds a shared utility for environment configuration. Review feedback highlights a potential InvalidOperationException when parsing host settings and identifies several instances of dead code, including unused constants and extension methods, that should be removed for better maintainability.

Comment thread samples/Dapplo.Hosting.Sample.Common/HostingUtility.cs
Comment thread samples/Dapplo.Hosting.Sample.CaliburnMicroDemo/Program.HostApplicationBuilder.cs Outdated
Comment thread samples/Dapplo.Hosting.Sample.ConsoleDemo/Program.HostApplicationBuilder.cs Outdated
Comment thread samples/Dapplo.Hosting.Sample.ConsoleDemo/Program.HostApplicationBuilder.cs Outdated
Comment thread samples/Dapplo.Hosting.Sample.ReactiveDemo/Program.HostApplicationBuilder.cs Outdated
Comment thread samples/Dapplo.Hosting.Sample.WinFormsDemo/Program.HostApplicationBuilder.cs Outdated
@gszdev
Copy link
Copy Markdown
Contributor Author

gszdev commented Mar 27, 2026

@gemini-code-assist
do complete code review again

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the project to support .NET 10, upgrades various dependencies, and introduces support for HostApplicationBuilder across multiple samples and library projects. The changes include conditional compilation using USE_HOST_APPLICATION_BUILDER to allow switching between the new builder and the legacy HostBuilder. A potential issue was identified regarding the removal of ConfigureLogging and ConfigureConfiguration extension methods in AppMixins, which may break the legacy HostBuilder path.

I am having trouble creating individual review comments. Click here to see my feedback.

samples/Dapplo.Hosting.Sample.DefaultWpfDemo/App.xaml.cs (21-52)

critical

The ConfigureLogging and ConfigureConfiguration extension methods were removed from AppMixins. If the App constructor for the !USE_HOST_APPLICATION_BUILDER path relies on these methods, this change will cause a compilation error. Please ensure that the HostBuilder path is still functional or update it accordingly.

@gszdev
Copy link
Copy Markdown
Contributor Author

gszdev commented Mar 27, 2026

@gemini-code-assist
do complete code review again

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the solution to .NET 10, upgrades various dependencies, and introduces HostApplicationBuilder support across sample projects. Extension methods have been refactored to support generic IHostApplicationBuilder types for better fluent API integration. The review feedback identifies critical logic errors in MSBuild conditions for Visual Studio versions, potential null reference exceptions in path handling, and opportunities to improve code quality through structured logging, proper dependency injection, and the removal of redundant commented-out code.

Comment thread samples/Dapplo.Hosting.Sample.CaliburnMicroDemo/Program.HostApplicationBuilder.cs Outdated
Comment thread samples/Dapplo.Hosting.Sample.WpfDemo/Dapplo.Hosting.Sample.WpfDemo.csproj Outdated
Comment thread samples/Dapplo.Hosting.Sample.Common/HostingUtility.cs
Comment thread samples/Dapplo.Hosting.Sample.Common/HostingUtility.cs Outdated
Comment thread samples/Dapplo.Hosting.Sample.CaliburnMicroDemo/Program.HostApplicationBuilder.cs Outdated
gszdev added 2 commits March 27, 2026 14:10
- Prepare for single file deployment
- Replace positional parameters in structured logging
@gszdev
Copy link
Copy Markdown
Contributor Author

gszdev commented Mar 27, 2026

@gemini-code-assist
do complete code review again

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the solution to .NET 10.0, including SDK and target framework updates across all projects and samples. It introduces a shared utility project and adds new samples demonstrating the HostApplicationBuilder pattern. Extension methods were refactored to use generics for improved fluent API usage, and logging was updated to a structured format. Feedback primarily focuses on code cleanup, including the removal of redundant commented-out code, empty configuration blocks, and unnecessary UTF-8 BOM characters in project files, as well as ensuring consistent error handling across the new samples.

Comment on lines +61 to +64
if (executableLocation == null)
{
return;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Silently returning when executableLocation is null is inconsistent with other samples in this pull request, which throw a NotSupportedException. For consistency and to avoid silent failures, it would be better to throw an exception here as well.

                if (executableLocation == null)
                {
                    throw new NotSupportedException("Can't start without location.");
                }

{
InitializeComponent();
ViewModel = new AppViewModel();
ViewModel = AppLocator.Current.GetService<AppViewModel>(); //new AppViewModel();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The commented-out code //new AppViewModel(); can be removed to improve clarity.

        ViewModel = AppLocator.Current.GetService<AppViewModel>();

Comment on lines +83 to +85
.WithRegistration(locator => {
// locator.InitializeSplat();
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This .WithRegistration() call has an empty body and contains commented-out code. If it's not needed, it should be removed to simplify the configuration.

{
string environmentName = null;

//var hostSettingsFilePath = System.IO.Path.Combine(Directory.GetCurrentDirectory(), hostSettingsFile);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This commented-out line should be removed to improve code clarity.

Comment thread Directory.Build.props Outdated
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IsPackable>true</IsPackable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<!--<GeneratePackageOnBuild>true</GeneratePackageOnBuild>-->
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This commented-out line is now redundant due to the conditional GeneratePackageOnBuild element on the next line. It can be removed to improve code clarity.

Comment thread samples/Dapplo.Hosting.Sample.WpfDemo/Dapplo.Hosting.Sample.WpfDemo.csproj Outdated
@@ -2,15 +2,19 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The <TargetFramework> element is redundant as <TargetFrameworks> is also specified. You can remove this line.

@gszdev
Copy link
Copy Markdown
Contributor Author

gszdev commented Mar 31, 2026

@gemini-code-assist
do complete code review again

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the entire solution to .NET 10.0, including SDK versions in global.json and CI pipelines, and target frameworks across all projects. It introduces comprehensive support for the HostApplicationBuilder API, providing generic extension methods for services like single-instance management, plugin configuration, and UI framework integration (WPF, WinForms, WinUI, Caliburn.Micro, and Metro) to support fluent chaining. Additionally, dependencies such as Caliburn.Micro, MahApps.Metro, and ReactiveUI have been updated to their latest versions. A new common utility project for samples was added, and logging throughout the samples was modernized to use structured logging. Review feedback suggests refining logging property names for clarity, removing dead code in new utility classes, and improving the robustness of JSON configuration parsing.

builder.WhenNotFirstInstance = (hostingEnvironment, logger) =>
{
// This is called when an instance was already started, this is in the second instance
logger.LogWarning("Application {applicationName} already running.", hostingEnvironment.ApplicationName);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the README and other samples in this repository, consider using the structured logging property name {@ApplicationName} (PascalCase with the destructuring operator).

                    logger.LogWarning("Application {@ApplicationName} already running.", hostingEnvironment.ApplicationName);

Comment on lines +12 to +18
//var hostSettingsFilePath = System.IO.Path.Combine(Directory.GetCurrentDirectory(), hostSettingsFile);
var hostSettingsFilePath = System.IO.Path.Combine(AppContext.BaseDirectory, hostSettingsFile);

if (System.IO.File.Exists(hostSettingsFilePath))
{
var jsonData = File.ReadAllText(hostSettingsFilePath);
var jsonHostSettingsObject = System.Text.Json.Nodes.JsonObject.Parse(jsonData);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider removing the commented-out code and making the JSON parsing more robust by ensuring the root node is an object before accessing it by key. This prevents potential InvalidOperationException if the JSON root is an array or a primitive value.

            var hostSettingsFilePath = System.IO.Path.Combine(AppContext.BaseDirectory, hostSettingsFile);

            if (System.IO.File.Exists(hostSettingsFilePath))
            {
                var jsonData = File.ReadAllText(hostSettingsFilePath);
                var jsonHostSettingsObject = System.Text.Json.Nodes.JsonNode.Parse(jsonData) as System.Text.Json.Nodes.JsonObject;

Comment on lines +26 to +31
/*
return AppContext.BaseDirectory;
return Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
*/

return AppContext.BaseDirectory;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The commented-out code and extra whitespace should be removed to keep the utility class clean and maintainable.

            return AppContext.BaseDirectory;

Comment on lines +82 to +85
.WithViewsFromAssembly(Assembly.GetExecutingAssembly())
.WithRegistration(locator => {
// locator.InitializeSplat();
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This empty registration block is unnecessary and can be removed to simplify the builder configuration.

            .WithViewsFromAssembly(Assembly.GetExecutingAssembly());

/// <param name="instance">some object to fill</param>
protected override void BuildUp(object instance) =>
this.logger.LogDebug("Should buildup {0}", instance?.GetType().Name); // TODO: don't know how to fill imports yet?//_bootstrapper.Container.InjectProperties(instance);
this.logger.LogDebug("Should buildup {MemberInfo.Name}", instance?.GetType().Name); // TODO: don't know how to fill imports yet?//_bootstrapper.Container.InjectProperties(instance);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The structured logging property name {MemberInfo.Name} is misleading as it suggests a property of a MemberInfo object. Using a more descriptive name like {InstanceType} would improve log clarity and searchability.

        this.logger.LogDebug("Should buildup {InstanceType}", instance?.GetType().Name); // TODO: don't know how to fill imports yet?//_bootstrapper.Container.InjectProperties(instance);

@gszdev
Copy link
Copy Markdown
Contributor Author

gszdev commented Apr 15, 2026

@Lakritzator
Is there a chance that this pull request can be reviewed and merged by you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant