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
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.

insta posted:

How do I safely "get into" an async/await stack if I'm not in one to begin with?

When people shoot themselves in the foot with async, it's usually because they try to introduce async to codebase that wasn't using it, or trying to mix async and sync methods. Async is a nice and easy convenience if it's all the way down the stack. What fucks people up is trying to mix and match sync/async, or refactoring existing code to use async (especially code uses framework instead of core). It's possible to do either safely, but it can be a very expensive learning experience, as it's possible to introduce issues that will sail through test just fine and deadlock in production.

I would suggest starting fresh and working through .NET core examples or playing with an existing open source project.

Adbot
ADBOT LOVES YOU

biznatchio
Mar 31, 2001


Buglord

raminasi posted:

Yes please don’t un-idiomatically use compiler internals directly just to save three lines of error handling code.

MSDN Magazine suggested using GetAwaiter().GetResult() when you need to block a thread to wait; but underneath the wider and much better advice that you shouldn't be blocking threads to wait for tasks in the first place because it's a recipe for deadlocks no matter how you do it.

Calidus
Oct 31, 2011

Stand back I'm going to try science!

New Yorp New Yorp posted:

Old-days Microsoft would have. New-days Microsoft just says "eh, screw it, we lost the battle -- let's throw our support behind the winner".

Sad part is I am really starting to believe it’s a better tool for 80% of .NET shops.

Sab669
Sep 24, 2009

e; never mind, UX dictates what I'm doing was a poor way to implement certain functionality anyways :)

Sab669 fucked around with this message at 15:32 on Sep 28, 2020

Just-In-Timeberlake
Aug 18, 2003
I guess this is a .NET question? If not, let me know.

I have a .netCore AWS Lambda project and I was wondering if there's a way to have different deployment config files (like in ASP.NET, web.debug.config, web.release.config) so I can deploy to different Lambda apps? Like have the following files:

aws-lambda-tools-defaults.development.json => deploy to dev
aws-lambda-tools-defaults.staging.json => deploy to staging
aws-lambda-tools-defaults.production.json => deploy to production

or using the serverless.template file? I can't quite seem to find the documentation I need for this.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
If you haven't updated to Visual Studio version 16.7.5 yet, don't; it's super unstable.

adaz
Mar 7, 2009

Just-In-Timeberlake posted:

I guess this is a .NET question? If not, let me know.

I have a .netCore AWS Lambda project and I was wondering if there's a way to have different deployment config files (like in ASP.NET, web.debug.config, web.release.config) so I can deploy to different Lambda apps? Like have the following files:

aws-lambda-tools-defaults.development.json => deploy to dev
aws-lambda-tools-defaults.staging.json => deploy to staging
aws-lambda-tools-defaults.production.json => deploy to production

or using the serverless.template file? I can't quite seem to find the documentation I need for this.

dotnet lambda deploy-function -C staging

Replacing staging with whatever configs (staging, production, development) you've defined.

Just-In-Timeberlake
Aug 18, 2003

adaz posted:

dotnet lambda deploy-function -C staging

Replacing staging with whatever configs (staging, production, development) you've defined.

exactly what I was looking for, thanks

Ola
Jul 19, 2004

Hammerite posted:

If you haven't updated to Visual Studio version 16.7.5 yet, don't; it's super unstable.

I've F#ed in it all day without problems. Think Resharper is the only big extension I have, perhaps another one is causing problems.

Hammerite
Mar 9, 2007

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

Ola posted:

I've F#ed in it all day without problems. Think Resharper is the only big extension I have, perhaps another one is causing problems.

To my knowledge I don't have any extensions installed.

I only updated today, but it crashed several times in a row, which doesn't give a good impression. It's been okay the last little while though.

Toast Museum
Dec 3, 2005

30% Iron Chef
Any advice for consuming an API that returns data in kind of unhelpful formats?

To give a sense of where I'm at, I'm pretty capable with PowerShell and have been intermittently learning C#. In the spirit of learning by doing, I'm trying to make a compiled PowerShell module to interact with the API of a product I use at work. Unfortunately, it's not a friendly REST API that spits out JSON, but rather an XML-RPC API that mostly returns strings.

Take these two methods related to dealing with users:
code:
[XmlRpcMethod("api.getUserProperties")]
string[] GetUserProperties(string username, string[] propertyNames);

[XmlRpcMethod("api.setUserProperties")]
void SetUserProperties(string username, string[][] propertyNamesAndValues);
To make representing users with a C# class a little less convenient, some of the API's property names aren't valid as C# property names (and are kebab-case besides). So far, my approach has been to have a SortedList<string,string> in which the key-value pairs are the property names I'm using and the property names the API uses, and using that to parse the array that the API returns:

