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
ThePeavstenator
Dec 18, 2012

:burger::burger::burger::burger::burger:

Establish the Buns

:burger::burger::burger::burger::burger:
Thinking "oh I'll just use a decimal and make it work, making a Money type seems like gold plating" will lead you to the same land of pain as using the standard DateTime type and adding TimeSpan values to it because a library like Noda time for calendar/time arithmetic seems too complex for a "simple" use case.

Adbot
ADBOT LOVES YOU

Red Mike
Jul 11, 2011
I've been trying this since they first added non-Blazor WASM support, but with .NET 8 I've finally managed it: SDL running in the browser called by a C# project without needing a modified runtime or build tools.

It's only SDL, and I can't easily use the built-in SDL packaged with emscripten, but it's a major step forward because it only takes project config and the right workload installed to have it work out of the box. It doesn't even need weird C interop to set the emscripten main loop correctly! It still needs some arcane MSBuild elements that will likely change in .NET 9, but at least they're not internal/underscored ones any more!

For reference, if you have the right workload and run the project, you'd see this:



Which shows the main loop being called from either C# or JS, and the main loop itself is C# code calling SDL functions from C#.

---

I also tried MonoGame previously and got as far as running it in browser, but it needed me to modify the library to call the SDL binding directly (it internally uses dlopen/dlsym to call SDL, which doesn't work on WebAssembly normally). I'm now halfway through trying to build SDL as an emscripten side module to see if I can get dlopen/dlsym to do the right thing, in which case MonoGame's DesktopGL should work directly with no real modifications.

e: and welp hit a wall there: building SDL as a side module works fine, but if you try to mark your project as a main module, it ends up failing because of the frozen cache issue in the runtime. Basically the emscripten cache that dotnet people froze and distribute with the runtime doesn't contain the PIC versions of the libraries (i.e. libraries built with emscripten to be relocatable). I will at least see if unfreezing the cache at least lets this work, because fixing the cache issue is much simpler than rewriting chunks of MonoGame.

Red Mike fucked around with this message at 22:13 on Feb 28, 2024

biznatchio
Mar 31, 2001


Buglord
Awesome work! Could be a renaissance in browser-based games when the rough edges hopefully get sanded down a bit in .NET 9.

Is that building AOT or to the WASM Mono interpreter?

Red Mike
Jul 11, 2011

biznatchio posted:

Is that building AOT or to the WASM Mono interpreter?

Works with either, although full AOT compilation takes a while. Enabling full AOT just needs a few csproj properties, even works with trimming correctly.

The MonoGame avenue is a rabbit hole of issues: side module/main module builds don't work unless you unfreeze the emscripten cache so it can download PIC libraries, even if you build SDL as a side module you still get errors when linking to it if you build it as a static library (because it doesn't see it as relocatable), but building as a shared library isn't supported by the emscripten config for the build in the cmake config for SDL. Fundamentally this is a dead end and just needs MonoGame code changes to import SDL statically, but that change is a big mess.

