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
nielsm
Jun 1, 2009



The event log was obviously the first thing I should have checked, and I did find some useful backtraces. I'll augment those locations and add some more logging first.

Adbot
ADBOT LOVES YOU

nielsm
Jun 1, 2009



Followup: Adding some log4net and logging unhandled exceptions in the App object was in fact a really good idea. (Thank you for making it easy to log exceptions for once.) It turns out a server was delivering truncated JSON data which caused the parser to throw, and I was not handling that.

Roid666
Jul 18, 2010
Great job! Glad I could be of some small assistance!

Mr Shiny Pants
Nov 12, 2012

NihilCredo posted:

Edit: Come to think of it, you could separate the "backflow" from the events with a couple lines of code. It would be barely any safer than the event handler route, but it would convey intent much better:

code:
type Server() =

  member val GetSessionInfo : unit -> SessionInfo option = (fun () -> None) with get, set

  // etc.
 | {Method = "GET"; Url = [|"session"|]} ->
     let info = this.GetSessionInfo()
     do event.Trigger() // if you still need this for other reasons
  // etc.
code:

  server.SomeEvent += SomeHandler;
  // add this:
  server.GetSessionInfo = (
     () => if (State.CurrentPlayer != null)
                {
                    print("Player is not null");
                    return Microsoft.FSharp.Core.FSharpOption<Types.SessionInfo>.Some(new Types.SessionInfo(State.CurrentPlayer.Id, State.CurrentPlayer.Name, State.CurrentPlayer.Time));
                    
                } else { return Microsoft.FSharp.Core.FSharpOption<Types.SessionInfo>.None; }
   );

I had some time and got to work on this and I have to say this is really clever and elegant. To be honest I never really had a need for the val keyword so I didn't grasp how it would all fit together at first but I see now.

Edit: I mean putting a func in a property. I had to do some FuncConvert stuff to get it to work on the C# side, but it works. Thanks!

Mr Shiny Pants fucked around with this message at 10:05 on May 5, 2019

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION

LongSack posted:

Is there a good reason why static classes can’t implement an interface? I have an instance where I’d love to declare a constructor as
C# code:
public ImportViewModel<T>(List<T> existing, string description, IDataAccessLayer DAL)
but since my DAL classes are all static, they can’t implement the interface. So instead, I have to do
C# code:
public ImportViewModel<T>(List<T> existing, string description, Type dalType)
and use reflection.

It works, but interfaces would be better.

A DAL should definitely not be static. I'm curious to see what the code looks like inside one of these static DALs.

Xik
Mar 10, 2011

Dinosaur Gum
I'd like to see the unit tests of components that call a static DAL.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Xik posted:

I'd like to see the unit tests of components that call a static DAL.

#if UNIT
using static MockDAL;
#elseif INTEGRATION
using static RealDAL;


would probably work pretty well.

Xik
Mar 10, 2011

Dinosaur Gum

NihilCredo posted:

#if UNIT
using static MockDAL;
#elseif INTEGRATION
using static RealDAL;


would probably work pretty well.

Thanks, I hate it.

mystes
May 31, 2006

Microsoft is officially rebranding the next release of .net core as ".NET 5" as part of the process of deprecating .net framework (now that it will be possible to use stuff like wpf from .net core).

This is similar to how they just announced that powershell core will just be called powershell from now on.

bigmandan
Sep 11, 2001

lol internet
College Slice

mystes posted:

Microsoft is officially rebranding the next release of .net core as ".NET 5" as part of the process of deprecating .net framework (now that it will be possible to use stuff like wpf from .net core).

This is similar to how they just announced that powershell core will just be called powershell from now on.

I only dabble with .net... does "use stuff like wpf from .net core" mean you could potentially use wpf in the linux runtime?

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost

bigmandan posted:

I only dabble with .net... does "use stuff like wpf from .net core" mean you could potentially use wpf in the linux runtime?

No. This is "One .NET." The doc explains it better than I ever could, but it doesn't change UI toolkits. WPF And WinForms are still very much tied to Windows.

