Skip to content
106 changes: 106 additions & 0 deletions docs/fundamentals/syslib-diagnostics/extobs0001.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---
title: EXTOBS0001 warning
description: Learn about the obsoletions that generate compile-time warning EXTOBS0001.
ms.date: 11/12/2025
f1_keywords:
- extobs0001
ai-usage: ai-assisted
---
# EXTOBS0001: IResourceMonitor is obsolete

The <xref:Microsoft.Extensions.Diagnostics.ResourceMonitoring.IResourceMonitor?displayProperty=fullName> interface and related APIs have been marked as obsolete starting in .NET 9. These APIs will be removed in a future version. The resource monitoring functionality has been replaced with a more efficient metrics-based approach using observable instruments.

The following APIs are marked obsolete. Use of these APIs generates warning `EXTOBS0001` at compile time.

- <xref:Microsoft.Extensions.Diagnostics.ResourceMonitoring.IResourceMonitor>
- <xref:Microsoft.Extensions.Diagnostics.ResourceMonitoring.ResourceMonitoringOptions.CollectionWindow?displayProperty=nameWithType>
- <xref:Microsoft.Extensions.Diagnostics.ResourceMonitoring.ResourceMonitoringOptions.SamplingInterval?displayProperty=nameWithType>
- <xref:Microsoft.Extensions.Diagnostics.ResourceMonitoring.ResourceMonitoringBuilderExtensions>
- <xref:Microsoft.Extensions.Diagnostics.ResourceMonitoring.ResourceUtilization>
- <xref:Microsoft.Extensions.Diagnostics.ResourceMonitoring.IResourceMonitorBuilder>
- <xref:Microsoft.Extensions.Diagnostics.ResourceMonitoring.IResourceUtilizationPublisher>
- <xref:Microsoft.Extensions.Diagnostics.ResourceMonitoring.ISnapshotProvider>
- <xref:Microsoft.Extensions.Diagnostics.ResourceMonitoring.Snapshot>
- <xref:Microsoft.Extensions.Diagnostics.ResourceMonitoring.SystemResources>
- <xref:Microsoft.Extensions.DependencyInjection.ResourceMonitoringServiceCollectionExtensions.AddResourceMonitoring(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{Microsoft.Extensions.Diagnostics.ResourceMonitoring.IResourceMonitorBuilder})?displayProperty=nameWithType>

## Workarounds

Instead of using `IResourceMonitor`, switch to using resource monitoring metrics with observable instruments. The metrics-based approach provides the same resource utilization information (CPU, memory) but integrates better with modern observability systems like OpenTelemetry.

### Migration example

Old approach using `IResourceMonitor`:

```csharp
services.AddResourceMonitoring();

// Inject and use IResourceMonitor
public class MyService
{
private readonly IResourceMonitor _resourceMonitor;

public MyService(IResourceMonitor resourceMonitor)
{
_resourceMonitor = resourceMonitor;
}

public void CheckResources()
{
var utilization = _resourceMonitor.GetUtilization(TimeSpan.FromSeconds(1));
Console.WriteLine($"CPU: {utilization.CpuUsedPercentage}%");
Console.WriteLine($"Memory: {utilization.MemoryUsedPercentage}%");
}
}
```

New approach using metrics:

```csharp
services.AddResourceMonitoring();

// Configure metrics collection.
services.AddOpenTelemetry()
.WithMetrics(builder =>
{
builder.AddMeter("Microsoft.Extensions.Diagnostics.ResourceMonitoring");
builder.AddConsoleExporter();
});
```

The resource monitoring metrics are automatically published and can be consumed by any OpenTelemetry-compatible metrics pipeline. For more information, see [`Microsoft.Extensions.Diagnostics.ResourceMonitoring` metrics](../../core/diagnostics/built-in-metrics-diagnostics.md#microsoftextensionsdiagnosticsresourcemonitoring).

## Suppress a warning

If you must use the obsolete APIs, you can suppress the warning in code or in your project file.

To suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the warning.

```csharp
// Disable the warning.
#pragma warning disable EXTOBS0001

// Code that uses obsolete API.
// ...
// Re-enable the warning.
#pragma warning restore EXTOBS0001
```

To suppress all the `EXTOBS0001` warnings in your project, add a `<NoWarn>` property to your project file.

```xml
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
...
<NoWarn>$(NoWarn);EXTOBS0001</NoWarn>
</PropertyGroup>
</Project>
```

For more information, see [Suppress warnings](obsoletions-overview.md#suppress-warnings).

## See also

- [Diagnostic resource monitoring](../../core/diagnostics/diagnostic-resource-monitoring.md)
- [`Microsoft.Extensions.Diagnostics.ResourceMonitoring` metrics](../../core/diagnostics/built-in-metrics-diagnostics.md#microsoftextensionsdiagnosticsresourcemonitoring)
31 changes: 21 additions & 10 deletions docs/fundamentals/syslib-diagnostics/obsoletions-overview.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
---
title: Obsolete features in .NET 5+
description: Learn about APIs that are marked as obsolete in .NET 5 and later versions that produce SYSLIB compiler warnings.
ms.date: 01/14/2025
ms.date: 11/12/2025
ai-usage: ai-assisted
---

# Obsolete features in .NET 5+

Starting in .NET 5, some APIs that are newly marked as obsolete make use of two new properties on <xref:System.ObsoleteAttribute>.

- The <xref:System.ObsoleteAttribute.DiagnosticId?displayProperty=nameWithType> property tells the compiler to generate build warnings using a custom diagnostic ID. The custom ID allows for obsoletion warning to be suppressed specifically and separately from one another. In the case of the .NET 5+ obsoletions, the format for the custom diagnostic ID is `SYSLIB0XXX`.

- The <xref:System.ObsoleteAttribute.DiagnosticId?displayProperty=nameWithType> property tells the compiler to generate build warnings using a custom diagnostic ID. The custom ID allows for obsoletion warning to be suppressed specifically and separately from one another. In the case of the `System*` namespace obsoletions, the format for the custom diagnostic ID is `SYSLIB0XXX`. In the case of the `Microsoft.Extensions` obsoletions, the format for the custom diagnostic ID is `EXTOBS0XXX`.
- The <xref:System.ObsoleteAttribute.UrlFormat?displayProperty=nameWithType> property tells the compiler to include a URL link to learn more about the obsoletion.

If you encounter build warnings or errors due to usage of an obsolete API, follow the specific guidance provided for the diagnostic ID listed in the [Reference](#reference) section. Warnings or errors for these obsoletions *can't* be suppressed using the [standard diagnostic ID (CS0618)](../../csharp/language-reference/compiler-messages/cs0618.md) for obsolete types or members; use the custom `SYSLIB0XXX` diagnostic ID values instead. For more information, see [Suppress warnings](#suppress-warnings).
If you encounter build warnings or errors due to usage of an obsolete API, follow the specific guidance provided for the diagnostic ID listed in the reference tables that follow. Warnings or errors for these obsoletions *can't* be suppressed using the [standard diagnostic ID (CS0618)](../../csharp/language-reference/compiler-messages/cs0618.md) for obsolete types or members; use the custom `SYSLIB0XXX` or `EXTOBS0XXX` diagnostic ID values instead. For more information, see [Suppress warnings](#suppress-warnings).

The following tables provide an index to obsolete APIs with custom diagnostic IDs in .NET 5 and later versions:

## Reference
- [SYSLIB obsoletions](#syslib-obsoletions)
- [EXTOBS obsoletions](#extobs-obsoletions)

The following table provides an index to the `SYSLIB0XXX` obsoletions in .NET 5+.
## SYSLIB obsoletions

The following table lists the `SYSLIB0XXX` obsoletions in .NET 5+.

| Diagnostic ID | Warning or error | Description |
|---------------|------------------|-------------|
Expand Down Expand Up @@ -84,9 +88,17 @@ The following table provides an index to the `SYSLIB0XXX` obsoletions in .NET 5+
| [SYSLIB0061](syslib0061.md) | Warning | The `Queryable` <xref:System.Linq.Queryable.MaxBy``2(System.Linq.IQueryable{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.Collections.Generic.IComparer{``0})?displayProperty=nameWithType> and <xref:System.Linq.Queryable.MinBy``2(System.Linq.IQueryable{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.Collections.Generic.IComparer{``0})?displayProperty=nameWithType> taking an `IComparer<TSource>` are obsolete. Use the new ones that take an `IComparer<TKey>`. |
| [SYSLIB0062](syslib0062.md) | Warning | <xref:System.Xml.Xsl.XsltSettings.EnableScript?displayProperty=nameWithType> is obsolete. |

## EXTOBS obsoletions

The following table lists the `EXTOBS0XXX` obsoletions from the `Microsoft.Extensions` libraries.

| Diagnostic ID | Warning or error | Description |
|---------------|------------------|-------------|
| [EXTOBS0001](extobs0001.md) | Warning | <xref:Microsoft.Extensions.Diagnostics.ResourceMonitoring.IResourceMonitor> is obsolete and will be removed in a future version. Consider using [Resource Monitoring observable instruments](../../core/diagnostics/built-in-metrics-diagnostics.md#microsoftextensionsdiagnosticsresourcemonitoring). |

## Suppress warnings

It's recommended that you use an available workaround whenever possible. However, if you cannot change your code, you can suppress warnings through a `#pragma` directive or a `<NoWarn>` project setting. If you must use the obsolete APIs and the `SYSLIB0XXX` diagnostic does not surface as an error, you can suppress the warning in code or in your project file.
It's recommended that you use an available workaround whenever possible. However, if you cannot change your code, you can suppress warnings through a `#pragma` directive or a `<NoWarn>` project setting. If you must use the obsolete APIs and the `SYSLIB0XXX` or `EXTOBS0XXX` diagnostic does not surface as an error, you can suppress the warning in code or in your project file.

To suppress the warnings in code:

Expand Down Expand Up @@ -123,7 +135,6 @@ To suppress the warnings in a project file:

## See also

- [API obsoletions with non-default diagnostic IDs (.NET 5)](../../core/compatibility/core-libraries/5.0/obsolete-apis-with-custom-diagnostics.md)
- [API obsoletions with non-default diagnostic IDs (.NET 6)](../../core/compatibility/core-libraries/6.0/obsolete-apis-with-custom-diagnostics.md)
- [API obsoletions with non-default diagnostic IDs (.NET 7)](../../core/compatibility/core-libraries/7.0/obsolete-apis-with-custom-diagnostics.md)
- [API obsoletions with non-default diagnostic IDs (.NET 8)](../../core/compatibility/core-libraries/8.0/obsolete-apis-with-custom-diagnostics.md)
- [API obsoletions with non-default diagnostic IDs (.NET 9)](../../core/compatibility/core-libraries/9.0/obsolete-apis-with-custom-diagnostics.md)
- [API obsoletions with non-default diagnostic IDs (.NET 10)](../../core/compatibility/core-libraries/10.0/obsolete-apis.md)
6 changes: 5 additions & 1 deletion docs/navigate/tools-diagnostics/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3936,7 +3936,7 @@ items:
- name: Obsoletions
items:
- name: Overview
displayName: syslib, obsolete, obsoletion
displayName: syslib, extobs, obsolete, obsoletion
href: ../../fundamentals/syslib-diagnostics/obsoletions-overview.md
- name: SYSLIB0001
href: ../../fundamentals/syslib-diagnostics/syslib0001.md
Expand Down Expand Up @@ -4170,6 +4170,10 @@ items:
- name: SYSLIB1230
href: ../../fundamentals/syslib-diagnostics/syslib1230.md
displayProperty: syslib1230, syslib1231, syslib1232, syslib1233, syslib1234, syslib1235, syslib1236, syslib1237, syslib1238, syslib1239
- name: EXTOBS diagnostics
items:
- name: EXTOBS0001
href: ../../fundamentals/syslib-diagnostics/extobs0001.md
- name: API compatibility
items:
- name: Overview
Expand Down