Red Mike
Jul 11, 2011
Of course I wrote that but then I realised there's a simple workaround to avoid it entirely, using the C# built-in NativeLibrary.Load/GetExport to pretend to be calling dlopen/dlsym. I got a basic MonoGame sample running now, with only these changes needed in the MonoGame repo: load "libSDL" without anything else, don't set "Sdl.GL.Attribute.ContextFlags" for debug (it breaks context creation), fix MonoGame's glEnable/glDisable thinking they should return int (they're void return delegates), enable GLES define in MonoGame (and fix the couple places that don't listen to the define), don't call glPolygonMode which isn't implemented in WebGL (and I assume there's others I haven't run into). Commits with the changes here.

The OpenGL ES support is the big one that might need some weird changes to the code, but the others are all things that can live in the existing DesktopGL backend. That said, I have a feeling MonoGame maintainers will be reluctant to look at this.

MonoGame branch of the sample here.

e: Especially because the reason NativeLibrary works for this is because I'm basically hitting the SDL binding I'm including in the project, so they can't escape having to do that for WASM builds anyway.

Red Mike fucked around with this message at 18:36 on Feb 29, 2024

Red Mike
Jul 11, 2011
If anyone's interested, this thing turned into a labyrinth of rabbit holes, but I did get quite far with it.

The MonoGame support for it was quite a lot of work and needs the MonoGame developers to change framework code, so likely won't happen due to open-source woes.
But I got FNA-XNA to work on it without any changes at all, sample here. I even set up an action to publish the sample to Github Pages. It's meant to just show a cornflower blue screen at this point.

That said I've run into a few issues with WASM support in dotnet, a couple of which I've raised on the dotnet/runtime repo:

The dotnet emscripten install on the workload is locked to 3.1.34 right now, which is unable to build more recent SDL's (which FNA-XNA requires). This is because the more recent SDL marks some code as using some emscripten library functions (stringToUTF8 and UTF8ToString)...that in 3.1.34 are runtime methods, not library methods. So it's really a bug in Emscripten 3.1.35+ that it had breaking changes like this. I worked around it with a custom JS to insert a shim that turned them into library functions (I'm quite happy with this terrible terrible workaround).
I raised an issue in dotnet/runtime that we should just be able to use the Emscripten ports SDL, which should be pretty easy to solve by adding it to the pre-populated cache; except they had a NuGet package size limit so I don't know if that's feasible yet.
Then I spent a good few hours not understanding why a ton of things mentioned in the docs (like WasmFilesToIncludeInFileSystem to add things to VFS) just aren't working at all, then I realised MSBuild isn't even trying to do anything, then I realised...something is broken because there's an entire chunk of the workflow that doesn't happen, so I raised another issue about it which might be fixed in .NET 9.

Unfortunately this last thing is a blocker to getting any useful sample (not a cornflower blue screen) up because it means loading from filesystem doesn't work (so I'd have to forcibly load from HTTP, which then means changes to FNA-XNA). I'll find some workaround in the meantime though.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
At work we have been using SkiaSharp's Blazor support to draw stuff on a canvas in a Blazor WASM project, and we were feeling pretty pleased with ourselves about that, but you're doing stuff that looks way more ambitious. Pretty interesting to hear about.

Red Mike
Jul 11, 2011

Hammerite posted:

At work we have been using SkiaSharp's Blazor support to draw stuff on a canvas in a Blazor WASM project, and we were feeling pretty pleased with ourselves about that, but you're doing stuff that looks way more ambitious. Pretty interesting to hear about.

This is where I was back on .NET 6-7, because the WASM support wasn't anywhere near ready yet. I've seen projects start using the Blazor stuff to actually move forwards (like there's a MonoGame fork that uses it to do MonoGame-on-web), but I was always annoyed at how the Blazor stuff brings in so much cruft on the dev workflow-side.

That said I'm just having fun learning about all of this and hacking it together to make it work, I'm just surprised no-one else has done it yet.


Red Mike posted:

Then I spent a good few hours not understanding why a ton of things mentioned in the docs (like WasmFilesToIncludeInFileSystem to add things to VFS) just aren't working at all, then I realised MSBuild isn't even trying to do anything, then I realised...something is broken because there's an entire chunk of the workflow that doesn't happen, so I raised another issue about it which might be fixed in .NET 9.

I got an answer back on this, and the answer is basically: "all those things are out of date and only apply to the old SDK, but the template sets up the new one that just doesn't have this (yet?)", which is pretty par for the course for the WASM stuff because it's moving so quickly by dotnet standards.

In the meantime I've found a solution that does mostly work, even if it's not fully automatable:

Copy or reference your assets into the .Web project, in the established "wwwroot" folder. (I don't think there's a way for a project to include files into here from a class library it uses?)
Then edit main.js to add something like this bit of code (for example to add "wwwroot/img/test2.png"):
code:
    .withModuleConfig({
            onConfigLoaded: (config) => {
                if (!config.resources.vfs) {
                    config.resources.vfs = {}
                }
                config.resources.vfs["img/test2.png"] = {"../img/test2.png": null}
            },
        })
as part of the call to dotnet, before .create().

This then exposes that file in three ways:
1. If you call System.IO methods to access "img/test2.png", you get the file contents as if it were a local file. Although bear in mind this is a fully synchronous operation right now.
2. If you call dotnet.instance.Module.FS.whatever to access "img/test2.png" from the JS side, you get the file contents as well. This can be a stream, although it was pre-loaded at app init so it's technically sync.
3. If you access /img/test2.png in the page itself when hosted for dev (or when you copy the published folder), you expose the image directly and this can be async.

Importantly, you'll note that there's no change to the build process once you put things in "wwwroot", which means that technically it should be possible to do some magic to enumerate the list of content in wwwroot and pipe it into the right place. I'm looking to see if that exists, but I've at least confirmed that the MSBuild task that should do this currently doesn't (it only handles certain resource types) - maybe in the future though.

There is also the fact that VFS is pretty bad (it loads everything into memory, pre-load everything on app init which can take ages, etc) so it's not a great long-term solution, but I don't know that there is an alternative that would allow e.g. File.Read() to read as if they were local files.

e: What I find confusing is that clearly the dotnet JS runtime is capable of going to the web-hosted files and loading a set of them and making them available synchronously when you do File.Open()... so why can't it instead react to you doing File.Open() by going to the web-hosted files?

Red Mike fucked around with this message at 14:24 on Mar 4, 2024

JawKnee
Mar 24, 2007





You'll take the ride to leave this town along that yellow line
I have an EntityFramework question, specifically EF6. In a project with a model generated using code first, which is also using (and will continue to use) code first migrations, is there a simple way to add a entity class (and DbSet) for what is currently an existing join table in the database without having to rename/migrate/drop the existing table?

When adding the class and DbSet, EF considers this a model change and as a result requires a migration. I can add an empty migration with -IgnoreChanges, but this still results in problems with the generated model in the migration history (namely you'll end up with a renamed table there, if not in your database). Looking at the current model builder during `OnModelCreating` only shows the newly added explicit class, so if I can catch this there, I'm uncertain how.

As a more concrete example drawing from the EF documentation, let's say I start with the following entities:

code:

[Table("Tags")]
public class Tag
{
	[Key]
	public int ID { get; set; }

	[InverseProperty(nameof(Post.Tags))]
	public virtual IList<Post> Posts { get; set; } = new List<Post>();
}

[Table("Posts")]
public class Post
{
	[Key]
	public int ID { get; set; }

	[InverseProperty(nameof(Tag.Posts))]
	public virtual IList<Tag> Tags { get; set; } = new List<Tag>();
}

And I want to add the existing join table, PostTags, that was created in some long ago migration as an explicit DbSet/entity class like so:

code:

[Table("PostTags")]
public class PostTag 
{
	<pretend I put all the various bits in here, composite primary key, foreign keys, indexes and such>
}

How do I do so without ending up with a phantom PostTag1 in the model? I can create a migration that renames the existing table, adds a new one, migrates data, and drops the existing table, but I would like to avoid that if there's an easy way to do so

biznatchio
Mar 31, 2001


Buglord
If I'm understanding your problem right, all you need to do is to add to your DbContext's OnModelCreating:

code:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<PostTag>().ToTable("PostTags", t => t.ExcludeFromMigrations());
}
You may still need to create a new migration; but nothing should be done to the table in the migration. Depending on your use case though, you may want to manually add code to the migration's Up method to check to see if the table exists and create it if not -- otherwise if you ever need to recreate a database from scratch via migrations, that table will not be present.

(Also I'd have to check to be sure but I'm fairly certain that after you've captured the model in a migration with the table present and marked as excluded, you can then remove the ExcludeFromMigrations configuration and for future migrations the table will be assumed to already be present, and then you can have EFCore maintain any future changes made to it via migrations. But I'm not sure I've ever actually done that myself so you'll want to verify that behavior.)

biznatchio fucked around with this message at 20:23 on Mar 18, 2024

JawKnee
Mar 24, 2007





You'll take the ride to leave this town along that yellow line

biznatchio posted:

If I'm understanding your problem right, all you need to do is to add to your DbContext's OnModelCreating:

code:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<PostTag>().ToTable("PostTags", t => t.ExcludeFromMigrations());
}
You may still need to create a new migration; but nothing should be done to the table in the migration. Depending on your use case though, you may want to manually add code to the migration's Up method to check to see if the table exists and create it if not -- otherwise if you ever need to recreate a database from scratch via migrations, that table will not be present.

(Also I'd have to check to be sure but I'm fairly certain that after you've captured the model in a migration with the table present and marked as excluded, you can then remove the ExcludeFromMigrations configuration and for future migrations the table will be assumed to already be present, and then you can have EFCore maintain any future changes made to it via migrations. But I'm not sure I've ever actually done that myself so you'll want to verify that behavior.)

Appreciate the response - just haven't had the chance to try out the above - will update when I have. I also think there might be a few issues with the particular situation I find myself in here that might make it a bit more complicated (regularly creating new databases with the same set of migrations applied). We're also not using EFCore, but that's a problem for another day.

biznatchio
Mar 31, 2001


Buglord
Oh my bad I totally missed that you said EF6. That approach won't work in EF6.

For EF6, I believe you can just generate the migration class; then go in and manually edit the generated code's Up method to add an appropriate check query to replace the generated CreateTable method (using the Sql method to query the database's schema tables) to see if the table actually needs to be created. Then once that migration exists, later generated migrations should presume the table already exists.

