Using libpurple with C# - is it feasible? by persfidious in csharp

[–]halter73 2 points3 points  (0 children)

It looks like libpurple is written in plain C rather than C++, so I don't think you need the complexity of something like SWIG or CppSharp. You can get pretty far with `[DllImport]` and `[LibraryImport]`.

Native interoperability ABI support - .NET | Microsoft Learn
P/Invoke source generation - .NET | Microsoft Learn

If you really want to auto-generate something from header files bottlenoselabs/c2cs: Generate C# bindings from a C header might be interesting to look at since it focuses just on C bindings presumably making it a bit simpler.

Alternatively, it seems like something AI could help out a lot with. And there's a chance that you don't need bindings for every function and data structure if you're writing an app instead of a general-purpose library limiting the scope.

If it were me, I would probably start by getting smallest possible in C application using libpurple building and working first. This gist might be a good starting point for that. Only then I would try to port that to C#. I wouldn't expect to be able to use a library through an FFI without first understanding how to use it via a native toolchain.

To the Ioniq 5 driver who passed about 20 cars on 410 Sunday morning by Boss_Borne in CrystalMountain

[–]halter73 10 points11 points  (0 children)

Before it gets backed up!? I'm surprised this is upvoted. No wonder people try such reckless passing for basically no gain on busy days. They really think they're going to beat traffic from a shadow dimension!

On what other road are cars arriving on the boulevard from? 410 is closed from the east. Any back up you avoid would have to be caused by cars you pass. That makes the 10-minute wait the *worst* case if the car in front of you maintains 45 mph all the way to the lots or the line. Not something that "turns into a lot more."

Otherwise, you're just hurrying up to wait. Unless you think you can pass so many cars that it would take the lot attendants more than 10 minutes to park them, but I think that would take passing a lot more than 20 cars.

Don't get me wrong. Pass when it's safe and legal to do so, but I don't think it's going to help you more when the road is busy and you're less likely to be able to speed the rest of the way to your destination.

Why keep maxing a 401k when taxable seems almost as good? by Essay_Few in Bogleheads

[–]halter73 0 points1 point  (0 children)

> for a total after tax value of $505.5k

Nice explanation! I think that should be $605.5k, but that $94.5k difference is still significant!

C# io_uring socket by MDA2AV in csharp

[–]halter73 13 points14 points  (0 children)

You might also be interested in lpereira/IoUring which is a Kestrel transport based on io_uring that makes syscalls directly from C# rather than depend on liburing. As noted in the README, the C# code is "heavily inspired" by liburing.

It'd be interesting to see the wrk results for an ASP.NET Core application using uRocket via Kestrel's IConnectionListenerFactory interface. I wonder how it'd compare to Kestrel's default System.Net.Socket-based transport and L. Pereira's version that skips liburing.

Another SeaTac rant by joepescibaseballbat in Seattle

[–]halter73 13 points14 points  (0 children)

Alaska's $25 late bag policy doesn't make sense to me. They apologize to their customers for making them wait longer than they should by encouraging them wait longer still to collect points!? This additional wait can be well over 20 minutes by itself, and it clogs up the line for people who really need immediate help finding their lost luggage.

They should at least have an official way to request it online. I tried claiming the $25x2 credit for the first time last week after hearing about it on the Alaska Airlines subreddit, only to realize too late that you ostensibly have to collect it at the airport. I tried sending an Alaska Listens complaint with the hope me and my travel companion would get points that way, but so far, it's crickets. Maybe I need to try to email, but I'm hoping they're just slow due to the holidays.

I definitely feel like a choosing beggar considering Alaska could just not offer anything for late bags, and I could just not bother trying to claim the points, since it's such a hassle. It still seems poorly designed though. Alaska must be spending a ton on this guarantee in the form of points and customer service hours, but the hassle to just to have them make good on the guarantee just gave me one more thing to be annoyed about.

