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
Kyte
Nov 19, 2013

Never quacked for this

Rocko Bonaparte posted:

The sorting problem is that I need to specify an IComparable that invokes functions in the scripting runtime that do the comparisons. The functions are async categorically, even if I don't expect them to actually block in this function. However, that's the interface. The problem is I don't know if I can reasonably switch the IComparables prototype to become async. I'm assuming I have to write my own sort implementation, which isn't the end of the world.

Edit: The data is all there. The comparison should normally have everything it needs. However, the internals for invoking the call to do the comparison is async.

If you are willing to risk people loving up, you could write an IComparable wrapper around some kinda IAsyncComparable interface that just does GetAwaiter().GetResult()?

Adbot
ADBOT LOVES YOU

LongSack
Jan 17, 2003

Pennywise the Frown posted:

Cross post from wrong thread.

Check out IAmTimCorey on YouTube. He has a ton of C# content starting at the very basic.

Polio Vax Scene
Apr 5, 2009



There's a developer on our team that continues to use .NET Framework for all their work. I think they're intimidated by .NET Core or something. Any good resources you recommend that can be used to convince them to swap?


vvv Even though we are on the same team, we primarily work on separate projects. The requirement to have all projects on the same framework has not been mandated yet, but I suspect that will be happening soon, and want to have as little friction as possible when it does become reality.

Polio Vax Scene fucked around with this message at 17:58 on Dec 20, 2021

raminasi
Jan 25, 2005

a last drink with no ice

Polio Vax Scene posted:

There's a developer on our team that continues to use .NET Framework for all their work. I think they're intimidated by .NET Core or something. Any good resources you recommend that can be used to convince them to swap?

How is your development process even permitting this? Do you not work on shared codebases?

ThePeavstenator
Dec 18, 2012

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

Establish the Buns

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

Polio Vax Scene posted:

There's a developer on our team that continues to use .NET Framework for all their work. I think they're intimidated by .NET Core or something. Any good resources you recommend that can be used to convince them to swap?

It’s been very clear for years now that .NET Core is where all the development effort is going - https://devblogs.microsoft.com/dotnet/net-core-is-the-future-of-net/

.NET Core was also rebranded to just .NET to further drive that point home - https://devblogs.microsoft.com/dotnet/introducing-net-5/

epswing
Nov 4, 2003

Soiled Meat

Polio Vax Scene posted:

There's a developer on our team that continues to use .NET Framework for all their work. I think they're intimidated by .NET Core or something. Any good resources you recommend that can be used to convince them to swap?

Could depend on the size of the project(s) they're working on, and the list of dependencies required. Switching from .NET Framework 4.8 to .NET 6 has required us to update or replace many, many dependencies. That's not to say it shouldn't be done, it really should. But it's more than just picking a new target from a dropdown list and calling it a day.

Canine Blues Arooo
Jan 7, 2008

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



Grimey Drawer
Unless you are doing work on front end, there isn't a compelling reason to not be on Core. Conversely, all my projects with UI are still on Framework.

Porting existing projects is of course very project specific.

GI_Clutch
Aug 22, 2000

by Fluffdaddy
Dinosaur Gum
I had to do my latest project in Framework because the only things it does is query a table to get a list of case numbers, then call an 11 year old state-provided SOAP-based web service about 40k times in a row to get the latest data to update the DB. MS basically said gently caress SOAP in .NET/Core, so Framework it is (and even then, I had to modify the code wsdl.exe generated to get the drat thing to work). The only good thing to come out of it is I finally took the time to try out Polly which in testing already recovered after numerous DNS errors, timeouts, host forcibly closed the connection, SoapExceptions, etc. allowing it to do a full 2+ hour run without having to skip an update because of minor hiccups.

NiceAaron
Oct 19, 2003

Devote your hearts to the cause~

FYI, creating a SOAP client is still supported in .NET Core - I've done it before. It's creating a SOAP service that is no longer supported.

GI_Clutch
Aug 22, 2000

by Fluffdaddy
Dinosaur Gum

NiceAaron posted:

FYI, creating a SOAP client is still supported in .NET Core - I've done it before. It's creating a SOAP service that is no longer supported.

If you're talking about adding a connected service and picking the WCF option that lets you point to a WSDL and works with SOAP, I've tried it and it doesn't work with this one. I got it to work on a simple SOAP service, but this one was built by people in love with Java and their documentation has a page about how they built the service using the such-and-such methodology because they think it is the future of web service design. Then pages of "C# doesn't support arrays properly so here are all the manual changes you need to make to the generated code". Attempting to use what VS generates for .NET 5/6 throws exceptionswhen trying to call a method.

