Ploxi
asp - Calling another api endpoint
Hey, i have a stream containing a raw request and would like to call the asp.net core request pipeline with it. Has anyone got an idea of archiving that without doing the obvious http request? I would like to avoid the network overhead.
6 replies
Best Practices for Instantiating Objects in C# Source Generators
I am writing a sourcegen.
We need a way of instantiating SomeArgs in SomeService.
Currently the sourcegen is just newing up SomeArgs.
Here are some ideas:
- Mark a method with an attribute that generates SomeArgs like that:
- The sourcegen simply using IServiceProvider to get the instance of SomeArgs behind the scenes. Could be hard to see through what is happening.
- Use a delegate in the generated partial class to create SomeArgs like that:
What are your thoughts on this?
7 replies
Threadsafety and Interlocked.CompareExchange
Hey, i have written a method that updates a dictionary without locks. Of course i have written a test for it and it succeeded for 15 runs. But today i executed all tests and suddendly the test failed, which i cannot reproduce a second time. Can you guys spot what i might have done wrong?
Test failure:
53 replies
❔ How to Package Multiple Versions of a Library Targeting Different Dependency Versions into a Nuget
I am working on a C# library (
mylib
) which has a dependency on another library (thatlib
).
Now, the problem is, that thatlib
has breaking changes between versions 1.0
and 2.0
, and I need to support both versions of thatlib
in my library.
I need to create two different versions of mylib
, each targeting different versions of thatlib
, and package them into a single NuGet package. Here are the version ranges I am targeting:
1. mylib_v1
targeting thatlib
versions [1.0,2.0)
2. mylib_v2
targeting thatlib
versions [2.0,5.0)
I want to achieve this ideally using a single .csproj
file without creating separate projects for each version. My goal is to ensure that consumers of my library get the correct version of mylib
based on the version of thatlib
they are using.155 replies
❔ [System.Text.Json] When to close the stream
I have a very large json file (500 mb or more), so naturally i would use
But what if the serializer needs the stream afterwards? If i leave it open, the stream would be dangling in limbo until the GC decides that it really wouldnt neeed that referencing memory anymore....
System.Text.Json
in combination with IAsyncEnumerable<FileMetaDataDto>
.
Now i want to open a stream to a file using the following:But what if the serializer needs the stream afterwards? If i leave it open, the stream would be dangling in limbo until the GC decides that it really wouldnt neeed that referencing memory anymore....
2 replies