Skip to content

Commit f5efc59

Browse files
authored
Fixed the discrepancy between applicationName between normal app launch and HostFactoryResolver launch (#102152)
1 parent aa4ac3f commit f5efc59

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/libraries/Microsoft.Extensions.HostFactoryResolver/src/HostFactoryResolver.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ static bool IsApplicationNameArg(string arg)
163163
=> arg.Equals("--applicationName", StringComparison.OrdinalIgnoreCase) ||
164164
arg.Equals("/applicationName", StringComparison.OrdinalIgnoreCase);
165165

166-
args = args.Any(arg => IsApplicationNameArg(arg)) || assembly.FullName is null
166+
args = args.Any(arg => IsApplicationNameArg(arg)) || assembly?.GetName().Name is null
167167
? args
168-
: args.Concat(new[] { "--applicationName", assembly.FullName }).ToArray();
168+
: args.Concat(new[] { "--applicationName", assembly.GetName().Name }).ToArray();
169169

170170
var host = hostFactory(args);
171171
return GetServiceProvider(host);

src/libraries/Microsoft.Extensions.HostFactoryResolver/tests/HostFactoryResolverTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public void ApplicationNameSetFromArgument()
274274
IServiceProvider? serviceProvider = factory(Array.Empty<string>());
275275

276276
var configuration = (IConfiguration)serviceProvider.GetService(typeof(IConfiguration));
277-
Assert.Contains("ApplicationNameSetFromArgument", configuration["applicationName"]);
277+
Assert.Equal("ApplicationNameSetFromArgument", configuration["applicationName"]);
278278
}
279279

280280
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]

0 commit comments

Comments
 (0)