If you know of some other method, I'm all ears.

adaz
Mar 7, 2009

GI_Clutch posted:

If you're talking about adding a connected service and picking the WCF option that lets you point to a WSDL and works with SOAP, I've tried it and it doesn't work with this one. I got it to work on a simple SOAP service, but this one was built by people in love with Java and their documentation has a page about how they built the service using the such-and-such methodology because they think it is the future of web service design. Then pages of "C# doesn't support arrays properly so here are all the manual changes you need to make to the generated code". Attempting to use what VS generates for .NET 5/6 throws exceptionswhen trying to call a method.

If you know of some other method, I'm all ears.

this sounds like the last time I ran into a soap service where they were generating invalid SOAP schema and/or generating such esoteric weird (but technically correct) WSDL that .net never cared to support because SOAP was dead 15 years ago. I think I ended up generating the java classes off of the schema then hand converting them to C#

NihilCredo
Jun 6, 2011

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

GI_Clutch posted:

If you're talking about adding a connected service and picking the WCF option that lets you point to a WSDL and works with SOAP, I've tried it and it doesn't work with this one. I got it to work on a simple SOAP service, but this one was built by people in love with Java and their documentation has a page about how they built the service using the such-and-such methodology because they think it is the future of web service design. Then pages of "C# doesn't support arrays properly so here are all the manual changes you need to make to the generated code". Attempting to use what VS generates for .NET 5/6 throws exceptionswhen trying to call a method.

If you know of some other method, I'm all ears.

dotnet tool install dotnet-svcutil && dotnet dotnet-svcutil <url to WSDL file>

I invoke SOAP services from .NET Core on Linux by pointing to WSDLs. There are various flags for stuff like generating sync methods, implementing INotifyPropertyChanged, etc.

Red Mike
Jul 11, 2011

NihilCredo posted:

dotnet tool install dotnet-svcutil && dotnet dotnet-svcutil <url to WSDL file>

I invoke SOAP services from .NET Core on Linux by pointing to WSDLs. There are various flags for stuff like generating sync methods, implementing INotifyPropertyChanged, etc.

I'll be a second person to confirm that while yes theoretically that works, it won't always work on the weird Java-based SOAP services you might sometimes have to call.

