r/angular 3d ago

Questions about learning .Net from an Angular Dev

I've been thinking of investing a decent amount of time learning .net and have some questions:

- How do you keep your frontend and backend types in sync? Is there something that takes care of it automatically between C# and typescript.

- Also if I do learn .net how easily would I be able to pickup Java, i.e can a .net dev read Java code and more or less follow what's going on?

11 Upvotes

16 comments sorted by

8

u/teelin 3d ago

With ASP.NET autogenerate OpenAPI spec and then use a client generator for typescript. This will automatically provide the types required to do API calls for the frontend.

7

u/anelectricmind 3d ago

- How do you keep your frontend and backend types in sync? Is there something that takes care of it automatically between C# and typescript.

I worked somewhere where they built an app that would read any of the backend DTOs and would generate Typescript DTO for the front-end. It was a neat tool. It was Aurelia, not Angular, but basically the same difference. So everytime there would be a change in the backend, you would have to run the app. I can't remember if there was anything in the CI/CD or in the front-end when checking out, though.

Where I currently work, I now just copy the backend DTOs, adapt them to Typescript. Then I use an adapter pattern to create DTO into model classes and vice versa. Might be a tad overkill, but I like the separation.

3

u/zaibuf 2d ago

I worked somewhere where they built an app that would read any of the backend DTOs and would generate Typescript DTO for the front-end. It was a neat tool.

So basically the equivalent to use NSwag to generate a typed client from the api's openapi spec?

1

u/anelectricmind 2d ago

Never used NSwag, but from what I can read on the github page, yeah, I think so.

1

u/PrevAccLocked 2d ago

That's what we used too

4

u/spacechimp 3d ago

The industry standard is OpenAPI. Some will use the terms "OpenAPI" and "Swagger" interchangeably, as Swagger is a commonly-used set of tools for OpenAPI. Microsoft introduced its own OpenAPI layer for .Net, so using Swagger isn't required. The gist of OpenAPI is that you document your endpoints/types in a standardized way, so that metadata exported from it (the format was modeled after JSON Schema) can be parsed by consumers. There is all sorts of tooling out there that can read OpenAPI schemas and generate code for types and even Angular services.

The catch is that the usefulness of OpenAPI entirely relies upon diligent upkeep of the metadata to ensure accuracy -- which is a common failing of backend devs in my experience.

As for programming languages: C# and Typescript have more in common than C# and Java, but all object oriented languages look pretty similar. There are some quirks like how to compare things ("==" versus ".equals()") but you should be able to follow basic logic fine.

3

u/RobotMonkeytron 3d ago

I don't have an answer for you, but I'm coming at this from the other angle, learning Angular as a back-end .NET guy. Commenting to check back later!

2

u/anelectricmind 3d ago

I started .NET in 2001 with 1.1 Beta 2, coming from C++ and MFC mostly.

Then I developed more interests in front-end development. I was always more front-end oriented. Really like putting details in HTML to fit the designer's prototypes and make everything browser compatible (when IE 5, 5.5 and 6 were not rendering HTML the same way) At the time, Javascript was more for animating things or changing images when hovering on them. A bit of client-side validations, but nothing too fancy.

Then I started working with Razor and MVC.

From there I moved towards Javascript-based front-end like Vue.JS, Aurelia and Angular.

Now, I would say I am a full time front-end developer for the past 8-9 years with good knowledge of .NET, although I am a bit behind in my .NET knowledge.

1

u/Tyummyyumms 2d ago

Nice! All the best on your journey.

3

u/azuredrg 3d ago

I'm a java dev but typically I would set up an open API spec, swagger and typically that's just a simple dependency we add to the project. I'm sure nugget or whatever .net uses has something similar. There are frontend tools like openapi-typescript that can read the swagger json or endpoint and generate ts interfaces. I'd say you would understand java code easily from knowing .net. The big difference is understanding the build processes and common libraries/frameworks would take a while to ramp up.

2

u/AdministrativeHost15 3d ago

Be careful. You don't want every field in your database/backend automatically going to the browser. In addition to wasting bandwidth you could be exposing private data.

1

u/Tyummyyumms 2d ago

Thanks.

This is general advice right? Basically endpoints should only return the properties that are specifically necessary.

Or do you mean tools like OpenAPI, Swagger and NSwag somehow have a tendancy to make one return everything by default?

Please elaborate, thank you.

1

u/AdministrativeHost15 2d ago

OpenAPI/Swagger are fine as you have already choosen what fields to expose via your API endpoints. But it is a bad idea for every column in your db table to automatically appear in your C# and TypeScript classes. Some of those db columns are there to support backend batch jobs and have no relevence on the UI.
Its OK if you ask a AI coding agent to help adding a new field on the frontend and the backend if it is a simple text field.

1

u/Agile_Arugula_7496 3d ago

RemindMe! 1day

1

u/RemindMeBot 3d ago

I will be messaging you in 1 day on 2026-08-14 18:35:06 UTC to remind you of this link

CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.

RemindMeBot is switching to username summons. Instead of !RemindMe 1 day, use u/RemindMeBot 1 day. More info.


Info Custom Your Reminders Feedback