Something like this:

code:
public partial class MaybeCreatePostTags : DbMigration
{
    public override void Up()
    {
        Sql("if not exists (select 1 from information_schema.tables " +
            "where table_name = 'PostTags') create table posttags (....)");
        // removed generated code:
        // CreateTable("PostTags", ...);
    }

    public override void Down()
    {
        // probably don't want to remove the table on down, so comment out the
        // generated drop table call
        // DropTable("PostTags");
    }
}

biznatchio fucked around with this message at 02:43 on Mar 21, 2024

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



I'm trying to hook up Azure App Services running a Framework ASP monolith up to an App Configuration service and I've almost got it working with just web.config changes, but I can't figure out how to load the connectionString (or endpoint for that matter) from the environment/App Service's Configuration. Is there some "magic" way to tell the config parser to grab a string from the environment's connection strings or... something? Configuration builders section of the config for reference:

code:
  <configBuilders>
    <builders>
      <add name="AzureConfigurationSerivice" connectionString="halp what do here?" mode="Greedy" type="Microsoft.Configuration.ConfigurationBuilders.AzureAppConfigurationBuilder, Microsoft.Configuration.ConfigurationBuilders.AzureAppConfiguration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      <add name="Environment" mode="Greedy" type="Microsoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Environment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </builders>
  </configBuilders>
