C Sharp

WolvenKit code analysis: things to know before modding Cyberpunk 2077 [https://pvs-studio.com/en/blog/posts/csharp/1165/?utm\_source=mastodon&utm\_medium=pvs&utm\_campaign=article](https://pvs-studio.com/en/blog/posts/csharp/1165/?utm_source=mastodon&utm_medium=pvs&utm_campaign=article) [@csharp](https://programming.dev/c/csharp) [@gamedev](https://lemmy.blahaj.zone/c/gamedev)

1
0

Would love a channel like Codebullet, but more focused with C# shenanigans that isn't necessarily educational All the C# channels I've seen have been mostly good or informative, but not exactly something I want to put on at night like I would a Codebullet video to have a good laugh Does anyone know of any good channels like that?

15
8

This may be common knowledge but I've never seen it online. `[MaybeNull] public Entity Entity { get; set; }` You now get a warning when accessing without a check and when setting to null. Sadly you still need to ! in quries

3
0

A collection of tools for dealing with nulls, failures and the generic type issues that arise in this domain. https://github.com/Andy3432344/SafeResults I'm the author, let me know what you think! *Edit: updated to show GitHub link, sorry!

16
13
github.com

From [the meeting minutes](https://github.com/dotnet/csharplang/blob/main/meetings/2024/LDM-2024-07-24.md): >First up today, the discriminated unions working group presented the proposal they've been working on for a while to the broader LDM. This was a broad overview session, rather than a deep dive into nitty-gritty questions; there are still plenty of little details that will need to be filled in, but we're cautiously optimistic about this proposal and moving forward with it. There was some concern about some of the ternary behavior, but we can dig more into that as we bring this proposal back for detailed follow ups in the future.

18
0

Let's say I have a method that I want to make generic, and so far it had a big switch case of types. For an simplified example, ```csharp switch (field.GetType()) { case Type.Int: Method((int)x)... case Type.NullInt: Method((int?)x)... case Type.Long: Method((long)x)... ``` I'd like to be able to just call my GenericMethod<T>(field) instead and I'm wondering if this is possible and how would I go around doing it. ```csharp GenericMethod(field) public void GenericMethod<T>(T field) ``` Can I use reflection to get a type and the pass it into the generic method somehow, is it possible to transform Type into <T>? Can I have a method on the field object that will somehow give me a <T> type for use in my generic method? Sorry for a confusing question, I'm not really sure how to phrase it correctly, but basically I want to get rid of switch cases and lots of manual coding when all I need is just the type (but that type can't be passed as generic from parent class)

5
8

Hi all. I've been wanting to get into programming for a while now, specifically C#. However, I am not good at self-study or self-guided learning. Are there any good textbooks/workbooks that you'd recommend to learners of C# as a first programming language? I have *some* experience with coding, but not much more than simple command-line calculators (due to aforementioned lack of self-teaching skills). To clarify, I'm looking for a straightforward textbook where I could read a chapter and do the associated "exercises" (for lack of a better word)

13
1

My favorite way to develop applications is microservices, or at least smaller services that can separate concerns a little bit. In our current application, there is an API we've created with an OAS document and an auto-generated .NET SDK based on the document. We then have a web console that makes calls to the backend API using the SDK and, ideally, customers would also use the SDK. So my question to everyone is: what is the best "flow" to develop a NuGet package? Currently, we have pipelines which publish the NuGet package of the SDK to our internal NuGet repository on every commit within a merge request. We have a manually incrementing semver with an additional build number tacked on (for example `1.2.3+abc123`). Now this works pretty well, but we often run into problems where a tester's NuGet doesn't pull down the latest version based on the build number if it detects it has the proper semver number. For example, if we create `1.2.3+abc456` NuGet won't pull down this version as long as it has the original `1.2.3+abc123` in its `.nuget/packages` directory. Testers and developers have to manually delete the version from the packages directory and do a fresh restore. So, is there a better way to do build numbers? Or should I be deleting the NuGet package from the private repository every time (doesn't sound ideal...)? The other part of this question is what is the best way to develop and test NuGet packages locally? My current flow is a PowerShell script which will create the new `.nupkg` file, publish it to a local/filesystem NuGet directory with some random semver number (i.e., `9.9.9`), update the `.csproj` with the version (temporarily), and then do a fresh `dotnet restore` on the target project. However, this can be cumbersome and feels like something that should be built into the `dotnet` command. Am I missing something, or is this really the best way to develop locally?

12
5