# Compiler Warning ASPIREFILESYSTEM001

<Badge
  text="Version introduced: 13.1"
  variant="note"
  size="large"
  class:list={'mb-1'}
/>

> File system service types and members are for evaluation purposes only and are subject to change or removal in future updates. Suppress this diagnostic to proceed.

This diagnostic warning is reported when using experimental file system service APIs in Aspire, including:

- `IFileSystemService` interface
- `ITempFileSystemService` interface
- `TempDirectory` class
- `TempFile` class

These APIs provide a centralized way to manage temporary directories and files used by Aspire, improving testability and consistency across the platform.

## Example

The following code generates `ASPIREFILESYSTEM001`:

```csharp title="C# — Using IFileSystemService"
var builder = DistributedApplication.CreateBuilder(args);

var fileSystemService = builder.Services
    .BuildServiceProvider()
    .GetRequiredService<IFileSystemService>();

// Create a temporary subdirectory
using var tempDir = fileSystemService.TempDirectory.CreateTempSubdirectory("aspire");
Console.WriteLine($"Temp directory: {tempDir.Path}");

// Create a temporary file
using var tempFile = fileSystemService.TempDirectory.CreateTempFile("config.json");
Console.WriteLine($"Temp file: {tempFile.Path}");
```

## Understanding the file system service

The `IFileSystemService` provides a standardized interface for managing temporary files and directories in Aspire. This abstraction enables:

- **Consistent temp file management** — Centralized handling of temporary resources
- **Automatic cleanup** — Disposable patterns ensure resources are cleaned up properly
- **Testability** — Easier to mock and test file system operations
- **Named files** — Ability to create temp files with specific names

### Key interfaces and classes

**`IFileSystemService`**

- Main service interface providing access to temporary directory operations
- Access via `TempDirectory` property

**`ITempFileSystemService`**

- Provides methods for creating temporary subdirectories and files
- `CreateTempSubdirectory(string? prefix)` — Creates a temp subdirectory
- `CreateTempFile(string? fileName)` — Creates a temp file

**`TempDirectory`**

- Represents a temporary directory that is automatically deleted when disposed
- `Path` property provides the full path to the directory

**`TempFile`**

- Represents a temporary file that is automatically deleted when disposed
- `Path` property provides the full path to the file

## To suppress this warning

Suppress the warning with either of the following methods:

- Set the severity of the rule in the _.editorconfig_ file.

  ```ini title=".editorconfig"
  [*.{cs,vb}]
  dotnet_diagnostic.ASPIREFILESYSTEM001.severity = none
  ```

  For more information about editor config files, see [Configuration files for code analysis rules](/diagnostics/overview/#suppress-in-the-editorconfig-file).

- Add the following `PropertyGroup` to your project file:

  ```xml title="C# project file"
  <PropertyGroup>
      <NoWarn>$(NoWarn);ASPIREFILESYSTEM001</NoWarn>
  </PropertyGroup>
  ```

- Suppress in code with the `#pragma warning disable ASPIREFILESYSTEM001` directive:

  ```csharp title="C# — Suppressing the warning"
  #pragma warning disable ASPIREFILESYSTEM001
  var fileSystemService = builder.Services
      .BuildServiceProvider()
      .GetRequiredService<IFileSystemService>();
  #pragma warning restore ASPIREFILESYSTEM001
  ```