Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
mystes
May 31, 2006

aperfectcirclefan posted:

I had no idea there was that big of a performance hit with interpolation.
I don't think there's actually a hit with interpolation since the actual interpolation is compiled out, but I think SirViver is just saying that since if you're doing number formatting that part will compile to String.Format (and then that will be concatenated), there's overhead from the string.format call or something like that?

mystes fucked around with this message at 22:51 on Feb 27, 2022

Adbot
ADBOT LOVES YOU

mystes
May 31, 2006

If when you say Visual Studio in relation to .net on OS X you mean "Visual Studio for Mac" (i.e. Xamarin Studio) then yeah I would assume that rider will be better, and probably vs code as well.

mystes
May 31, 2006

Avalon is starting to look decent.

mystes
May 31, 2006

MightyBigMinus posted:

hello, this isn't so much a writing .net question as a working-with asp.net question

trying to automate a process of looking something up on a govt website, which is using asp.net to force you through an "accept" page and then tracking session/state somehow with a bunch of post body vars like "__EVENTVALIDATION".

this is making my attempts to just curl it go nowhere. is there an easy way to handle the session stuff if you're trying to write a little powershell script to enrich a csv with data from this site?
You either need to use a headless browser like selenium (probably overkill for this case unless you need JavaScript but a lot of people will just default to that now) or a traditional scraping framework like AngleSharp (I think; I've only used its html parsing) for .net or mechanize for python which will keep track of the state/forms.

mystes fucked around with this message at 00:59 on Jul 26, 2022

mystes
May 31, 2006

Fable should probably stick to js

For flutter I think it would be vastly more useful to take an approach like blazor server where as little as possible is actually done within dart so you don't need to transpile

That way you could probably use flutter as the gui for .net apps pretty much immediately

mystes fucked around with this message at 12:47 on Jul 27, 2022

mystes
May 31, 2006

Dr. Poz posted:

Created the basic dockerized ASPNET Core template project and figured out how to manually specify the ports I wanted the app on. Then I added Container Orchestrator Support and figured out how to manually specify the ports I wanted to use. Figuring out how to override these values via documentation wasn't difficult but I was a little surprised the initial port definition seems to be configured only via magic. I initially expected to be able to search my way to changing the value, at first by searching for the port number itself, failing that the launchSettings.json or even some value defined in the .csproj settings.

While the launchSettings.json (and later docker-compose.override.yml) were where I would eventually override the values successfully did I miss some bit of initial configuration along the way or is this just a dash of "magic" for new projects?
You can also use a commandline option or environment variable (maybe the best option if you're using docker?) by default or you can set it up in code within the app but it definitely feels a bit too magical to me

mystes fucked around with this message at 19:40 on Aug 14, 2022

mystes
May 31, 2006

For pattern matching:

In functional languages it's extremely common to define custom union types to cover different cases whenever there are multiple options for something and then use pattern matching on them.

Using them with enumerations would similarly probably be the most natural use in c#, but since I think c# enumerations are probably still a bit less ergonomic (you can't have enumerations of heterogenous types without using separately declared wrapper classes or something right?) and they tend to be used a lot more sparingly in languages like c# than union types in functional languages, that might make them less useful a lot of the time so I'm not sure I would necessarily reach for them as much as in a functional language? I'm not sure I would go out of my way to use it in c# if it doesn't seem natural.

For declaring types vs tuples:

Personally I feel like tuples can get pretty unreadable pretty quickly unless you're using them on like the next line so I'm a fan of declaring types

mystes fucked around with this message at 18:17 on Jun 13, 2023

mystes
May 31, 2006

RC Cola posted:

I have to migrate from framework 4.6.1 to netcore 6 on a pretty complex bit of software. its uh. fun?

Also its only one day a week that I work on it lol
I think regardless of the complexity of the software it entirely just depends on whether you're using specific features/dependencies that don't work in .net 6 that you have to replace; otherwise there aren't a lot of backwards incompatible changes and it should be trivial

mystes fucked around with this message at 20:58 on Jul 12, 2023

mystes
May 31, 2006

I mean to be fair if you're dealing with enterprise software that for some reason hasn't been migrated so far it's very likely to be using stuff that won't work too

mystes
May 31, 2006

TheBlackVegetable posted:

Is there maybe an open source licence that says "use this for free unless it's for development in an uber corp in which case cough the gently caress up"?
By definition no

mystes
May 31, 2006

Stallman and the FSF don't like the term "open source" so I'm not sure they have a definition for it, but you probably mean the OSI definition. If you don't care about the OSI definition then open source doesn't really mean anything and you can just call anything where the source code is available to view "open source"

mystes
May 31, 2006

epswing posted:

I am sad that the SignalR C# client library requires the Desktop Runtime and the ASP Runtime :( which requires me to bundle both with my desktop (WPF) app. I use Squirrel for deployment/installation packaging and of course it can auto-install the Desktop Runtime but not the ASP Runtime (though support to auto-install the ASP Runtime is already implemented and will be released in the next version, which might be tomorrow, or might be a year from now, who knows). And sending users to this sdk/runtime download page is a non-starter https://dotnet.microsoft.com/en-us/download/dotnet/6.0.
For distributing desktop software with .net 6+ are you even supposed to rely on the runtime being installed globally?

Aren't you supposed to use the self contained mode or something?

mystes
May 31, 2006

Just to be clear are you using a raw socket and actually trying to display tcp messages like SYN/ACK or is that unintentional?

mystes fucked around with this message at 17:29 on Oct 12, 2023

mystes
May 31, 2006

I guess it might be somewhat overkill but you could also just use a webview2 control and use html/css and replace the nonprintable characters with a number in a span element with a border... it's a LOT easier to do arbitrary formatting in html

There's probably also some way to do that in a RichTextBox if you really want to

mystes fucked around with this message at 19:47 on Oct 12, 2023

mystes
May 31, 2006

If it's utf8 you need to decode it first and not just iterate through the bytes

mystes
May 31, 2006

Surprise T Rex posted:

What's the state of the art for creating PDFs in C# code now? Ideally one I can run from a serverless Azure Function or AWS Lambda. At work we do some of this using rendering Razor templates to HTML and feeding it to Puppeteer(?) to basically fake a print-to-PDF, but that requires us to run it as a docker container so we can bundle a headless Chrome with it and that seems like more effort than is necessary.

QuestPDF seems good but new and I'm not sure if I'm just being blinded by it looking semi-modern.
Questpdf looks nice but iirc it still can't do font subsetting so it sucks unless you just need to support english (the files will be huge)

If you can run an external program written in Python I think weasyprint is pretty good as an HTML to PDF converter (as long as you're writing the HTML specifically for it). It produces very good results and doesn't use a headless browser. I'd imagine you can find some way to bundle it so you don't actually need to use containers but that's still more of a pain than an actual .net library (I'm surprised they don't provide a standalone windows .exe version)

mystes fucked around with this message at 14:40 on Jan 9, 2024

mystes
May 31, 2006

Hughmoris posted:

A novice question from a hobbyist:

Is it painful to call a F# library from Winforms or WPF? Can I:
  • write a simple parsing library in F#. Compile it.
  • Create a Winforms application in C#. Have an input field, click a button that calls the F# library to parse the input, then output the result to a new field.

At the 'Hello World' level so far, I enjoy writing in F#. But I want to create simple GUIs as well. Is combining both a bad path to take?
If you want to call f# code from c#, it needs to be a separate project, but you can just have a separate f# project and reference it in your c# project.

However, if you want to use f# I would suggest trying Avalonia.FuncUI* or making a webapp instead of using winforms/wpf from c#.

*: You can also use https://github.com/JordanMarr/ReactiveElmish.Avalonia, or if you really want to use WPF rather than avalonia you could use https://github.com/elmish/Elmish.WPF to use it from f# too, I guess

mystes fucked around with this message at 22:32 on Jan 15, 2024

mystes
May 31, 2006

Nostalgamus posted:

What's the current recommended library for reading Excel files? I'm having a hard time finding up-to-date answers to this.

I'm currently dealing with an issue where an excel import I set up a few years ago is importing incorrect numbers to the database. I'm currently using NPOI, but we've started seeing floating point errors when reading numeric value fields. I'm hoping a different library might avoid this, though we're also considering the possiblity of converting the columns to text before import.

Excel Interop is out, as I can't install Office on the machine.

Of course, there is probably grounds for asking questions about the numbers. 13-14 digits after the comma definetly implies somebody is using the wrong unit for the job. Also, the one field header I saw in the screenshots was in millimeters, which would imply a precision in a hundredth of a femtometer.
I think Closedxml is decent but I've never used npoi so I'm not sure exactly how they compare.

Also, there are a million edge cases in excel files so it may depend on your files.

mystes fucked around with this message at 16:10 on Apr 5, 2024

mystes
May 31, 2006

Supersonic posted:

So I have an idea for a side project which involves placing photos on a map and associating data with them. While logged in, users would be able to create pins (or the pin is placed automatically if GPS data is present in the image EXIF), and other users in the same account would be able to view the data, edit it, and generate reports. The photos would appear as pins like in Google maps which would then open a view to see and edit the associated data. If there's a lot of pins in one area then they would be grouped together and you can click on them to expand like this:



I'm just wondering, does anyone have any recommendations in terms of stack for this (I have C# experience and am familiar with the basics of ASP.NET and EF)? Would ASP .NET, EF Core, and Postgres work for the backend, or should I go for something more like Supabase? In addition, am I okay using something like openstreetmap or are there benefits to using the Google Maps API?

In terms of frontends, I've used Astro, plain html/css/js, and a bit of React. Would React be a good frontend choice, or does Vue or Svelte have better developer velocity assuming I'm the only one working on it? Aside from working on desktop, it would be nice if there was a phone app to take the pictures and add them to the system as well (I'm assuming I could just use the SPA for this?).
I think the pricing for google maps sucks so you probably want something else. There is mapbox or you can use a library like leaflet with either self-hosted maps (possible but still fairly complicated last time I checked) or some other tile provider using openstreetmap data (you can't just use openstreetmap directly as an api).

You might also want to consider using something like firebase rather than hosting a database yourself.

The other stuff is pretty much up to personal preference, I think.

mystes fucked around with this message at 21:10 on Apr 5, 2024

mystes
May 31, 2006

nielsm posted:

To display a map with your own overlay, you can look into OpenStreetMap.
You can't just use openstreetmap directly (you aren't allowed to use its tile servers for your own apps). You either have to do some very complicated stuff to convert the map for the whole world to tiles and host them yourself or use a third party tile provider service.

Edit: Basically unless you want to use google maps or mapbox, you should probably start by using leaflet, openlayers, or MapLibre with a tile provider (I think a bunch of them have free tiers), and then you can always switch between them or try to self host the tiles later. It's getting easier to self host the tiles so even if you don't want to that now it may be completely trivial soon and if you're using one of those map libraries it should be easy to switch whenever you want to.

mystes fucked around with this message at 21:29 on Apr 5, 2024

mystes
May 31, 2006

If you already want to render everything on the server but then do progressive enhancement primarily through dynamically loading html fragments rather than reloading the whole page, like what used to be common, htmx is a very good option in 2024 for doing that without having to manually write any javascript, but imo it's not necessarily as novel or exciting as some people are making it out to be.

I don't think it's helpful to even think of it as "vue" vs "htmx" as competing frameworks or something. The first question is whether you want to write something as an SPA / render stuff on the client (but maybe add back server rending using something like next.js for SEO or performance) or use traditional server rendering, and if you choose the latter, htmx may be useful.

I do think that some of the htmx hype is because people who don't know what the web was like 20 years ago and are only used to stuff like react or vue are looking at traditional server rendering for the first time and only seeing the ways it seems to be simpler than having a separate frontend making api calls, but maybe not seeing the other ways that approach can actually be more complicated (e.g. having to have a bunch of view state temporarily stored on the server for each session when you're doing anything remotely complicated). But that's not to say that it's a bad approach either; it worked for a really long time and it can still work perfectly fine in 2024.

mystes fucked around with this message at 19:20 on Apr 14, 2024

mystes
May 31, 2006

CapnAndy posted:

I've got a mobile app to rewrite at work and a really generous deadline, so I figured I'd take time and play with all the new toys, see what they're like. So I made a MAUI/Blazor hybrid app, and... this is a website. This is a literal, css-using, wwwroot-folder-having, website. They've somehow tricked it into running as a desktop or mobile app, but the code itself is pure website.

And I get what Microsoft is going for, right? If they can unify every design case into "just write it in this one language, we'll compile it appropriately for you", everyone's life gets appreciably easier. But it's been a loving decade since I did web development in any major capacity and it's a bit annoying that we've taken in all of web design's weaknesses too and jettisoned strengths of coding for apps, so now the codebehind just plain can't see anything you put on the razor pages, hope you didn't need sender in any of your event args.

Is it known to what degree this is gonna be the way things go in the future? Like, if Microsoft intends to continue the pressure to turn everything into a Blazor app, okay, gently caress it, I'll start learning web design. But if it's not, I... kinda don't want to.
You can also just use MAUI. Hybrid apps are specifically for when you want to use MAUI to present a webview control for your blazor app

That's not to say I think MAUI is good or anything but the whole idea of hybrid apps is to use MAUI to do something like Cordova for blazor apps but within the MAUI / .net ecosystem and within that context the idea probably more or less makes sense.

mystes fucked around with this message at 19:47 on Apr 25, 2024

mystes
May 31, 2006

CapnAndy posted:

Yeah, I know. I'm specifically wondering if I should do a hybrid app because it's likely that Microsoft will put more pressure on in the future to turn everything into Blazor -- because, like I said, I can see the benefit of literally everything being one codebase and they'll just compile it differently for us. If they're gonna, I'll go with it, but if they're not gonna, I really don't want to.
Imo, for better or worse, there's no way Microsoft is going to commit to a single approach hard enough for that to be an issue.

Adbot
ADBOT LOVES YOU

mystes
May 31, 2006

epswing posted:

Oops. Ok, so I'm playing around in LINQpad8 and it must be doing some magic, enough for me to question my entire existence as a developer for a few minutes there. Glad to hear I'm not crazy, this time.


I'm not surprised that linqpad probably pulls the value from tasks in general just because that's way more convenient when messing around with them interactively, but it's weirdly magical that it somehow does that even when it's being passed to Console.WriteLine

Edit: It seems like linqpad overrides Console.WriteLine with a more magical one that does stuff like this. I guess that's useful but also potentially confusing as in cases like this.

mystes fucked around with this message at 19:35 on Apr 26, 2024

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply