dotnet / dotnet/extensions

AddResourceMonitoring() do no-operation if not supported OS

Open
#5,962 7 comments 3 reactions 1 assignee Claimed by @evgenyfedorov2 View on GitHub
area-resourcemonitoring
Dominant language
C#
Stars
3.2k
Forks
894
Avg merge
1d 12h
Merged PRs (30d)
23

Description

### Description

I'm currently working on MacOS and it seems like https://source.dot.net/#Microsoft.Extensions.Diagnostics.ResourceMonitoring/ResourceMonitoringServiceCollectionExtensions.cs,7ba4439b710f2460,references throws an exception if the OS is not supported.

I would prefer it did a no-op. We go through all OS' and we need to do:
```
if (!OperatingSystem.IsMacOS())
{
builder.Services.AddResourceMonitoring();
}
```
In the calling code.

### Reproduction Steps

Run `builder.Services.AddResourceMonitoring();`.

### Expected behavior

Just do no-op and return early if not supported OS.

### Actual behavior

Throws exception

### Regression?

_No response_

### Known Workarounds

Add if statement at consuming code

### Configuration

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.