code:
string[] apiResponse = GetUserProperties(username, PropertyMappings.UserGettableFields.Values.ToArray());

foreach (var key in PropertyMappings.UserGettableFields.Keys)
{
    int index = PropertyMappings.UserGettableFields.IndexOfKey(key);
    string value = apiResponse[index];
    typeof(User).GetField(key).SetValue(this, value);
}
I feel like there's got to be a better way to deal with situations like this, but my searches so far have mostly turned up results that assume a more accommodating API. So, is there a more useful approach I should be taking?

insta
Jan 28, 2009
Just checking, the API isn't WCF, is it? If so, you can generate client-side code with a single command that does *alllll* that crap for you.

Social Animal
Nov 1, 2005

I'm so stumped. I've got an Azure Function that makes a connection to a cosmos database/container successfully. When I run through what seems to be a standard pattern of running a query against the container I get nothing. I typed up an example below of what I'm trying to do. iterator.HasMoreResults starts true but my breakpoint in the foreach never hits. The list is also empty on return.

code:
public async Task<IEnumerable<ObjectModel> GetObjects()
{
  var query = new QueryDefinition("SELECT TOP 10 * FROM c");

  var iterator = container.GetItemQueryIterator<ObjectModel>(query);

  var list = new List<ObjectModel>();

  while (iterator.HasMoreResults)
  {
  	foreach(var i in await iterator.ReadNextAsync())
  	{
  		list.Add(i)
  	}
  }

 return list;
}
I've tried leaving the foreach out of it and seeing what something like
code:
var test = await iterator.ReadNextAsync();
brings me on a single line but the count is 0, no results. Of course executing that query in cosmos explorer brings me results. There's got to be something super simple I'm missing here right?

NihilCredo
Jun 6, 2011

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

Hammerite posted:

If you haven't updated to Visual Studio version 16.7.5 yet, don't; it's super unstable.

Water status: wet?

Jokes aside, the release notes for this patch seem to only interest C++ coding, are you doing that?

Hammerite
Mar 9, 2007

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

NihilCredo posted:

Water status: wet?

Jokes aside, the release notes for this patch seem to only interest C++ coding, are you doing that?

are you asking me specifically, or posing a question to a hypothetical reader who might upgrade?

I touch C++ occasionally on our legacy apps but mostly do C#, to answer your question. I don't read the release notes for updates, I just let VS update when it tells me there's an update. Usually I don't regret doing that.

Alan G
Dec 27, 2003

Hammerite posted:

are you asking me specifically, or posing a question to a hypothetical reader who might upgrade?

I touch C++ occasionally on our legacy apps but mostly do C#, to answer your question. I don't read the release notes for updates, I just let VS update when it tells me there's an update. Usually I don't regret doing that.

Same, had a bunch of white screens of death just from interacting with c# projects. A great boost of confidence before they completely change how the .net ecosystem works in less than 2 months.

Toast Museum
Dec 3, 2005

30% Iron Chef

insta posted:

Just checking, the API isn't WCF, is it? If so, you can generate client-side code with a single command that does *alllll* that crap for you.

'Fraid not. I did run into some of the documentation on WCF data contracts during my initial searches, which is part of what gave me some hope that there was a better way to ingest from the API.

brap
Aug 23, 2004

Grimey Drawer

Alan G posted:

Same, had a bunch of white screens of death just from interacting with c# projects. A great boost of confidence before they completely change how the .net ecosystem works in less than 2 months.

What does white screen of death mean here? Is VS failing so badly it’s bringing down your whole system?

biznatchio
Mar 31, 2001


Buglord

brap posted:

What does white screen of death mean here? Is VS failing so badly it’s bringing down your whole system?

When a WPF application like Visual Studio has a rendering hang, it leaves the application's window unpainted, which is usually white.

adaz
Mar 7, 2009

Social Animal posted:

I'm so stumped. I've got an Azure Function that makes a connection to a cosmos database/container successfully. When I run through what seems to be a standard pattern of running a query against the container I get nothing. I typed up an example below of what I'm trying to do. iterator.HasMoreResults starts true but my breakpoint in the foreach never hits. The list is also empty on return.