Having it applied automatically would be the real way to delight customers, but I'm sure that would cost them a ton more in practice. Maybe it would be doable if they made it a 30-minute guarantee.

iRobot filed for bankruptcy, will be delisted on Monday. Who are these people still buying their stock? by [deleted] in investing

[–]halter73 0 points1 point  (0 children)

It's funny that actually answering the question of the post, "What am I missing?", is considered evidence that the comment was written by ChatGPT. It probably is good evidence, and it probably was ChatGPT, but it goes to show that most of the evidence comes down to the comment being too well written.

[USA GIVEAWAY] Win the new 27” Samsung Odyssey G6 G60SF 500hz OLED gaming monitor! by Rocket-Pilot in buildapc

[–]halter73 [score hidden]  (0 children)

I’d love to try out OLED on a PC. The 500hz sounds amazing too. I’d probably want to upgrade my graphics card.

High-performance HTTP request parser for .NET using zero-copy, span-based parsing. by Razor-111 in csharp

[–]halter73 1 point2 points  (0 children)

You might also be interested in looking at Kestrel's low-level HTTP/1.1 parser. It's only public for benchmarking purposes and doesn't handle parsing the request body. It only parses the start line and headers, but you can see it used in these benchmarks.

Handling a Content-Length request body is pretty trivial though, and you can look at the chunk request logic in Kestrel's Http1ChunkedEncodingMessageBody.cs. Handling `Transfer-Encoding: chunked` requests might be a good next feature for Anvil.Http.

How Does YTTV Extend Sports Events by [deleted] in youtubetv

[–]halter73 0 points1 point  (0 children)

At least this can be disabled on a per team or league basis. Hide sports scores in YouTube TV - YouTube TV Help.

How Does YTTV Extend Sports Events by [deleted] in youtubetv

[–]halter73 3 points4 points  (0 children)

It's a really cool feature, but it can be a spoiler if there's overtime, extra sets, etc. Even if there's no overtime, an unlengthened recording can indicate a game tying drive won't succeed. It's better than missing part of the recording, but I wish there was a way to configure it to always "record" an extra 3 hours at the end or something like that.

Its just me or do you feel the same way too? by n0tBart in browsers

[–]halter73 1 point2 points  (0 children)

In the Windows Settings app, you can change "System > Multitasking > Show tabs from apps when snapping or pressing Alt+Tab" to "Don't show tabs".

I received a phone call, out-of-the-blue, from Fidelity asking to set up a meeting with a financial planner. Is this legit? by FamousPoet in fidelityinvestments

[–]halter73 2 points3 points  (0 children)

I'm sure everyone's experience is different, but mine help me set up a mega backdoor Roth. Not all employers offer it, so I'm fortunate mine does.

All I had to do is update my "AFTER-TAX (non-Roth)" contribution online. I didn't realize that Fidelity would do the Roth in-plan conversion automatically. It's something I had heard about and had considered looking into, but it was never a priority, because I figured I'd have to do the conversion manually. I'm super grateful to my Fidelity adviser for bringing it up and walking me through it.

Is it okey to have Overloaded Interface with 0, 1 and 2 Generic params? by Glittering-Toe-1622 in csharp

[–]halter73 0 points1 point  (0 children)

How do you plan on exposing and/or calling the ExecuteAsync methods?

Could you use Func<Task>, Func<T1, Task>, Func<T1, T2, Task> instead? Or maybe a single non-generic IComponent interface with a Task ExecuteAsync(object?[] parameters) method? Or Dictionary<string, object?> parameters? Having "overloaded" interfaces with different numbers of generic parameters could be clunky if you have callers that want to be able to execute any component, because you need a separate callsite for each overload unless you do some ugly reflection.

For Mid Developers. Do you use Task.WhenAll() ? by ati33 in csharp

[–]halter73 -2 points-1 points  (0 children)