For example, when doing integration with classic Oracle ERP (ignoring that one half of the services need you to host a SOAP service anyway, but chances are you don't need those) the WSDL they offer contains specific encryption/WSDL extensions that they use (which were never really implemented in .NET). When you generate your .cs file it'll work fine, and when you call the web service it'll reject your request. For this particular case, I couldn't get it working on .NET Framework either.

As a different more recent example, when integrating with a postal order broker service, their WSDL used addressing modes that aren't supported in .NET Core or SoapCore but are supported in .NET Framework. How you generate the C# class/wrappers isn't relevant here I don't think, but running it on a .NET Core application fails because the request that goes out will just ignore the addressing mode. If you tweak the code to force that addressing mode to be used, you'll get a not implemented exception I think (might have been just in SoapCore).

So what the previous poster said: "invalid SOAP schema and/or generating such esoteric weird (but technically correct) WSDL"

NihilCredo
Jun 6, 2011

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

Oh yeah, there's definitely plenty of weird SOAP implementation quirks around, but it's pretty normal to find slight incompatibilities between clients and servers, especially when crossing between JVM and CLR worlds. Dotnet-svcutil isn't special in that regard.

For example, over the years I saw several SOAP tools crash hard when pointed at our own internal legacy SOAP service. Why? It was written as a classic .NET Web Service in Visual Basic circa 2009, and it uses - of all goddamn things - ref parameters in SOAP method signatures. (Thankfully dotnet-svcutil works on it.)

I have to say though that my favourite way to write SOAP client code was to take XML straight from the provided/generate sample requests, dump it into a .vb source file as a XML literal value, and replace the tag contents with variables :v:

Red Mike
Jul 11, 2011
Related to that, that second example I gave of a postal order broker service, we ended up agreeing on the service offering an updated SOAP service that used more standard things which worked in .NET Core. Unfortunately that meant my next task was to set up a mock of the service to be used for testing instead of the live endpoint (for various good reasons). Getting that done in .NET Core with SoapCore proved impossible because of one of the more standard things, and I wanted to avoid .NET Framework wherever possible.

So we just figured out all the potential responses and did text replacement to generate them. That was about a year ago and I've since left the company, so I bet I'm being cursed at by newer devs discovering that particular project.

GI_Clutch
Aug 22, 2000

by Fluffdaddy
Dinosaur Gum

NihilCredo posted:

dotnet tool install dotnet-svcutil && dotnet dotnet-svcutil <url to WSDL file>

I invoke SOAP services from .NET Core on Linux by pointing to WSDLs. There are various flags for stuff like generating sync methods, implementing INotifyPropertyChanged, etc.

Oh yeah, I tried using that a well a couple weeks ago. My first issue was that it looks like it hadn't been updated for .NET 6 yet and it threw errors until I installed the .NET 5 SDK on the machine I had to install VS on within their network. I installed that and was able to create something, but it didn't work because of the issues mentioned by others.

Maybe it had similar issues to correct as wsdl.exe generated, but I just didn't have time to fiddle around anymore. The fixes for the array issues with wsdl.exe were to update the attributes to remove the namespace and change the names from "item" to whatever the backing field/property was named. Even after those changes the response was always null until I noticed other namespaces didn't match what was actually coming back in the response when calling it with SoapUI, so I updated those and tada, I finally going something back besides null.

zokie
Feb 13, 2006

Out of many, Sweden
I also had to touch a SOAP recently, thankfully it looks like SoapCore will work for us. But it doesn’t allow you to control some of the parameter names completely, so what I did was generate a client from the wsdl of the legacy service we are replacing. Then used the generated [ServiceContract] and down to for our replacement implementation. It because of the previously mentioned SoapCore thing I had to use a hosted wsdl file instead of the one generated by SoapCore.

TheBlackVegetable
Oct 29, 2006
Has anyone played with the new Blazor hot reload and got it working? I've done everything I think is necessary but I've had no luck - even using the minimal examples from the dotnet new blazorwasm client.

Is there a good step-by-step tutorial I can follow?

bobua
Mar 23, 2003
I'd trade it all for just a little more.

TheBlackVegetable posted:

Has anyone played with the new Blazor hot reload and got it working? I've done everything I think is necessary but I've had no luck - even using the minimal examples from the dotnet new blazorwasm client.

Is there a good step-by-step tutorial I can follow?

I tried over and over again over the last few months as they claimed it would work in various scenarios\previews. Never had an ounce of luck. Now I'm using .net 6 with vs 2022 (both preview and release) and it's finally working. Didn't do anything or use any special template.


Speaking of hot reload, Ill change something like 3 EF queries deep in an injected service and rename some variables and it will hot reload like a champ... then I'll move an html element and it will be like CLEAN AND REBUILD! Still wonderful, but weird.

Supersonic
Mar 28, 2008

You have used 43 of 300 characters allowed.
Tortured By Flan
I'm writing an api wrapper and am currently trying to deserialize this JSON response: http://data.nba.net/json/bios/player_201935.json

I'm able to get the response correctly, but my model keeps getting null properties. Is there a step I'm missing in this code?

https://pastebin.com/5g6c32sR

I'm using this deserializer (https://json2csharp.com/json-to-csharp) which outputs a Bio class and a Root class containing a bio object to model the DTOs after.

Supersonic fucked around with this message at 15:08 on Dec 31, 2021

Just-In-Timeberlake
Aug 18, 2003

Supersonic posted:

I'm writing an api wrapper and am currently trying to deserialize this JSON response: http://data.nba.net/json/bios/player_201935.json

I'm able to get the response correctly, but my model keeps getting null properties. Is there a step I'm missing in this code?

https://pastebin.com/5g6c32sR

I'm using this deserializer (https://json2csharp.com/json-to-csharp) which outputs a Bio class and a Root class containing a bio object to model the DTOs after.

I’m not near a machine to mess with it so I can’t help with the null issue, but you should stop doing what you’re doing with the HttpClient before you get too far along and it becomes a real pain in the rear end to fix.

https://www.aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/

Supersonic
Mar 28, 2008

You have used 43 of 300 characters allowed.
Tortured By Flan
Thanks, I've made this change now!

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Supersonic posted:

I'm able to get the response correctly, but my model keeps getting null properties. Is there a step I'm missing in this code?

What properties are null? Are they always null, or only null in some cases? If they're only null in some cases, have you looked at the data directly?

Also don't catch exceptions unless you're going to do something with the exception. The catch { throw; } thing is completely useless.

Supersonic
Mar 28, 2008

You have used 43 of 300 characters allowed.
Tortured By Flan

New Yorp New Yorp posted:

What properties are null? Are they always null, or only null in some cases? If they're only null in some cases, have you looked at the data directly?

Also don't catch exceptions unless you're going to do something with the exception. The catch { throw; } thing is completely useless.

The response comes back with the correct JSON, but looking at my playerBioModel return, all the properties are null:


This leads me to believe that there's an issue with my playerBioRootDto line.

HexiDave
Mar 20, 2009
Should PlayerBioRootDto have a nested property called PlayerBioDto? The JSON looks like it's trying to map it to one called "Bio", so I'm wondering if the PlayerBioDto property isn't mapped correctly.

Supersonic
Mar 28, 2008

You have used 43 of 300 characters allowed.
Tortured By Flan

HexiDave posted:

Should PlayerBioRootDto have a nested property called PlayerBioDto? The JSON looks like it's trying to map it to one called "Bio", so I'm wondering if the PlayerBioDto property isn't mapped correctly.

This solved it, thanks!

epswing
Nov 4, 2003

Soiled Meat

Supersonic posted:

I'm using this deserializer (https://json2csharp.com/json-to-csharp) which outputs a Bio class and a Root class containing a bio object to model the DTOs after.

If you’re not aware, if you have a good sample of the data, you can “Edit -> Paste Special -> XML/JSON as classes” in a .cs file and VS will generate the class/property structure for you. Sometimes not perfectly but it’s usually easy to fix up.

Supersonic
Mar 28, 2008

You have used 43 of 300 characters allowed.
Tortured By Flan

epswing posted:

If you’re not aware, if you have a good sample of the data, you can “Edit -> Paste Special -> XML/JSON as classes” in a .cs file and VS will generate the class/property structure for you. Sometimes not perfectly but it’s usually easy to fix up.

This is handy, thanks!

Supersonic fucked around with this message at 20:41 on Dec 31, 2021

insta
Jan 28, 2009
I have a task coming up where a customer wants to define a crude UI in an end-user-editable file, and I make databound controls from that at runtime. It has to be cross-platform.

Where to start?

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

insta posted:

I have a task coming up where a customer wants to define a crude UI in an end-user-editable file, and I make databound controls from that at runtime. It has to be cross-platform.

Where to start?

I would find out what problem they're trying to solve and propose a realistic solution to their problem. What they are proposing is a completely unworkable poo poo show that is guaranteed to fail.

This is 100% a problem of setting expectations correctly and customer management. They want to not need developers to adapt their software to changing needs because developers are expensive. This is an incredibly common bad idea that comes from non technical bean counters.

WorkerThread
Feb 15, 2012

insta posted:

I have a task coming up where a customer wants to define a crude UI in an end-user-editable file, and I make databound controls from that at runtime. It has to be cross-platform.

Where to start?

The rare opportunity to reinvent html, but do it right this time. Good work if you can get it.

insta
Jan 28, 2009

New Yorp New Yorp posted:

I would find out what problem they're trying to solve and propose a realistic solution to their problem. What they are proposing is a completely unworkable poo poo show that is guaranteed to fail.

This is 100% a problem of setting expectations correctly and customer management. They want to not need developers to adapt their software to changing needs because developers are expensive. This is an incredibly common bad idea that comes from non technical bean counters.

The actual use-case is customers defining 'dashboards' for serial-connected devices. The devices will have different parameters that can be either read or written, and sometimes the 'write' needs to be an expression from the 'read'. The devices are not all the same, and each customer has a different use-case for the parameters they want to read or write.

I'm willing to push back against this, but the customer's requirements in this case were fairly reasonable. I mean, at some point, some business unit said "we need to let them draw Win32 controls onto a form so they can attach to the events..." in order for WYSIWYG editors like VB6.

I'm still willing to entertain really any path I can go down, and the customer is ultimately just trying to solve the problem of end-user-with-support-help definable dashboards.

distortion park
Apr 25, 2011


Are the "writes" meant to only be manually triggered? You might be able to hack something together using Retool but I kind of agree that this sounds like a massive project that would likely require continuous engineering support.

nielsm
Jun 1, 2009



It might be possible to put a huge effort into developing viewmodel classes for WPF and then let the "users" supply a WPF XML file and just hook up the viewmodel to that at runtime.
It would still be very fragile and require a lot of knowledge from the UI designers ("users") and yeah, continuous developer support for the viewmodels.

And unless the devices are very similar on a technical level, you'd have to develop a viewmodel and underlying support for each anyway. After that, making a WPF GUI on top would be the lesser part.

Supersonic
Mar 28, 2008

You have used 43 of 300 characters allowed.
Tortured By Flan
On the topic of WPF, I've been working on a larger WPF project with some other people, and one issue I've been running into is understanding Databinding. For example, consider the following view:
code:
<dx:LoadingDecorator
    x:Class="QDev.DataManagement.Client.Wpf.Views.CustomizableLoadingDecorator"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:local="clr-namespace:QDev.DataManagement.Client.Wpf.Views"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="450"
    d:DesignWidth="800"
    SplashScreenDataContext="{Binding }">
        <dx:LoadingDecorator.SplashScreenTemplate>
            <DataTemplate>
                <dx:WaitIndicator Content="{Binding }" DeferedVisibility="True">
                    <dx:WaitIndicator.ContentTemplate>
                        <DataTemplate>
                        <TextBlock Text="{Binding SpinnerText}" />
                        </DataTemplate>
                    </dx:WaitIndicator.ContentTemplate>
                </dx:WaitIndicator>
            </DataTemplate>
        </dx:LoadingDecorator.SplashScreenTemplate>
</dx:LoadingDecorator>


The splash screen and data template both use {Binding} with nothing specified. Looking at example view files from MS documentation, they all seem to explicitly set this to something, eg:
code:
Background = "{Binding ElementName = comboBox, Path = SelectedItem.Content}">
How can I tell what is bound to what here?

Supersonic fucked around with this message at 13:42 on Jan 1, 2022

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

insta posted:

I mean, at some point, some business unit said "we need to let them draw Win32 controls onto a form so they can attach to the events..." in order for WYSIWYG editors like VB6.

Yeah, enormous teams have spent millions of dollars on these sort of things and still have not managed to accomplish the dream of "software being meaningfully createable by someone who is not a developer". You're unlikely to succeed where they have failed.

My recommendation would be to encourage your clients to accept that, and provide them with library components that a developer on their end can very easily assemble into a dashboard for their specific needs.

NihilCredo
Jun 6, 2011

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

insta posted:

The actual use-case is customers defining 'dashboards' for serial-connected devices. The devices will have different parameters that can be either read or written, and sometimes the 'write' needs to be an expression from the 'read'. The devices are not all the same, and each customer has a different use-case for the parameters they want to read or write.

It doesn't seem that bad to me, as long as the functionality of each control is strictly limited to "send/read value X to device Y". You'll support like four or five different controls in total - text field, toggle, slider, listbox, radio buttons.

If looks aren't a priority I might consider Windows Forms here, since generating user controls via code is a lot simpler.

All the nice stuff from WPF that makes layouts easier will be useless here as you'll most likely just be reading raw pixel sizes from the user's text file, and it will be their problem to correctly align poo poo.

Unless the requirements include that the whole thing be responsive and customizable beyond the bare minimum, in which case you are indeed reinventing a limited subset of html.

BTW: I suggest TOML for the text file, it's understandable to non-technical users and you can parse it with a library.

Calidus
Oct 31, 2011

Stand back I'm going to try science!

insta posted:

I have a task coming up where a customer wants to define a crude UI in an end-user-editable file, and I make databound controls from that at runtime. It has to be cross-platform.

Where to start?

Retool.com, then build them an API or use the DB connectors

mystes
May 31, 2006

NihilCredo posted:

BTW: I suggest TOML for the text file, it's understandable to non-technical users and you can parse it with a library.
Or just do the absolute bare minimum and use Roslyn since it's not going to work anyway.

Adbot
ADBOT LOVES YOU

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

mystes posted:

it's not going to work anyway.

I've seen customers go down this road too many times to not agree with you. The end result, if it works at all, will be hated by the people who use it.

The only even theoretically workable approach I could think of would be to have a lot of pre-defined layout and just stick fields into that layout. i.e. "You have a 5x5 grid. Specify the column and row number." Anything much more complex than that will be a nightmare.

Except then they're going to want validation rules. Or fields that calculate their value depending on the values of other fields. Or fields that are conditionally visible. And now you're building your own lovely XML/JSON/TOML/YAML/ALABAML/whatever-based programming language.

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