code:
public async Task<IEnumerable<ObjectModel> GetObjects()
{
  var query = new QueryDefinition("SELECT TOP 10 * FROM c");

  var iterator = container.GetItemQueryIterator<ObjectModel>(query);

  var list = new List<ObjectModel>();

  while (iterator.HasMoreResults)
  {
  	foreach(var i in await iterator.ReadNextAsync())
  	{
  		list.Add(i)
  	}
  }

 return list;
}
I've tried leaving the foreach out of it and seeing what something like
code:
var test = await iterator.ReadNextAsync();
brings me on a single line but the count is 0, no results. Of course executing that query in cosmos explorer brings me results. There's got to be something super simple I'm missing here right?

Are you setting the partition somewhere else? That's the only thing I can think of off the top of my head, is you are - in code -just querying the wrong partition/db compared to your cosmos explorer

Social Animal
Nov 1, 2005

adaz posted:

Are you setting the partition somewhere else? That's the only thing I can think of off the top of my head, is you are - in code -just querying the wrong partition/db compared to your cosmos explorer

Haha that was it! Thanks it was a similarly named db damnit that’s frustrating but what a relief. Thank you!

adaz
Mar 7, 2009

Social Animal posted:

Haha that was it! Thanks it was a similarly named db damnit that’s frustrating but what a relief. Thank you!

scars from doing this a thousand times and realizing that i was pointing to wrong table/db/environment.

You might want to consider instrumenting your connections and having it log all queries + what db it's querying. AT least for lower environments and troubleshooting it rules. How to do so depends on what framework/orm you are using but isnt usually SUPER rough!

mystes
May 31, 2006

Ola posted:

I've F#ed in it all day without problems. Think Resharper is the only big extension I have, perhaps another one is causing problems.
They probably just haven't gotten around to adding f# support to the new bugs yet.

Social Animal
Nov 1, 2005

adaz posted:

scars from doing this a thousand times and realizing that i was pointing to wrong table/db/environment.

You might want to consider instrumenting your connections and having it log all queries + what db it's querying. AT least for lower environments and troubleshooting it rules. How to do so depends on what framework/orm you are using but isnt usually SUPER rough!

I’ll look into this. It’s not common for me to make new cosmos connections like this and honestly I think it’ll be on my mind next time I do.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
I'm just going to make a quick post to plug my project.log thread about writing a static web app in Blazor. I thought it might be of interest to some readers of the .NET thread.

mystes
May 31, 2006

Hammerite posted:

I'm just going to make a quick post to plug my project.log thread about writing a static web app in Blazor. I thought it might be of interest to some readers of the .NET thread.
I realize that the point is just to demonstrate a static web app in Blazor, but neither this post, the project.log thread, the github page, or the actual site give even the slightest indication of what the blessed thing actually does, which seems like some sort of new record.

Mr Shiny Pants
Nov 12, 2012

mystes posted:

They probably just haven't gotten around to adding f# support to the new bugs yet.

That's harsh.... but probably true :(

Hammerite
Mar 9, 2007

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

mystes posted:

I realize that the point is just to demonstrate a static web app in Blazor, but neither this post, the project.log thread, the github page, or the actual site give even the slightest indication of what the blessed thing actually does, which seems like some sort of new record.

Sorry, I figured no one would care about that if they were just looking at it from a technical perspective. It is helping out with the game mechanic described on this page, but an executive summary would be: it is some video game bullshit.

Riot Bimbo
Dec 28, 2006


At some point in September, my brain finally clicked into place and began building new routines to replace covid-destroyed ones.

One of my partners has a background in self-taught coding, and informed me that visual studio had a good free edition these days, and then I blasted through the intro to c# course on codecademy.

Right now, I'm trying to figure out what my next step is. I am more or less self directed right now. Learning how to do stuff that wasn't covered, or covered well, by the course i've taken. The followup offering on codecademy, is about c# and ASP, and while it seems like a loving cool next step, their teaching environment has a hideously low user cap for the ASP stuff, and tbh the answer checker is busted as gently caress, so I gave up.

I have an ancient java-based comp-sci course in my past; in my noggin, that probably made getting back to this point *far* easier and faster than it is for most starting blind, but yeah... I've got a "C# masterclass" course my partner picked up, where a guy awkwardly puts code on the screen without explaining anything. That's useful as a jumping off point, and I've found some stuff on Skillshare that's similarly useful for short-topic dives.

Insofar as I actually know what I want, I think I'm looking for, I think I'd like to find some solid resources on LINQ+C# operations, because that's what my course finished on, but did frustratingly little with.

I'd also just generally like resources that might firm up a foundation I can turn into a career. I want to also make like, 2D games as a hobby, and anything in that direction is fine, but I'm principally trying to get skills to escape the culinary industry, as I've been made aware that I could just... do that.

Riot Bimbo fucked around with this message at 11:29 on Oct 13, 2020

