dotnet / dotnet/runtime

[API Proposal]: Add Yaml for StringSyntaxAttribute

Open
#132,320 2 comments 0 reactions 0 assignees View on GitHub
api-suggestion area-System.Diagnostics untriaged
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

### Background and motivation

Add `Yaml` likes `Json` for `StringSyntaxAttribute`, `Yaml` is widely used for k8s/CI-CD configurations etc.
Maybe we should also support `Yaml` likes `Json`

### API Proposal

```csharp
namespace System.Diagnostics.CodeAnalysis;

public sealed class StringSyntaxAttribute
{
public const string Yaml = nameof(Yaml);
}
```

### API Usage

```csharp
var configuration = """
config:
default: true
MD013: false
""";
var yamlContent = new YamlContent(configuration);
using var response = await httpClient.PutAsync("/config", yamlContent);

class YamlContent([StringSyntax(StringSyntaxAttribute.Yaml)]string content): StringContent(content, "application/yaml");
```

### Alternative Designs

_No response_

### Risks

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by locating System.Diagnostics.CodeAnalysis.StringSyntaxAttribute and reviewing how its existing syntax constants are declared and tested. Confirm the API proposal and its YAML naming and usage, then add the Yaml constant; done means the API and relevant tests or validation for the runtime change pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.