简体   繁体   中英

Shared class definitions for C#, TypeScript and Python

We are developing a set of apps that share about 15 classes. The UI is Angular8, The API is C#, and we have some Azure Functions running Python. We're using Azure DevOps.

So far we've manually defined the classes in each separate project and manually checked that they are no mismatches. But as the number of apps grows, we're going to hit a wall soon.

Ideally we'd want to have the following scenario:

  • define these classes in a C# class library and then generate their equivalent in TypeScript and Python (two other libraries)
  • have these 3 class libraries available for import for the C#/TypeScript/Python apps

Is there a way to do this? Is it possible? Are there alternatives?

There are ways to create a class library and share it through NuGet. https://azuredevopslabs.com/labs/azuredevops/packagemanagement/

But we need the class definitions across TypeScript and Python too.

How are you passing these classes? Have you considered Protocol Buffers or Microsoft Bond? Could you use dynamic objects? How much of your complexity is wrapped up in ensuring static types? As suggested JSON can be used as neutral definition language and can then be translated into the programmer's secret weapon, a dictionary.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM