|
New Yorp New Yorp posted:Yeah and I'm going to be adding on another layer, with this running in an App Service where those values can be overridden at the slot level. Unless you have some specific needs, I would keep the App Service settings overrides limited. I would, and have, generally only used the App Service settings for security-related items that I don't want checked into source. I also typically put the setting in the environment's config with a bogus value like "EncryptionKey": "This value is set by AppService settings" to keep it clear.
|
# ? Mar 14, 2018 17:20 |
|
|
# ? Jun 8, 2024 06:39 |
|
B-Nasty posted:Unless you have some specific needs, I would keep the App Service settings overrides limited. I would, and have, generally only used the App Service settings for security-related items that I don't want checked into source. I also typically put the setting in the environment's config with a bogus value like "EncryptionKey": "This value is set by AppService settings" to keep it clear. Yeah, I always push for configuration as code as much as possible. The connection string is going to be derived from whatever is provisioned during the ARM template deployment. I actually don't think there are a lot of app settings other than that.
|
# ? Mar 14, 2018 17:34 |
|
Munkeymon posted:My educated guess is that that property isn't backed by a managed string, one is only provided when you access it, and they probably want people to use the Secure property you mentioned but the old one is kept around to avoid a breaking API change. Yes but, the goddamned property isn't bindable a hot gujju bhabhi posted:We use this at my current (soon to be previous) job and I'm not a fan. I can't describe exactly my issues with it, but it just feels clunky to use. NLog was much nicer in my opinion. In the end I went with NLog, it was really easy to set up. Only, is the console target really as slow as it feels? I had to make it asynchronous, because it was making my app lag, but now the output window takes a very long time to catch up with some of the larger bursts of log lines, on the order of several seconds The quick and dirty native logger I had hacked up before switching to NLog was, like, a good order of magnitude faster. I wonder if I'm doing something wrong or if I should just live with it
|
# ? Mar 14, 2018 22:41 |
|
hackbunny posted:is the console target really as slow as it feels? no, but the console itself is terrible. redirect to a file and you'll see a significant performance increase out of the console logger. or shrink your console to one line tall.
|
# ? Mar 14, 2018 23:07 |
|
hackbunny posted:The quick and dirty native logger I had hacked up before switching to NLog was, like, a good order of magnitude faster. I wonder if I'm doing something wrong or if I should just live with it Not sure if this also applies to the console, but IIRC NLog uses some buffering/flushing mechanism to not block your program, so maybe it just flushes less often than e.g. a real-time console logger.
|
# ? Mar 15, 2018 10:55 |
|
amotea posted:Not sure if this also applies to the console, but IIRC NLog uses some buffering/flushing mechanism to not block your program, so maybe it just flushes less often than e.g. a real-time console logger. Only if you wrap your targets in an async wrapper. Otherwise it's unbuffered blocking writes.
|
# ? Mar 15, 2018 11:10 |
|
Night Shade posted:Only if you wrap your targets in an async wrapper. Otherwise it's unbuffered blocking writes. I did, because the blocking writes were making my app unusable (many log lines come from realtime threads doing audio - I know it sounds crazy but it's never been an issue on iPhone or Android builds of the same code). But is there any buffering other than the async wrapper's queue?
|
# ? Mar 15, 2018 11:29 |
|
hackbunny posted:I did, because the blocking writes were making my app unusable (many log lines come from realtime threads doing audio - I know it sounds crazy but it's never been an issue on iPhone or Android builds of the same code). But is there any buffering other than the async wrapper's queue? Unless it got added while I wasn't watching, no. Without an async wrapper you should be able to follow the call stack all the way from the call to Logger to Console.WriteLine.
|
# ? Mar 15, 2018 11:45 |
|
Are there any tools which will diagram the relationships between classes, interfaces, etc in a WPF project / solution? For example, all of my POCO objects derive from NotifyBase (which itself implements INotifyPropertyChanged) and implement IEquatable<T>. And as another example, in one project the Firewall object contains collections of nats, identity nats, version 9 nats, interfaces, rules, named objects, routes, rules, object groups, etc. I’d love to see a graphic representation of all the interdependencies.
|
# ? Mar 17, 2018 04:43 |
|
LongSack posted:Are there any tools which will diagram the relationships between classes, interfaces, etc in a WPF project / solution? For example, all of my POCO objects derive from NotifyBase (which itself implements INotifyPropertyChanged) and implement IEquatable<T>. And as another example, in one project the Firewall object contains collections of nats, identity nats, version 9 nats, interfaces, rules, named objects, routes, rules, object groups, etc. I’d love to see a graphic representation of all the interdependencies. Isn't this built into VS?
|
# ? Mar 17, 2018 16:40 |
|
downout posted:Isn't this built into VS? VS Enterprise, yeah. There's architecture diagram tools -- I think it's called "Code Map". NDepend also does it.
|
# ? Mar 17, 2018 17:14 |
|
New Yorp New Yorp posted:VS Enterprise, yeah. There's architecture diagram tools -- I think it's called "Code Map". NDepend also does it. Sadly, neither of these things are free
|
# ? Mar 18, 2018 00:25 |
|
LongSack posted:Sadly, neither of these things are free google free c# class diagram tool - it looks like there are a few options that might work
|
# ? Mar 18, 2018 02:10 |
|
downout posted:google free c# class diagram tool - it looks like there are a few options that might work Thanks! Am still thinking of rolling my own as an exercise, but will definitely take a look.
|
# ? Mar 18, 2018 03:00 |
|
The name of HashSet<T>.ExceptWith borders on "Until" levels of confusion for me, because I think it is union at first.
|
# ? Mar 18, 2018 17:27 |
|
Just hopping in to say JB Rider (on a mac) is loving awesome but it doesn't respect your launchSettings.json port, so you have to make a profile for each service if your are doing microservice bs. Other than that, it's freaking great.
|
# ? Mar 26, 2018 02:35 |
|
I've been completely unable to find the answer to this: does await work with foreach? e.g. C# code:
Or would I need to make a list of Tasks and add to it in the foreach, and then await Task.WhenAll() after the foreach is done? All I can find is people trying to make linq's .ForEach() method work, or people wanting parallel foreachs...
|
# ? Mar 27, 2018 12:52 |
|
Yes, await works perfectly normally in a foreach. No, a foreach does not run in parallel unless you make it run in parallel. Yes, to execute multiple Tasks in parallel, you can collect them into a list and WhenAll() them later.
|
# ? Mar 27, 2018 13:00 |
|
Edit, never mind
Sab669 fucked around with this message at 18:55 on Mar 30, 2018 |
# ? Mar 30, 2018 18:52 |
|
Is there a way to change the font family for menu items in a context menu? The MenuItem class has a FontFamily property (inherited from Control) but appears to ignore it. I'm using a context menu to allow the user to select a different font / font size if they are having trouble reading with the defaults. The context menu offers a couple standard options (Arial, Times New Roman, Calibri, Comic Sans for a chuckle) and a final option which will allow them to choose from a dialog box. The idea is to have the menuitem font match the font being selected, but it's not working. I've tried setting the FontFamily directly on the MenuItem itself, and also using a TextBlock in an ItemTemplate like: code:
Any ideas?
|
# ? Mar 30, 2018 21:08 |
|
I vaguely remember font settings being special somehow but I forget how. Try looking up the visual tree in XAML Spy or whatever the modern variant of that tool is and fiddling with the properties until the hidden relation shows up. This is a memory from Silverlight/WPF days, though, so if you are doing UWP perhaps it no longer applies.
|
# ? Apr 1, 2018 18:15 |
|
EssOEss posted:I vaguely remember font settings being special somehow but I forget how. Try looking up the visual tree in XAML Spy or whatever the modern variant of that tool is and fiddling with the properties until the hidden relation shows up. Nope, just using WPF on windows. The MS docs just say that the MenuItem FontFamily property is inherited from Control, but don’t indicate that it’s ignored. I’ve tried straight up binding, ItemTemplates and even ItemContainerStyle (or whatever it’s called) without success. Probably going to give up on it, not worth wasting a ton of time on, but wondered if anyone else had come across it. I think my next feature will be a whiteboard with the ability to drop characters, locations, incidents, etc on the board and draw arrows connecting them with annotations. I’ve got some example code that is not MVVM, so it will be interesting to try to change the paradigm as well as giving me the change to try out some more extensive styling. Not sure if you can bind the Children of a Canvas, so it should be a challenge.
|
# ? Apr 2, 2018 01:05 |
|
LongSack posted:
Try just settting FontFamily on the MenuItem itself. This works for me code:
|
# ? Apr 2, 2018 21:31 |
|
How long do y'all think MVC/Web API Controller Action methods should be? I try to keep mine down to like 10 lines tops, at leas when I'm creating new stuff. But one that I'm maintaining is 260 lines long. The method does quite a few different things underlying the surface of 'edit this busiess entity', including sending the entity to two different third party services and gobs of validation code. Is that 'fine', 'bad', or 'ludicrous' ?
|
# ? Apr 2, 2018 22:01 |
|
Careful Drums posted:How long do y'all think MVC/Web API Controller Action methods should be? I try to keep mine down to like 10 lines tops, at leas when I'm creating new stuff. But one that I'm maintaining is 260 lines long. The method does quite a few different things underlying the surface of 'edit this busiess entity', including sending the entity to two different third party services and gobs of validation code. Is that 'fine', 'bad', or 'ludicrous' ? I tend to always keep the Action methods very tiny, and defer actual logic to a separate business logic layer (web api, dll or even just another class). The only time I cram everything into the Action method is if I'm writing something I know is going to be once-off. Aside from the obvious maintainability etc, it also makes it a lot easier to create a separate app for the product if the web UI is just presentation and all actual processing happens elsewhere.
|
# ? Apr 2, 2018 22:51 |
|
fankey posted:Try just settting FontFamily on the MenuItem itself. This works for me That’s the first thing I tried. In the code I posted above, the menuitem for Calibri does just that. Doesn’t seem to work.
|
# ? Apr 3, 2018 00:02 |
|
The only thing my controller action methods do is just translate input/output from the controller's API contract to my internal business logic objects. If those 260 lines are data transformation, it is fine. But it sounds like you actually have the business logic in there, which I would not look kindly upon.
|
# ? Apr 3, 2018 07:04 |
|
Same, my controller methods are pretty much only for producing the correct HTTP return codes and messages. Example (F#):code:
|
# ? Apr 3, 2018 14:14 |
|
thanks everyone, glad to hear i'm not crazy. on to the challenge of refactoring it without breaking anything
|
# ? Apr 3, 2018 14:49 |
|
Hey I have another question, in the form of "fine, bad, or terrible" A method has a try/catch embedded inside another try/catch. Is that "fine", "bad", or "terrible"? It seems pretty terrible to me.
|
# ? Apr 6, 2018 21:18 |
|
Feels terrible offhand, why not just have a second catch clause on the outer try? I guess technically try/catch within a try/catch is exactly what's happening all the time anyway, just usually there's a method call in between
|
# ? Apr 6, 2018 21:33 |
|
Depends, you might want to handle some errors differently. I've used it to make a budget TryFoo variant when one is missing. I'd say code smell not horror...
|
# ? Apr 6, 2018 21:35 |
|
I guess the only thing I can think of is something like this:C# code:
|
# ? Apr 6, 2018 21:40 |
|
It is perfectly fine if the inner catch needs to operate over a smaller scope of code. If the only thing inside the outer try is the inner try-catch then it is a bit more fishy, though. Might still simplify some inconvenient patterns. All in all, post code for exact judgement!
|
# ? Apr 6, 2018 21:56 |
|
Ciaphas posted:I guess the only thing I can think of is something like this: Wouldn't something like this work to avoid a nested try/catch? C# code:
|
# ? Apr 6, 2018 22:14 |
|
Potassium Problems posted:Wouldn't something like this work to avoid a nested try/catch? the difference is that your example sort of implies (without reading comments because who reads those) that UnsafeStuff could throw a WowYouFuckedUpException which you might not want to handle right there (though I suppose you could rethrow in the corresponding catch block in that case)
|
# ? Apr 6, 2018 22:24 |
|
Sometimes you want to convert an exception into a different type.code:
|
# ? Apr 6, 2018 22:26 |
|
EssOEss posted:It is perfectly fine if the inner catch needs to operate over a smaller scope of code. If the only thing inside the outer try is the inner try-catch then it is a bit more fishy, though. Might still simplify some inconvenient patterns. Thanks for opinions. Its work code so to post it I'd have to anonymize it a bit but it's in an interesting grey area. It does fit the form of "doing unsafe stuff" inside an otherwise safe-ish method.
|
# ? Apr 7, 2018 20:25 |
|
Wondering if there is a better way to handle this. One program I’m working on has an Account object. It had an AccountType, a Number, Due Date Type (monthly, quarterly, annually, etc), month and day. The account number is stored encrypted and converted to base64, and is displayed using the account type and the last 4 digits of the number - a VISA card would be displayed as “Credit Card 0000”. The account number and due date fields on the screen are bound to the account object, with value converters. Problem: if the account is edited to change the due date, the change is not reflected on the screen because the Account object has not changed. I should note that the Account object has an Id field which is an identity key in the database, and the equality methods check only the Id fields - two Accounts are equal if their Id fields are equal. I’ve worked around it by changing the bindings for the account number and due date to MultiBindings bound to each of the individual fields with a multiconverter to match, and it works fine, but I wonder if there is a more elegant way to handle it. I thought about changing my equality methods to actually compare all the fields rather than just the Id, but that would have side effects that I’d rather not deal with.
|
# ? Apr 9, 2018 01:31 |
|
|
# ? Jun 8, 2024 06:39 |
|
So I've been working on a simple text RPG to help me learn C#, and I'm just wondering if this code looks okay. So far everything in the menus works (the options to fight a monster only appear once a character has been created save for the boss fight which I haven't fully implemented yet). My main issue is being confused as to whether or not I'm doing OOP right. Is it a good idea to have the player class be static like I have? My rationale is that there's only one player (although I imagine this could change if you wanted to create a new character). Moreover, I'm a bit confused about inheritance. I imagine that the boss class should inherit the enemy class (bosses are enemies and have both HP and a name), but then the boss class should override the enemy HP variable and be set to a different (higher) value. Finally, is the general logic right? I'm wondering if I should be having more functions return a result rather than things like Console.Writeline (to decouple methods from formatting)m, but if thats the case, where would the methods be returning to?
|
# ? Apr 9, 2018 04:23 |