Ola
Jul 19, 2004

Riot Bimbo posted:

At some point in September, my brain finally clicked into place and began building new routines to replace covid-destroyed ones.

One of my partners has a background in self-taught coding, and informed me that visual studio had a good free edition these days, and then I blasted through the intro to c# course on codecademy.

Right now, I'm trying to figure out what my next step is. I am more or less self directed right now. Learning how to do stuff that wasn't covered, or covered well, by the course i've taken. The followup offering on codecademy, is about c# and ASP, and while it seems like a loving cool next step, their teaching environment has a hideously low user cap for the ASP stuff, and tbh the answer checker is busted as gently caress, so I gave up.

I have an ancient java-based comp-sci course in my past; in my noggin, that probably made getting back to this point *far* easier and faster than it is for most starting blind, but yeah... I've got a "C# masterclass" course my partner picked up, where a guy awkwardly puts code on the screen without explaining anything. That's useful as a jumping off point, and I've found some stuff on Skillshare that's similarly useful for short-topic dives.

Insofar as I actually know what I want, I think I'm looking for, I think I'd like to find some solid resources on LINQ+C# operations, because that's what my course finished on, but did frustratingly little with.

I'd also just generally like resources that might firm up a foundation I can turn into a career. I want to also make like, 2D games as a hobby, and anything in that direction is fine, but I'm principally trying to get skills to escape the culinary industry, as I've been made aware that I could just... do that.

Write a web API in C#, then write a front end to interact with it in React. That's a safe career path these days. You can run everything locally so no need to spend on cloud stuff, but if you move it to the cloud then you'll get some nice bonus skills. I don't know about any particular tutorials other than the top obvious search results, such as this: https://dotnet.microsoft.com/apps/aspnet/apis There are probably many other ones, perhaps someone else has a good suggestion.

Before you get the front end running you can use a client like Postman to call the API https://www.postman.com/. You'll basically want to implement a fake database in C#, which is just the typical beginner stuff like write a list of your favorite fruits and filter it for green ones etc. Then you'll write an API that takes web requests such as GET http://yourserverhere/fruits/favorites/green, looks up to relevant data in the fake database, then returns it to the client in some serialized form such as JSON, and hopefully written in such a way that it's easy to swap which database you connect to and how you serialize it. If you don't know some or all of this terminology, you'll learn it during or after the tutorial. :)

Just-In-Timeberlake
Aug 18, 2003

Riot Bimbo posted:

At some point in September, my brain finally clicked into place and began building new routines to replace covid-destroyed ones.

One of my partners has a background in self-taught coding, and informed me that visual studio had a good free edition these days, and then I blasted through the intro to c# course on codecademy.

Right now, I'm trying to figure out what my next step is. I am more or less self directed right now. Learning how to do stuff that wasn't covered, or covered well, by the course i've taken. The followup offering on codecademy, is about c# and ASP, and while it seems like a loving cool next step, their teaching environment has a hideously low user cap for the ASP stuff, and tbh the answer checker is busted as gently caress, so I gave up.

I have an ancient java-based comp-sci course in my past; in my noggin, that probably made getting back to this point *far* easier and faster than it is for most starting blind, but yeah... I've got a "C# masterclass" course my partner picked up, where a guy awkwardly puts code on the screen without explaining anything. That's useful as a jumping off point, and I've found some stuff on Skillshare that's similarly useful for short-topic dives.

Insofar as I actually know what I want, I think I'm looking for, I think I'd like to find some solid resources on LINQ+C# operations, because that's what my course finished on, but did frustratingly little with.

I'd also just generally like resources that might firm up a foundation I can turn into a career. I want to also make like, 2D games as a hobby, and anything in that direction is fine, but I'm principally trying to get skills to escape the culinary industry, as I've been made aware that I could just... do that.

To add to the previous answer, check out this blog post with links to a git repo

https://medium.com/@michaeldimoudis...er-6d31cdd6d3f5

The git repo code will handle all the grunt work to spin up a serverless AWS Lambda/CloudFormation stack with a CloudWatch lambda warmer to keep the functions from going dormant.

You get something like 1M lambda function calls/month so it won’t cost anything. Spin up a cheap/free RDS instance and you can work on your database integration.

AWS Lambda makes API development a cinch.

Riot Bimbo
Dec 28, 2006


Just-In-Timeberlake posted:

To add to the previous answer, check out this blog post with links to a git repo

https://medium.com/@michaeldimoudis...er-6d31cdd6d3f5

The git repo code will handle all the grunt work to spin up a serverless AWS Lambda/CloudFormation stack with a CloudWatch lambda warmer to keep the functions from going dormant.