That works as long as I crack open the live config and paste in a connection string, but obviously that's not gonna cut it for automated deploys and eventually I'd want to either put the string in a keyVault or, better, just pass it the endpoint and let IAM do its thing. Anyone here made this work?

JawKnee
Mar 24, 2007





You'll take the ride to leave this town along that yellow line

biznatchio posted:

Oh my bad I totally missed that you said EF6. That approach won't work in EF6.

For EF6, I believe you can just generate the migration class; then go in and manually edit the generated code's Up method to add an appropriate check query to replace the generated CreateTable method (using the Sql method to query the database's schema tables) to see if the table actually needs to be created. Then once that migration exists, later generated migrations should presume the table already exists.

Something like this:

code:
public partial class MaybeCreatePostTags : DbMigration
{
    public override void Up()
    {
        Sql("if not exists (select 1 from information_schema.tables " +
            "where table_name = 'PostTags') create table posttags (....)");
        // removed generated code:
        // CreateTable("PostTags", ...);
    }

    public override void Down()
    {
        // probably don't want to remove the table on down, so comment out the
        // generated drop table call
        // DropTable("PostTags");
    }
}

Yeah this is unfortunately subject to the same issue as just setting `IgnoreChanges`. A table isn't created in the DB schema (good), but the generated .resx contains references to both the desired table (PostTags) and the undesired one (PostTag1)

Surprise T Rex
Apr 9, 2008

Dinosaur Gum
Is there a good guide to the differences in Application Insights logging between .Net 6 in-process functions and .Net 8 isolated worker functions?

We’ve recently upgraded and now most of our app insights logs are missing fields like Operation_Name which we usually found quite useful.

I feel like we were probably just doing the most :effort: implementation of logging ever if this has torpedoed it this badly, but there’s an absolute mess of guides for App Insights, OpenTelemetry, ASP.Net, .Net, and Azure Functions (both in and out of process models) and I can’t fully make heads or tails of what’s considered best practice.

No Pants
Dec 10, 2000

Munkeymon posted:

