{"id":13628833,"url":"https://github.com/westermo/DotnetYang","last_synced_at":"2025-04-17T04:32:30.715Z","repository":{"id":239999118,"uuid":"791307051","full_name":"westermo/DotnetYang","owner":"westermo","description":"Source Generator for .Yang Files","archived":false,"fork":false,"pushed_at":"2024-05-28T14:10:27.000Z","size":1172,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-29T02:26:43.478Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/westermo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-24T13:33:55.000Z","updated_at":"2024-05-30T09:26:48.859Z","dependencies_parsed_at":"2024-05-16T08:25:51.620Z","dependency_job_id":"1ebfc69a-dd01-41eb-89c2-37266d78fe55","html_url":"https://github.com/westermo/DotnetYang","commit_stats":null,"previous_names":["westermo/dotnetyang"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/westermo%2FDotnetYang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/westermo%2FDotnetYang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/westermo%2FDotnetYang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/westermo%2FDotnetYang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/westermo","download_url":"https://codeload.github.com/westermo/DotnetYang/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249315996,"owners_count":21249871,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T22:00:58.156Z","updated_at":"2025-04-17T04:32:26.393Z","avatar_url":"https://github.com/westermo.png","language":"C#","readme":"[![Nuget (Generator)](https://img.shields.io/nuget/v/dotnetYang?style=flat-square)](https://www.nuget.org/packages/dotnetYang/)\n[![Build](https://img.shields.io/github/actions/workflow/status/westermo/dotnetYang/build.yml?branch=main\u0026style=flat-square)](https://github.com/westermo/dotnetYang/actions)\n[![License](https://img.shields.io/github/license/westermo/dotnetYang?style=flat-square)](https://github.com/westermo/dotnetYang/blob/develop/LICENSE)\n\ndotnetYang is a [Roslyn](https://github.com/dotnet/roslyn) source generator for using the .yang language to generate C# code, providing access to data models, ease-of-use asynchronous RPC, Action \u0026 Notification calls directly from code and generated server interfaces.\n\n## Features\n\n- **Drop-and-go:** Add your .yang files to a C# project as additional files that references this generator, that is it, your .yang defined RPC's and more are now available directly in  that C# projects code\n- **Server-interface:** Want to implement a server that responds to NETCONF calls? Look no further than the generated interface `IYangServer` and it's extension method `async Task Recieve(this IYangServer server, Stream input, Stream output);` which provides a framework for implementing your own server without having to worry about serializing and parsing NETCONF directly, but instead work with well defined C# Datatypes.\n\n## Documentation\n\n### Getting Started\n\nIn order to start using `dotnetYang` on a new .csproj project, start by adding the nuget packages by, for example, using the dotnet CLI in your project directory:\n`dotnet add package dotnetYang`\n\nAfterwards, create or add a .yang file to said project:\n`some-module.yang`\n```yang\nmodule some-module {\n    yang-version 1.1;\n    namespace \"urn:dotnet:yang:some:module\";\n    prefix sm;\n    identity someIdentity;\n    identity someOtherIdentity\n    {\n        base someIdentity;\n    }\n    rpc doSomething {\n        input {\n            leaf the-big-leaf\n            {\n                type uint32;\n                default \"4\";\n                description \"The value that is the input of the doSomething rpc\";\n            }\n        }\n        output {\n            leaf response\n            {\n                type identityref\n                {\n                    base someIdentity;\n                }\n                default \"someOtherIdentity\";\n                description \"The identity that is the output of the doSomething rpc\";\n            }\n        }\n    }\n}\n```\nAnd then add it as an additional file to your .csproj file\n```xml\n\u003cProject Sdk=\"Microsoft.NET.Sdk\"\u003e\n    \u003c!--Other parts of the .csproj file --\u003e\n    \u003cItemGroup\u003e\n        \u003cAdditionalFiles Include=\"some-module.yang\" /\u003e\n    \u003c/ItemGroup\u003e\n    \u003c!--Other parts of the .csproj file --\u003e\n\u003c/Project\u003e\n```\nNow the generated C# code from `some-module.yang` will be available, with it's naming conventions adjusted to be C# compliant\n```csharp\nnamespace MyProject;\npublic class Program\n{\n  public static async Task Main()\n  {\n      IChannel channel = //...Code for setting up whatever channel you want to send the rpc over\n      int messageID = //...Code for getting message id;\n      //Set up the rpc input, not the slight name changes\n      Some.Module.YangNode.DoSomethingInput input = new Some.Module.YangNode.DoSomethingInput\n      {\n          TheBigLeaf = 123\n      };\n      //Call the rpc function, note the slight name changes and the asynchronous nature of the call\n      Some.Module.YangNode.DoSomethingOutput output = await Some.Module.YangNode.DoSomething(channel, messageID, input);\n      //Write the \"response\" leaf of the output to console.\n      Console.WriteLine(output.Response);\n  }\n}\n```\n\n### Server creation\nSay that you want to create a server that can response to calls defined in `some-module.yang`, then you would create a class that implementes the generated `IYangServer` interface, which might look something like this:\n\n```csharp\nusing Some.Module;\nnamespace MyProject;\npublic class Server : IYangServer\n{\n    public async Task\u003cYangNode.DoSomethingOutput\u003e OnDoSomething(YangNode.DoSomethingInput input)\n    {\n        //Do whatever it is the server is expected to do when told to \"doSomething\"...\n        //Await something, do something else, the options are endless...\n        \n        //Create the output, not nessecarily like this..\n        YangNode.DoSomethingOutput output = new YangNode.DoSomethingOutput(); \n        return output;\n    }\n}\n```\n\nOf course, if there are a lot of yang modules in a project, `IYangServer` runs the risk of becoming rather big. In such a case, it is recommended to split it's implementation into several `partial` server classes in order to maintain readability.  ","funding_links":[],"categories":["Content"],"sub_categories":["145. [DotnetYang](https://ignatandrei.github.io/RSCG_Examples/v2/docs/DotnetYang) , in the [FilesToCode](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#filestocode) category"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwestermo%2FDotnetYang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwestermo%2FDotnetYang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwestermo%2FDotnetYang/lists"}