You get something like 1M lambda function calls/month so it won’t cost anything. Spin up a cheap/free RDS instance and you can work on your database integration.

AWS Lambda makes API development a cinch.

I feel like a doofus but I am not at a point where this blog post provides enough info to get this running properly right off the bat. I think I'll go a little meta and endeavor to learn how to understand what the hell I'm doing here. That's the best I can do, since this is kind of the direction I wanna go.

Just-In-Timeberlake
Aug 18, 2003

Riot Bimbo posted:

I feel like a doofus but I am not at a point where this blog post provides enough info to get this running properly right off the bat. I think I'll go a little meta and endeavor to learn how to understand what the hell I'm doing here. That's the best I can do, since this is kind of the direction I wanna go.

You can download the code and just run it locally with no extra configuration and use Postman to test your code.

When you want to get to the point of spinning up a serverless stack on AWS you can mess around with the config files (it’s actually not as hard as it seems)

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I have a feeling I'm going to be posting about XAML stuff for awhile since I'm toying with NoesisGUI inside Unity 3d. I figured it's more XAML than Unity 3d so I figured I'd post here instead.

I'd like to add custom tags into some text to insert icons. In this case, the tags are for player actions from the controller and the icons would be the keys/buttons/whatever currently bound to the action. So I want to have something like "[icon(s) for MainMenu][icons(s) for Abort] Return To Game." I can put some controller code on top of everything to parse the text myself and do the insertions in a rather ham-fisted way, but I am thinking that XAML and WPF has something cooler for this kind of thing. The other reason to look for better is that I'm hoping there's some indirection I can use to help change those icons if they get dynamically remapped. Is there anything better?

I can worry about if cool stuff actually works with NoesisGUI or not myself.

Riot Bimbo
Dec 28, 2006


Just-In-Timeberlake posted:

You can download the code and just run it locally with no extra configuration and use Postman to test your code.

When you want to get to the point of spinning up a serverless stack on AWS you can mess around with the config files (it’s actually not as hard as it seems)

if that's the case, neat!

chglcu
May 17, 2007

I'm so bored with the USA.

Rocko Bonaparte posted:

I have a feeling I'm going to be posting about XAML stuff for awhile since I'm toying with NoesisGUI inside Unity 3d. I figured it's more XAML than Unity 3d so I figured I'd post here instead.

I'd like to add custom tags into some text to insert icons. In this case, the tags are for player actions from the controller and the icons would be the keys/buttons/whatever currently bound to the action. So I want to have something like "[icon(s) for MainMenu][icons(s) for Abort] Return To Game." I can put some controller code on top of everything to parse the text myself and do the insertions in a rather ham-fisted way, but I am thinking that XAML and WPF has something cooler for this kind of thing. The other reason to look for better is that I'm hoping there's some indirection I can use to help change those icons if they get dynamically remapped. Is there anything better?

I can worry about if cool stuff actually works with NoesisGUI or not myself.

It's been years since I've done XAML/WPF stuff, but it seems like it would be pretty simple to implement a data converter that handles that. You'd still have to implement the parsing, but it would be called automatically for any binding that used that converter.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

chglcu posted:

...implement a data converter...

Is "value converter" the magic phrase? I got a bunch from that and wanted to confirm before I crawl down that rabbit hole.

epswing
Nov 4, 2003

Soiled Meat

Rocko Bonaparte posted:

Is "value converter" the magic phrase? I got a bunch from that and wanted to confirm before I crawl down that rabbit hole.

Yeah, implement IValueConverter, which means specifying how to Convert and then ConvertBack the data referred to by your binding.

Here's an example that converts strings to bools and back.

MadFriarAvelyn
Sep 25, 2007

So I'm starting to work with publishing nuget packages with .Net core, and a big thing I've been working with is making sure a proper set of StyleCop rules that are published by a nuget package for use in the different packages to ensure a consistent style consistency without forcing them to be required by any package that pulls them down. Is there a way to configure a nuget package to force a package to reference a library with PrivateAssets set to all by default to make them easier to pull down without modifying the .csproj file?

MadFriarAvelyn fucked around with this message at 01:07 on Oct 16, 2020

Adbot
ADBOT LOVES YOU

chglcu
May 17, 2007

I'm so bored with the USA.

Rocko Bonaparte posted:

Is "value converter" the magic phrase? I got a bunch from that and wanted to confirm before I crawl down that rabbit hole.

Yeah, sorry that's what I meant. Like I said, it’s been a while.

chglcu fucked around with this message at 01:24 on Oct 16, 2020

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