Skip to content

Commit d53b3e6

Browse files
authored
Merge pull request #34 from CZEMacLeod/fix-aspire-debuggerattached
Only default to attaching debugger if aspire itself is under debug.
2 parents 1aa778e + 4c404a8 commit d53b3e6

File tree

5 files changed

+19
-14
lines changed

5 files changed

+19
-14
lines changed

samples/EF6/EF6/Extensions/WebObjectActivator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public object GetService(Type serviceType)
2222
}
2323
if (serviceType == typeof(IKeyedServiceProvider))
2424
{
25-
return serviceType as IKeyedServiceProvider ?? serviceProvider.GetService(serviceType);
25+
return serviceProvider as IKeyedServiceProvider ?? serviceProvider.GetService(serviceType);
2626
}
2727
return serviceProvider.GetService(serviceType) ??
2828
Activator.CreateInstance(serviceType, flag, null, null, null);

src/C3D/Extensions/Aspire/IISExpress/IISExpressEntensions.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,10 @@ public static IResourceBuilder<IISExpressResource> AddIISExpress(this IDistribut
385385

386386
builder.Services.AddSingleton<CommandExecutor>();
387387

388-
if (builder.Environment.IsDevelopment() && builder.ExecutionContext.IsRunMode)
389-
{
390-
builder.Services.AddAttachDebuggerHook();
391-
}
388+
//if (builder.Environment.IsDevelopment() && builder.ExecutionContext.IsRunMode)
389+
//{
390+
// builder.Services.AddAttachDebuggerHook();
391+
//}
392392

393393
builder.Eventing.Subscribe<BeforeStartEvent>((@event, token) =>
394394
{
@@ -572,10 +572,10 @@ public static IDistributedApplicationBuilder AddIISExpressConfiguration(this IDi
572572
return Task.CompletedTask;
573573
});
574574

575-
if (builder.ExecutionContext.IsRunMode && builder.Environment.IsDevelopment())
576-
{
577-
builder.Services.AddAttachDebuggerHook();
578-
}
575+
//if (builder.ExecutionContext.IsRunMode && builder.Environment.IsDevelopment())
576+
//{
577+
// builder.Services.AddAttachDebuggerHook();
578+
//}
579579

580580
return builder;
581581
}

src/C3D/Extensions/Aspire/VisualStudioDebug/Extensions/DebugResourceExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public static class DebugResourceBuilderExtensions
1212
public static bool IsDebugMode<TResource>(this IResourceBuilder<TResource> resourceBuilder, params string[]? environments)
1313
where TResource : IResource =>
1414
(resourceBuilder as IDebugBuilder<TResource>)?.IsDebugMode ?? (
15+
System.Diagnostics.Debugger.IsAttached &&
1516
resourceBuilder.ApplicationBuilder.ExecutionContext.IsRunMode &&
1617
((environments is null || environments.Length == 0) ?
1718
resourceBuilder.ApplicationBuilder.Environment.IsDevelopment() :

src/C3D/Extensions/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
33

44
<PropertyGroup>
5-
<PackageOutputPath Condition="$(PackageOutputDir) == ''">$(MSBuildThisFileDirectory)..\nuget</PackageOutputPath>
5+
<PackageOutputPath Condition="$(PackageOutputDir) == ''">$(MSBuildThisFileDirectory)..\..\..\nuget</PackageOutputPath>
66
</PropertyGroup>
77

88
<PropertyGroup>

tests/OutputWatcherTestProject/Tests/OutputWatcherIntegrationTests.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
using Microsoft.Extensions.Configuration;
12
using Microsoft.Extensions.Logging;
23
using System.Runtime.CompilerServices;
4+
using System.Threading;
35
using Xunit.Abstractions;
46

57
namespace OutputWatcherTestProject.Tests;
68

79
public class OutputWatcherIntegrationTests(ITestOutputHelper outputHelper)
810
{
911
private void WriteFunctionName([CallerMemberName] string? caller = null) => outputHelper.WriteLine(caller);
12+
private const int WaitForHealthyTimeoutSeconds = 90;
1013
private static readonly TimeSpan WaitForHealthyTimeout = TimeSpan.FromSeconds(90);
1114

1215
private async Task<IDistributedApplicationTestingBuilder> CreateAppHostAsync()
@@ -18,6 +21,7 @@ private async Task<IDistributedApplicationTestingBuilder> CreateAppHostAsync()
1821
var appHost = await DistributedApplicationTestingBuilder.CreateAsync<Projects.AspireAppHostWaitForConsole>([], (dab, host) =>
1922
{
2023
dab.EnableResourceLogging = true;
24+
host.Configuration!.AddUserSecrets<OutputWatcherIntegrationTests>();
2125
});
2226
appHost
2327
.Services
@@ -30,12 +34,12 @@ private async Task<IDistributedApplicationTestingBuilder> CreateAppHostAsync()
3034

3135
appHost.Services.ConfigureHttpClientDefaults(clientBuilder =>
3236
{
33-
37+
var timeout = TimeSpan.FromSeconds(appHost.Configuration.GetValue<double>("HttpClientTimeout", 30));
3438
clientBuilder
3539
.AddStandardResilienceHandler(res => {
36-
res.TotalRequestTimeout.Timeout = TimeSpan.FromSeconds(120);
37-
res.CircuitBreaker.SamplingDuration = TimeSpan.FromSeconds(60);
38-
res.AttemptTimeout.Timeout = TimeSpan.FromSeconds(30);
40+
res.TotalRequestTimeout.Timeout = timeout * 4;
41+
res.CircuitBreaker.SamplingDuration = timeout * 2;
42+
res.AttemptTimeout.Timeout = timeout;
3943
});
4044
clientBuilder
4145
.ConfigurePrimaryHttpMessageHandler(() =>

0 commit comments

Comments
 (0)