I'm trying to hook up Azure App Services running a Framework ASP monolith up to an App Configuration service and I've almost got it working with just web.config changes, but I can't figure out how to load the connectionString (or endpoint for that matter) from the environment/App Service's Configuration. Is there some "magic" way to tell the config parser to grab a string from the environment's connection strings or... something? Configuration builders section of the config for reference:

code:
  <configBuilders>
    <builders>
      <add name="AzureConfigurationSerivice" connectionString="halp what do here?" mode="Greedy" type="Microsoft.Configuration.ConfigurationBuilders.AzureAppConfigurationBuilder, Microsoft.Configuration.ConfigurationBuilders.AzureAppConfiguration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      <add name="Environment" mode="Greedy" type="Microsoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Environment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </builders>
  </configBuilders>
That works as long as I crack open the live config and paste in a connection string, but obviously that's not gonna cut it for automated deploys and eventually I'd want to either put the string in a keyVault or, better, just pass it the endpoint and let IAM do its thing. Anyone here made this work?

You've probably already figured it out, but there's a quickstart that shows how to grab the connection string from configuration. Adding AzureKeyVaultConfigBuilder to the mix is probably not too difficult.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



No Pants posted:

You've probably already figured it out, but there's a quickstart that shows how to grab the connection string from configuration. Adding AzureKeyVaultConfigBuilder to the mix is probably not too difficult.

Yeah, I read that but nothing I put in the attribute seems to be interpreted in any way other than what's literally in the attribute after the XSLT runs, so the answer seems to be to make a new release configuration per environment, but we only deploy the same build to all environments, so that won't work.

I'm already working on code to load the config KVPs from the service and fill in values on the configuration object during startup.

Calidus
Oct 31, 2011

Stand back I'm going to try science!
Anyone run VS 2022 on Windows for ARM inside Parallels for Mac? Dell is ruining their XPS line and I am looking at other options.

epswing
Nov 4, 2003

Soiled Meat

Calidus posted:

Dell is ruining their XPS line

How so?

susan b buffering
Nov 14, 2016

Calidus posted:

Anyone run VS 2022 on Windows for ARM inside Parallels for Mac? Dell is ruining their XPS line and I am looking at other options.

just use Rider op

Calidus
Oct 31, 2011

Stand back I'm going to try science!

15 and 17 are discounted. The new 14 and 16 don’t have physical function keys.

Calidus
Oct 31, 2011

Stand back I'm going to try science!

susan b buffering posted:

just use Rider op

Most of my work is on a large framework solution.

ChocolatePancake
Feb 25, 2007
I recommend using a 30 day trial of parallels and give it a try. I tried it once and it works fine, but I much prefer still using my desktop machine.

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost

Calidus posted:

Anyone run VS 2022 on Windows for ARM inside Parallels for Mac? Dell is ruining their XPS line and I am looking at other options.

VS fully supports ARM for supported workloads (including .NET) so you shouldn’t notice a difference. I use it for WinUI and C++ Cmake to build ARM apps and the same scripts I have work there as they do on X64.

Although IMO I would give Rider a try for Mac if you can swing it, so you wouldn’t need to run Windows at all. And the VSCode C#/C# Dev Kit plugin isn’t terrible depending on your use case.

Small White Dragon
Nov 23, 2007

No relation.
Rider is great, although I can never seem to find keybindings I like.

raminasi
Jan 25, 2005

a last drink with no ice

Calidus posted:

Most of my work is on a large framework solution.

When I worked on a large framework solution I found Rider more usable than VS, although that was admittedly several years ago at this point.

Calidus
Oct 31, 2011

Stand back I'm going to try science!
I go back an forth between Rider and VS. I use Rider for most thing, then dip back into VS if I need to edit a win form or if I need the modules window for some cursed app domain debugging.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer
I tried Rider for a bit, but it is missing a lot from VS. I still revisit it from time to time but their most recent redesign has put a nail in that. It looks like some stupid web idiot got to design productivity software. There is a hamburger menu in my IDE... No thanks...

susan b buffering
Nov 14, 2016

Canine Blues Arooo posted:

I tried Rider for a bit, but it is missing a lot from VS. I still revisit it from time to time but their most recent redesign has put a nail in that. It looks like some stupid web idiot got to design productivity software. There is a hamburger menu in my IDE... No thanks...

