dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.36k stars 4.74k forks source link

Feature Request: Provide a base serializer for YAML #83313

Open MrPippin66 opened 1 year ago

MrPippin66 commented 1 year ago

This has been requested multiple times, and I see no progress.

In the end, this boils down to PowerShell not supporting YAML conversion, like XML and JSON currently is.

The response is always "We don't support YAML, becuase the .Net runtime doesn't support YAML.

YAML is a base format in Linux based systems, etc, and a common format supported in a major language, like Python.

I don't understand why YAML isn't natively supported in .Net, and thus eliminate the reason why PowerShell doesn't natively support YAML.

dotnet-issue-labeler[bot] commented 1 year ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

MrPippin66 commented 1 year ago

Should be 'area-Serialization'

teo-tsirpanis commented 1 year ago

area-Serialization refers to the older Data Contract and XML serializers; assigning to area-Meta.

ghost commented 1 year ago

Tagging subscribers to this area: @dotnet/area-meta See info in area-owners.md if you want to be subscribed.

Issue Details
This has been requested multiple times, and I see no progress. In the end, this boils down to PowerShell not supporting YAML conversion, like XML and JSON currently is. The response is always "We don't support YAML, becuase the .Net runtime doesn't support YAML. YAML is a base format in Linux based systems, etc, and a common format supported in a major language, like Python. I don't understand why YAML isn't natively supported in .Net, and thus eliminate the reason why PowerShell doesn't natively support YAML.
Author: MrPippin66
Assignees: -
Labels: `area-Meta`, `untriaged`
Milestone: -
davidfowl commented 1 year ago

YAML is a base format in Linux based systems, etc, and a common format supported in a major language, like Python.

Is YAML suppoted natively by python? What other languages come with YAML support in the standard library?

MrPippin66 commented 1 year ago

Apologies. It's not a standard part of Python.

PyYAML has become ubiquitous, but is not a part of the standard distribution.

MrPippin66 commented 1 year ago

But the desire to have this function natively within PowerShell is still desirable due the native use of YAML within container and Ansible envioronments.

stephentoub commented 1 year ago

What prevents PowerShell from using one of the myriad of yaml libraries available via nuget? eg https://www.nuget.org/packages/YamlDotNet

I see PowerShell relying on other such libraries, eg https://github.com/PowerShell/PowerShell/blob/b58db8b8f70756301d63ca9c52d0cca69756ef73/src/Microsoft.PowerShell.Commands.Utility/Microsoft.PowerShell.Commands.Utility.csproj#L11

MrPippin66 commented 1 year ago

My desire to have this supplied as a standard part of .Net (and thus resolving a reason PowerShell doesn't support it, natively) is primarily a support issue.

This isn't a niche solution, but a major infrastructure piece used by many mainstream products/solutions (beyond just Ansible and container solutions).

Y, PyYaml isn't s standard module in Python. But it is a solution Red Hat provides support for. (at least as a solution for other Red Hat products that also leverage this).

And it's not like Microsoft isn't internally using YAML for their own products (Azure Pipelines being one).

Lastly, yaml is a formal specification.

I would think all of the above would merit this being a technology provided within the core framework.

davidfowl commented 1 year ago

I don't think I've seen a YAML serializer built into any language's standard library. YAML certainly is ubiquitous in the cloud native space and https://www.nuget.org/packages/YamlDotNet is the defacto YAML implementation for .NET. I don't see a super strong argument for why it needs to go into the standard library (nothing in the standard library or anything that ships with .NET depends on it).

amis92 commented 1 year ago

Just to point out one argument that seems to be a strong one from a perspective of user/customer, is having a good, stable, performant, supported, documented and hopefully standards-compliant implementation. Especially the support and documentation are major selling points for .NET I think. So, that's why I think it'd be great to have in BCL.

But another is, similarly as ASP.NET helped BCL embrace native JSON implementation, containerization and ubiquitous-ness of YAML in CI/CD pipelines is an argument I'd use. GitHub Actions and Azure Pipelines runners are both C#-based, so that's one major player at least potentially interested in YAML support :D

Edit: I've recently found https://github.com/hadashiA/VYaml to be a good, simple and perf-optimized yaml package, if anyone else stumbles upon this thread.

StephenHodgson commented 10 months ago

I don't think I've seen a YAML serializer built into any language's standard library. YAML certainly is ubiquitous in the cloud native space and https://www.nuget.org/packages/YamlDotNet is the defacto YAML implementation for .NET. I don't see a super strong argument for why it needs to go into the standard library (nothing in the standard library or anything that ships with .NET depends on it).

David, I love the stuff you do, but I have to respectfully disagree here. Just because there is a community supported library, doesn't mean it should not be a native runtime component to dotnet. In fact, I'd argue the opposite, since the community needed to come up with an alternative solution.

I agree with @amis92, since the Azure and Github runners are both c# based, it only makes sense that they should be able to natively parse the build workflow files.

I heard over and over again the same exact arguments for JSON, yet today we have System.Text.Json it only stands to reason we also need System.Text.Yaml to complete the loop.

am11 commented 3 weeks ago

What other languages have YAML support directly in the standard library?

I only know of two: Ruby and Crystal (yep, the programming languages 😜).

When we were overhauling the YDN parser to add YAML 1.2 support back when source generators were still a new thing, we discussed potential corner cases with the YAML spec team https://github.com/yaml/yaml-spec/issues/113#issuecomment-904092900. That conversation got me thinking: instead of manually handling every parsing nuance, why not use a source generator to process the intermediate representation (IR) from the spec tool and automatically emit the YAML parser?

Of course, we ultimately ended up adding the support manually, and I got sidetracked with other projects, but building it out as a source generator could still be a pretty neat project to tackle (someday 😅)