If you want a cross-platform UI toolkit, you should look at Xamarin.Forms, which can target WPF on Windows and GTK# on Linux, and a ton of other platforms.

mystes
May 31, 2006

What's the actual status of GTK# support in Xamarin Forms? I searched for information a few weeks ago and I found some separate github repository from 6 months or so earlier, but it also hadn't been updated in months at that point; I thought maybe it was a bad sign but is it actually because it has been merged into mainline Xamarin Forms or something?

Was there a release announcement that I missed?

Edit: Is gtk# supposed to be officially coming out in Xamarin Forms 4.0? If so why does nothing in their website say so?

mystes fucked around with this message at 21:10 on May 6, 2019

redleader
Aug 18, 2005

Engage according to operational parameters

mystes posted:

Microsoft is officially rebranding the next release of .net core as ".NET 5" as part of the process of deprecating .net framework (now that it will be possible to use stuff like wpf from .net core).

This is similar to how they just announced that powershell core will just be called powershell from now on.

Well, I'm glad Microsoft aren't trying to make the .NET ecosystem even more confusing.

mystes
May 31, 2006

redleader posted:

Well, I'm glad Microsoft aren't trying to make the .NET ecosystem even more confusing.
In this case it's not more confusing, though. Framework is dead and core is the future, period. They have basically already been saying that for like 6 months to a year, but I guess as long as they maintained different names/version number schemes windows users were trying to ignore core, so they are just trying to make it even clearer.

This should actually resolve a bunch of confusion about the .net ecosystem. I think the only major remaining point of confusion is having both desktop WPF and UWP. Microsoft doesn't seem eager to do anything about that but I think they're going to have to make some sort of decision within the next year or so.

mystes fucked around with this message at 21:27 on May 6, 2019

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Yeah the big If here is if WPF et al actually go away in any meaningful sense

LongSack
Jan 17, 2003

I apologize in advance for the length of this reply.

a hot gujju bhabhi posted:

A DAL should definitely not be static. I'm curious to see what the code looks like inside one of these static DALs.

Standard ADO CRUD operations. Like an example (stuff omitted since I’m on iPad):
C# code:
public static class FooDAL
{
    private static readonly string _cs = SQLUtilities.BaseConnectionString.AddDatabase(“foodb”);

    public static int Insert(Foo f)
    {
        int ret = 0;
        using (var conn = new SqlConnection(_cs))
        {
            conn.Open();
            string sql = “insert into foo (...) output inserted.Id values (...);”;
            using (var command = new SqlCommand(sql, conn))
            {
                command.AddParm(...); // if needed for parameters in sql
                ret = (int)command.ExecuteScalar();
             }
        }
        return ret;
    }
}
Understand that I’m not a developer. I don’t work in a software shop. I don’t work with a team of other developers, designers, DBAs, etc. I don’t use DI (except in ASP.NET). I don’t do unit tests. I’m a Security Engineer who manages a load of firewalls and other threat detection / prevention devices. I write these programs for three reasons - one, I enjoy it. Two, I do it to learn how to do different things. Three, I get useful tools that help me in my day-to-day that do exactly what I need them to do, exactly how I need it done.

I originally started using static DAL classes when the Print method for one of my programs literally needed twelve DAL classes passed in as parameters. Yes, I know how to fix that now, but here’s the thing - the static classes work, and work well for me.

All that being said, I’ve taken the suggestions here to heart and am learning another way to do things. I’m currently rewriting my simplest program, a time tracking and reporting tool, to make these changes:

1. Replace JSON file timesheets with a database.
2. DB access is using EF Core 2.1
3. Project is using .NET Framework 4.7.2 and WPF for presentation.
4. The (non-static) DAL classes get POCO entity classes from EF and produce observable DTO classes that the ViewModels use. The DAL classes handle the translation between entity objects and DTO objects using a custom Mapper class.
5. The ViewModels get their DAL classes by using a custom Registrar class (which is static) that maps Interfaces to objects. The VMs request an interface and the registrar returns an instance of the class that implements that interface. Yes, it’s similar to DI.