You can switch the hamburger menu back to just being toolbars. On a Mac that menu isn't even a thing because of how macos handles toolbars.

For me and what I'm working on Rider's code analysis and refactoring tools are extremely useful. I'm somewhat fortunate in that we just have web services in .NET, so no winforms or anything to deal with (we do have an application with a desktop GUI, but it's built with power-builder :v:)

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Hot drat Rider finally got the type dependency graph feature. Still no call hierarchy, though :smith:

CitizenKeen
Nov 13, 2003

easygoing pedant
Hey, just checking in. Long-time lurker, first time poster.

So... I'm in over my head. One of my toy apps blew up. I started last July. On February 1 I had about a thousand users, most unpaid. As of this morning I have about 19k users (of which 10k are active on a weekly basis). March was the first month where I tried to make money and I'm looking at about $1k in my first 30 days.

I wrote the app using Razor Pages as an HTMX experiment; had I known what I was doing I probably would have used Vue with a more traditional API model. Not writing any Javascript was a fun idea when it was just for fun.

(I'm a later-in-life career-change dev. I work in Enterprise software where it's stale and safe.)

I don't have any specific problem other than that I don't really know how to grow on my own (don't really want to talk side-hustle at work). I've spent the last week learning about nginx so that I could figure out some buffering issues.

Just wanted to introduce myself because I'm increasingly running into problems that I can't solve by myself (or I can but only after weeks of searching).

biznatchio
Mar 31, 2001


Buglord
Sounds like you're growing on your own already, even if you think you don't know how to. Having a problem and researching tools and asking questions on how to fix it is one of the primary ways a developer learns and grows. Knowing nginx is now a tool in your toolbox; and over time, you accumulate quite a set of tools that way. Eventually you get to a point where you realize you're solving some problems using just the tools you already know; but you never stop learning new things.

Calidus
Oct 31, 2011

Stand back I'm going to try science!
Talk to your coworkers about side project stuff over lunch if you work in an office. As long as people aren’t burnt out and don’t have young kids to rush home to most devs will happily talk shop for a free beer or two after work.

Admiral Snackbar
Mar 13, 2006

OUR SNEEZE SHIELDS CANNOT REPEL A HUNGER OF THAT MAGNITUDE
I've been learning how to write analyzers and code fix providers, and I have a question about bundling them in NuGet packages. For example, I have an existing NuGet package that is used by some other projects. I have written some analyzers and fixers to address some common issues that have come up when using the NuGet package. Is there a way to update the existing package to include the new analyzers and have those analyzers automatically run when a client project updates its package version?

Nostalgamus
Sep 28, 2010

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.

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

Kyte
Nov 19, 2013

Never quacked for this

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 just finished making an excel importer thing. At first I tried to use ExcelMapper but it's a bad fit if you're trying to account for cell type nonsense.

I ended up using ExcelDataReader plus ExcelDataReader.DataSet. They will give you a DataTable with each cell in their natural type.
Then built ReadCellString / ReadCellDate / ReadCellTime / ReadCell<T> methods that take the cell object and perform typechecks to know how to return the value you need.
For example ReadCellAsTime tests if it's a DateTime (cell type date), TimeSpan (cell type time) or arbitrary string and then does whatever's correct to return a TimeOnly.

https://github.com/ExcelDataReader/ExcelDataReader

I've also used ClosedXML in the past and it's good although a bit overkill if all you want to do is data import. It's more for creating and styling workbooks.
I've never tried to use NPOI without ExcelMapper.


E: On the issue of those numeric fields, try looking into the raw XML and look at how are the numbers being stored. Maybe the error's from the source and your library has no choice on the matter.

Kyte fucked around with this message at 16:38 on Apr 5, 2024

Supersonic
Mar 28, 2008

You have used 43 of 300 characters allowed.
Tortured By Flan
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?).

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

Adbot
ADBOT LOVES YOU

nielsm
Jun 1, 2009



Postgres can be a very good candidate for database, if you have the option to use or install the PostGIS extension. That will give you the geographic data types and operations on them to make all the map and coordinates logic much more straight forward to store and query.
To display a map with your own overlay, you can look into OpenStreetMap.

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