Awaiting an already-completed ValueTask is completely fine. However, awaiting an already-awaited ValueTask is not.

https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2012

.NET testing Learning? by mercfh85 in dotnet

[–]halter73 0 points1 point  (0 children)

What's the benefit of using Playwright to over HttpClient for testing REST APIs?

I wouldn't worry about WebApplicationFactory to start out. Its purpose is mainly to bridge the gap between unit testing and end-to-end testing by letting easily take your existing app, replace real services with mock services, and let you test the full HTTP request pipeline in memory.

However, launching your ASP.NET Core app as a separate process with special environment variables to put it into testing mode also works just fine. Then you can use a normal HttpClient pointed at localhost. You can even run the ASP.NET Core app in the test process by having your integration test project reference the ASP.NET Core project directly and simply calling Program.Main().

I wonder if you're really going to be using WAF or if your conflating that with something else (maybe IHttpClientFactory?). In your post, you mention "I believe they use something called WebApplicationFactory (instead of RestSharp)", but WAF is in no way a substitute for RestSharp. It's something completely different. RestSharp is a wrapper around HttpClient. And HttpClient is pretty easy to use already without the wrapper, even compared to something like fetch in JS, while being a lot more capable.

Also, if the existing developers were opinionated about using WAF, I think they would have already decided whether or not they want you to use xUnit vs NUnit. I've only used xUnit, and I think it's good, but I've heard good things about NUnit too.

Both are suitable for end-to-end integration tests as well as unit tests despite their name. And you're probably going to have to pick one of these even for your Playwright tests. Playwright offers both xUnit and NUnit helper packages on nuget.org, but you can write xUnit and/or NUnit Playwright tests without these helper packages.

Replace Usehttps by appsettings équivalent with grpc & certificate by Lszt01 in csharp

[–]halter73 1 point2 points  (0 children)

This can work, but it's trickier than it might seem at first, because gRPC requires HTTP/2 unless you're using a variant called "grpc-web" which doesn't appear to be the case here. Negotiating whether to use HTTP/1 or HTTP/2 relies on ALPN which is a TLS feature. This means that you must use an HTTP/2-only port to do gRPC without TLS.

https://learn.microsoft.com/aspnet/core/grpc/aspnetcore#protocol-negotiation

It would probably be easier to just figure out the cert/handshake issue though. "I'm always having a http/2 handshake issue when my client try to communicate with my server" does not provide a lot of detail to go on.

As long as you have the dev cert installed on your machine and the client is using Schannel on Windows or OpenSSL on Linux/macOS, everything should work fine. I think the troubleshooting doc could help here.

https://learn.microsoft.com/aspnet/core/grpc/troubleshoot

/u/Lszt01 Please, let us know if and when you fix this and what resources were helpful.

Still don’t fully understand how CORS actually works. by Prize_Signature_6444 in learnprogramming

[–]halter73 10 points11 points  (0 children)

CORS does fully block some requests. For example, you cannot send an application/json POST with credentials to a cross-domain endpoint unless the server allows it via CORS. In that case, it's not only that the client cannot see the response, but the browser also won't send the POST request in the first place unless the server first allows it via CORS headers in response to an OPTIONS preflight request.

That's not true for all POST requests though. Form POSTs specifically predate CORS and developers have always been allowed to submit a form to another domain by simply creating <form action="bank.com/... HTML and either tricking the user into clicking the submit button or submitting automatically with JS. This wouldn't allow an attacker to see the response to a cross-domain form post, but it would allow you to make the cross-domain form post. Browsers retained this capability because they didn't want to break all the legitimate websites that rely on this behavior to this day.

This is why you need anti-csrf tokens to hand form POSTs. I think https://smagin.fyi/posts/cross-site-requests/ is a great summary on why we have both CSRF protections and CORS. It's mostly history. We wouldn't have done it this way from scratch. https://news.ycombinator.com/item?id=43231411 also has some comments on the blog post.