And, yes, I know I could have used “off-the-shelf” components for entity mapping and my “registrar”, but that’s not the point. I’m learning. An example, my Registrar class checks that the concrete type can actually be returned as an instance of the interface (using IsAssignableFrom()). This works great for Registrar.Register<IFooDAL, FooDAL>(), but how about Registrar.Register<IFoo<int>,Foo<int>>(). Haven’t quite figured that one out yet (or even whether I need to)

LongSack fucked around with this message at 02:01 on May 7, 2019

Munkeymon
Aug 14, 2003

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



You could probably replace that with a few lines using Dapper

Dietrich
Sep 11, 2001

LongSack posted:

I don’t use DI (except in ASP.NET)

You're doing DI, dude.

LongSack posted:

An example, my Registrar class checks that the concrete type can actually be returned as an instance of the interface (using IsAssignableFrom()). This works great for Registrar.Register<IFooDAL, FooDAL>(), but how about Registrar.Register<IFoo<int>,Foo<int>>(). Haven’t quite figured that one out yet (or even whether I need to)

This is a form of DI. You've created your own DI container, you're registering concretions with abstractions and asking for the abstraction from the container provided as an ambient context. You're like two steps away from making it true DI by just having the registry new up the concrete type and resolve any dependencies it has by checking itself, and adding a "release" operation where you pass the injected service back to the DI Container so it can clean up any disposable dependencies.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

LongSack posted:

And, yes, I know I could have used “off-the-shelf” components for entity mapping and my “registrar”, but that’s not the point. I’m learning.

99% of software development is knowing when to not reinvent the wheel in the name of learning, and instead learn how to use an off-the-shelf tool so that you can get back to solving problems, instead of solving meta-problems.

I'm seeing that this is a recurring pattern with you. You say "I'm trying to solve <problem X> by <reinventing tool Y>". People (me) say "You're reinventing the wheel. Use <tool Y>." You respond with "I'm learning!" It's a pattern we see in the industry all the time, it's called "Not Invented Here", and it's always bad.

There's nothing wrong with learning, and there's certainly educational value in reinventing Tool Y to understand how Tool Y might work under-the-hood. But you should ultimately just use Tool Y, because there's almost no chance that you did a better job of solving that specific problem than the person or people responsible for Tool Y.

Dietrich
Sep 11, 2001

As a consulting developer I love NIH orgs, because I can roll in and blow their mind with getting something done in one-eighth of the time it would have taken them by using third party libs where they would be spinning their wheels for 4 weeks re-writing JSON.net.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Dietrich posted:

As a consulting developer I love NIH orgs, because I can roll in and blow their mind with getting something done in one-eighth of the time it would have taken them by using third party libs where they would be spinning their wheels for 4 weeks re-writing JSON.net.

jason dot net is so bad though; i wish someone put in the effort to build a better jason :smith:

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
What's so bad about json.net? I mean I really don't know about anything else besides gson and the built-in python one, but it seems to do the needful pretty quicklike.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

dougdrums posted:

What's so bad about json.net? I mean I really don't know about anything else besides gson and the built-in python one, but it seems to do the needful pretty quicklike.

the thing that makes me groan about json.net are all the stupid dependency issues i've had to deal with involving the library

- there was a version of json.net which pulled in 100+ dependencies on different projects in nuget when added to a project. (this is fixed)
- json.net had a bunch of releases back in the day that incremented the major version but didn't really change the functionality, and since a lot of loving stuff uses json .net, you might have to deal with library 1 that uses version 6, library 2 that uses version 9, etc. and it all goes to hell if they need to run at the same time. easily fixable with binding redirect, easily detectable using assembly binding logging, but annoying.
- while not nearly as bad as the gently caress ups in .net standard, net core has a dependency on specific json.net versions (this is supposed to be fixed in .net 30)

i mean you'll probably just end up with the stupid thing as a dependency in your project anyway, it does the job well enough, and the dependency problems are mostly a function of it being a victim of its own success, but man can that poo poo be annoying if something goes wrong.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.
my favorite issue is this one closed won’t fix where strings that look like datetimes get parsed as datetimes (sometimes incorrectly) with no way to recover the parse string

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

That's horrible, you should post it in the coding horrors thread

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

leper khan posted:

jason dot net is so bad though; i wish someone put in the effort to build a better jason :smith:

You might like FSPickler, depending on what you need to do with your jason (read carefully the 'Why FSPickler?' section).

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)

Bruegels Fuckbooks posted:

the thing that makes me groan about json.net are all the stupid dependency issues i've had to deal with involving the library
Yeah I remeber wrestling with this in the past ... I must have purged it from my memory ... This is just 100% brain damaged.

quote:

@JamesNK could you explain the reasons behind this design? It seems pretty strange to me that a string value should arbitrarily be interpreted as a date just because it looks like a date...

@JamesNK posted:

Because JSON doesn't have a date format.
:psyduck:I've gotta go change some old code now ...

Dietrich
Sep 11, 2001

(It's open source dudes, send a pull request with the feature you want)

necrotic
Aug 2, 2005
I owe my brother big time for this!
Any PR changing that default behavior is likely to get immediately rejected by the author.

quote:

I have no plans to change it, and I would do it again if give the chance.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
TFW when you mean to write C# but end up writing PHP instead

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
Yeah I thought about submitting one that just changed the default, but it seemed like a dick move. Still might do it anyways.

rarbatrol
Apr 17, 2011

Hurt//maim//kill.

That sounds a lot like something Elasticsearch does if you write a new field. It'll guess the type and then the field is that type forever.

Che Delilas
Nov 23, 2009
FREE TIBET WEED
gently caress it, CSV for serialization forever.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
Does anybody know of a good library to create a text shell console application? I'm talking about having an actual command prompt and commands. I'm feeling particularly lazy about doing this half-assed manually so I hoped there was something nice I could use instead.

I found this:
https://github.com/janpieterz/CommandRunner

But it seems keen on this menu/submenu thing and vomiting out the main menu after each shell command. The pollution from that is going to be very annoying for what I'm trying to do.

EssOEss
Oct 23, 2006
128-bit approved
Mono.Options is my go-to command line args parser, can't beat it IMO. It was previously called NDesk.Options and this name can get you better docs online still to this day.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

A bit different from what I think you're looking for, but check this out: https://github.com/migueldeicaza/gui.cs

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

EssOEss posted:

Mono.Options is my go-to command line args parser, can't beat it IMO. It was previously called NDesk.Options and this name can get you better docs online still to this day.

Ahhh I wasn't looking for a command-line argument parser, but a command-line console helper. I was hoping to get something to help me present basic terminal commands like:
code:
>Do this
>Do that
>Set X 3
...and stuff like that.

What's funny with you bringing that up all my searching gets polluted by command-line argument stuff.


NihilCredo posted:

A bit different from what I think you're looking for, but check this out: https://github.com/migueldeicaza/gui.cs
Very pretty and that does take me back, but I'm looking for more like a REPL with maybe a basic command pattern framework or something. Actually, I probably should have just looked for a REPL...

...lol yes I think I should have been searching for a REPL:
https://github.com/piksel/LibREPL

LongSack
Jan 17, 2003

Is anyone using VS2019 having it randomly upcasing the builtin classes, so that string becomes String? Which, of course, VS then tells me that the declaration can be simplified and recommends changing it back to string. It's getting irritating.

B-Nasty
May 25, 2005

LongSack posted:

Is anyone using VS2019 having it randomly upcasing the builtin classes, so that string becomes String?

Probably obvious, but have you checked your language settings / editorconfig settings? Do you have the Intellicode plugin?

I haven't noticed this behavior with 2019 myself.

Adbot
ADBOT LOVES YOU

LongSack
Jan 17, 2003

B-Nasty posted:

Probably obvious, but have you checked your language settings / editorconfig settings? Do you have the Intellicode plugin?

I haven't noticed this behavior with 2019 myself.

It doesn’t happen all the time, so I don’t think it’s an editor setting, but yeah, I do have Intellicode enabled. That’s probably it. I guess I’ll have to wait and see if the annoyance of this outweighs the utility of intellicode. Thanks.

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