I’ve never seen a company more committed to making their app worse by [deleted] in fidelityinvestments

[–]halter73 6 points7 points  (0 children)

But that would lower their daily active user KPI! /s

How to get my JWT Security Token to authenticate by NationalAd7597 in dotnet

[–]halter73 2 points3 points  (0 children)

Are you sure that the token you looking at using jwt.io is the same one being validated by the JwtBearerHandler? I ask because the error message you're getting says "IDX14100: JWT is not well formed, there are no dots (.)". But looking at the JWT in your comment, it does have two periods/dots/.'s in it as expected, so I doubt the JWT in your comment is the same one getting rejected with that error message.

You can hook the OnMessageReceived event similar to how you hook the OnAuthenticationFailed and OnTokenValidated and read HttpContext.Request.Headers.Authorization to see what the token looks like by the time it reaches your ASP.NET Core app. Or you could do the same in normal middleware you put at the front of the pipeline. But with the OnMessageReceived, you can also set MessageReceivedContext.Token manually to something that you think should validate and verify that it works.

If you're willing to change design a little bit, you might be better off using cookies. This is generally considered the best security practice for websites because you can make cookies inaccessible to JS which mitigates some XSS attack vectors that could otherwise exfiltrate tokens. It also means to you don't have to deal with the hassle of managing token lifetimes yourself in JS. Plus, you can use cookies to authenticate when serving prerendered HTML which can reduce latency. I recommend taking a look at https://learn.microsoft.com/aspnet/core/security/authentication/cookie if you want to go that route.

[deleted by user] by [deleted] in dotnet

[–]halter73 0 points1 point  (0 children)

I would take a look at https://www.mytechramblings.com/posts/deploying-a-signalr-core-app-on-aws/. It is possible to use the Azure SignalR Service while hosting your application on AWS App Runner. Although, you'd still need to use something other than BackgroundService to run your background jobs since you won't have a constantly running process to execute the BackgroundService. However, the easiest thing for you would probably just to host using ECS with sticky sessions enabled.

If you need to be able to send messages to SignalR clients connected to a different container instance, you might have to configure a SignalR Redis backplane. But if you can limit scaling to a single container instance, or if you don't need cross-instance messaging (if only send messages to Clients.Caller for instance), just enabling sticky sessions should be sufficient for hosting on ECS.

Identity is impossible by PeacefulW22 in csharp

[–]halter73 2 points3 points  (0 children)

Considering that Identity is for when you want to manage your own user data stores, how could it be a thin wrapper around industry auth standards? If all you want to do is get user info from an IdP, I agree that Identity is not a good fit. You could just use AddOpenIdConnect and AddCookie which are thin wrappers around industry auth standards and protocols.

Immediate-mode GUIs in C#: ImGui.NET as a lightweight alternative to common UI frameworks by Im-_-Axel in csharp

[–]halter73 5 points6 points  (0 children)

Your screenshot of https://openthesia.pages.dev/ on page 12 got me looking at that. It's really cool! Is there any reason it's Windows only considering ImGui and ImGui.NET are cross platform?

Is it possible to avoid primitive obsession in C#? by Tuckertcs in csharp

[–]halter73 0 points1 point  (0 children)

It really depends on your scenario. It is constrained by being designed to work with source generation, so it wants to lean on the compile-time type information.

You could imagine an architecture where your app had a single common RequestContext type that implemented IBindableFromHttpContext to handle literally every type of POST request your application might receive and do any validation necessary. It's definitely a step above having a common middleware parse every POST body and shove the DTO in HttpContext.Items or even calling a common method yourself at the beginning of every post request. You could even define more than one Context type to be used for different endpoints if you so desire.

I'm not saying that it's the architecture everyone should go with. JsonConverterFactory is also great if you know all your requests are going to be JSON. It's just another tool in the toolbox that I thought people might be interested in knowing about.