|
Funking Giblet posted:Figure out a different way to Populate your observable, and maybe, try not using an EF entity, but a DTO of some sort. I’ve finally come to an understanding as to why you recommended this. Since the contexts are disposed, my data bindings are throwing a shitton of exceptions now. The only fix is to load my observable with classes with a bunch of added .Include() which loads way more memory than needs to be loaded. So by adding DT objects as an added layer of abstraction, I can avoid attempts to hit the database with a disposed context. I think I will replace my character selection combo box of ObservableCollection<Character> with a List<int> or ObservableCollection<int> of character ids and when SelectedCharacterId changes, load up a new Character DTO from the new id. I think. I don’t think this added abstraction is needed for every entity, but on those with navigation properties, it’ll probably save me some headache. Of course, abandoning EF and going back to my ADO data access layer classes would do the same. There is a lot of counter-intuitive stuff happening in EF, like getting an exception about not being able to create a relationship to an entity in deleted state when deleting. Why is it trying to create anything when I am deleting an item? I’m trying to learn, but man this kind of stuff is making it frustrating.
|
# ? Jan 15, 2018 04:57 |
|
|
# ? Jun 7, 2024 16:37 |
|
Hello everyone! I'm not entirely sure that this is the right place to post this but it's the closest I could find, so here goes. I'm working on an interview presentation and for part of it I want to create a powerpoint slide that does a rudimentary text check for proper MLA or APA (haven't decided yet) citation in a string. Essentially, you would type in a sentence and then click a button and it would point to the problem area and explain what is incorrect, or alternatively to give an affirmative message if everything is in line. I don't know about coding, so I'm hoping the fine goons here can point me in the direction of either sources that I can use to puzzle this out, or if not, possibly in the direction of something that I might be able to reverse-engineer into what I want. Any help would be greatly appreciated!
|
# ? Jan 16, 2018 20:38 |
|
For want of a proper Windows thread, I'll ask here: how would you write a UI for a Windows desktop application? My coworker wants to use Windows Forms but hasn't it been obsolete for a long time? Not that I know much about UI development on Windows...
|
# ? Jan 17, 2018 09:49 |
|
hackbunny posted:For want of a proper Windows thread, I'll ask here: how would you write a UI for a Windows desktop application? My coworker wants to use Windows Forms but hasn't it been obsolete for a long time? Not that I know much about UI development on Windows... Windows forms isn't going anywhere, but if I were learning from scratch WPF is weapon of choice now.
|
# ? Jan 17, 2018 14:21 |
|
What sort of app and who is the target audience in terms of users? WinForms is perfect for quick-and-dirty technical GUIs. WPF is the most powerful option but not very loved by Microsoft. UWP is the "modern mobile UI kit" that gets all the attention these days.
|
# ? Jan 17, 2018 16:02 |
|
yeah i just started building my first large app in WPF and its super annoying if youre used to winforms but once you get the hang of it things start to come together really nicely bindings and XAML reduce the amount of UI code by absolutely obscene amounts. there's a lot of annoying boilerplate code though what im struggling with now is figuring out how the hell to get my ViewModel to do something and then report the status of that action. from what i can tell the "offical MVVM" way is to have the View subscribe to an Interaction Service in the ViewModel and then issue a command to the ViewModel. the ViewModel executes the command and then pushes a message to the Interaction Service which the View receives and then performs an action this is ludicrous if you want an "OK" button that saves some data and pops up an error message if something doesnt work 30 TO 50 FERAL HOG fucked around with this message at 16:06 on Jan 17, 2018 |
# ? Jan 17, 2018 16:03 |
|
NEED MORE MILK posted:yeah i just started building my first large app in WPF and its super annoying if youre used to winforms but once you get the hang of it things start to come together really nicely You create a status label that is two way binded to your outcome. So in your GUI you have something like a status field and you save the outcome to the field its binded to in your viewmodel and the Gui will show the outcome if it is necessary. At least, that is what I would do.
|
# ? Jan 17, 2018 16:17 |
|
Mr Shiny Pants posted:You create a status label that is two way binded to your outcome. So in your GUI you have something like a status field and you save the outcome to the field its binded to in your viewmodel and the Gui will show the outcome if it is necessary. This is a dialog though, so when I hit "OK" I want to set DialogResult = true to close the dialog if the command is successful and pop up a MessageBox if it fails
|
# ? Jan 17, 2018 16:21 |
|
NEED MORE MILK posted:This is a dialog though, so when I hit "OK" I want to set DialogResult = true to close the dialog if the command is successful and pop up a MessageBox if it fails Ah, well that is a bit different, what I've seen is that you "fake" a dialog. You create a new XAML form that acts as a dialog and have a viewmodel that hides behind this form in which you update the state of the operation. Dialogs in WPF are pain in the rear end, I think it wasn't even possible to have them in the older versions, but I could be misremembering.
|
# ? Jan 17, 2018 16:25 |
|
Roid666 posted:Windows forms isn't going anywhere, but if I were learning from scratch WPF is weapon of choice now. "Not going anywhere" in the sense that they won't get any significant updates, or in the sense that they won't be dropped any soon? EssOEss posted:What sort of app and who is the target audience in terms of users? General users - it's a communication application (voice chat & text messaging) EssOEss posted:WPF is the most powerful option but not very loved by Microsoft. UWP is the "modern mobile UI kit" that gets all the attention these days. I was afraid you'd say that! I'd rather go with a desktop application unless there are very, very good reasons not to. Microsoft mobile platforms are not on our radar right now and they don't look like they'll ever be
|
# ? Jan 17, 2018 16:35 |
|
hackbunny posted:"Not going anywhere" in the sense that they won't get any significant updates, or in the sense that they won't be dropped any soon? Both quote:I was afraid you'd say that! I'd rather go with a desktop application unless there are very, very good reasons not to. Microsoft mobile platforms are not on our radar right now and they don't look like they'll ever be It's technically ~mobile-friendly~ and a requirement to use the app store IIRC. You know how most of the apps that come with Windows 10 look? That's probably what they're using.
|
# ? Jan 17, 2018 17:10 |
|
Munkeymon posted:It's technically ~mobile-friendly~ and a requirement to use the app store IIRC. For our customers, the app not being on the store might be a plus. Only thing that might be desirable to us about UWP is sandboxing, but (with effort) you can sandbox desktop apps in the same way, as Chrome famously does Munkeymon posted:You know how most of the apps that come with Windows 10 look? That's probably what they're using. Yeah, let's just say I... don't love those. Is the single window UI a hard requirement or just convention?
|
# ? Jan 17, 2018 17:34 |
|
Is there a way in C# to require that a string parameter (or hell numeric ones too) to a function be filled via a literal rather than a variable or other expression that requires evaluation?C# code:
|
# ? Jan 18, 2018 01:58 |
|
Ciaphas posted:Is there a way in C# to require that a string parameter (or hell numeric ones too) to a function be filled via a literal rather than a variable or other expression that requires evaluation? If there is, it would be some deeply weird poo poo involving reflection, but even then I am dubious, because typeof(“foo”) and typeof(string) are almost certainly the same.
|
# ? Jan 18, 2018 05:15 |
|
LongSack posted:If there is, it would be some deeply weird poo poo involving reflection, but even then I am dubious, because typeof(“foo”) and typeof(string) are almost certainly the same. Wonder what nameof does in this scenario
|
# ? Jan 18, 2018 13:28 |
|
hackbunny posted:For want of a proper Windows thread, I'll ask here: how would you write a UI for a Windows desktop application? My coworker wants to use Windows Forms but hasn't it been obsolete for a long time? Not that I know much about UI development on Windows... electron
|
# ? Jan 18, 2018 13:42 |
|
hackbunny posted:Is the single window UI a hard requirement or just convention? Looks like multiple windows are supported in UWP https://docs.microsoft.com/en-us/windows/uwp/design/layout/show-multiple-views WPF is being neglected/in maintenance mode in favor of UWP because they figured out too late that it's to hard or impossible to offload things WPF does to a mobile GPU because of the way it's structured under the hood, IIRC. WPF, like Forms, won't go away because that would break thousands of internal applications that Microsoft's primary customers depend on. Also worth noting that WPF and Forms can mingle! An application based on either can host controls from the other. Probably not a great idea to do that too much, but it's not a totally binary choice. Dunno if UWP will do that, too, but I'd be a kinda surprised if it did. IME, WPF makes it easier to make a consistently good-looking UI, but slightly more annoying/convoluted to wire up the behavior that controls the UI. However, the wiring tends to be testable where Forms control code is much less so.
|
# ? Jan 18, 2018 15:24 |
|
uncurable mlady posted:electron Is Electron really bad or something (or was this a serious recommendation)? I assume it was pretty good, mainly because there are some decent apps built on it. I saw an interesting blog article about creating an app that was basically a self-hosted WebAPI app using .NET Core, with an Electron UI. chippy fucked around with this message at 16:26 on Jan 18, 2018 |
# ? Jan 18, 2018 16:21 |
|
chippy posted:Is Electron really bad or something (or was this a serious recommendation)? I assume it was pretty good, mainly because there are some decent apps built on it. I saw an interesting blog article about creating an app that was basically a self-hosted WebAPI app using .NET Core, with an Electron UI. Electron's fine, I just wish it did a better job of handling stupid OS poo poo like app icons, keyboard shorcuts and menus to OS conventions without having to write a bunch of stuff. If you're mainly targeting windows and don't care if your app feels a little wonky under mac-os or linux then it's not bat at all. This is all assuming that you have lots of experience working in web development, of course.
|
# ? Jan 18, 2018 17:16 |
|
Another question: correct me if I'm wrong, but .NET still doesn't have a standard way to specify/suggest that a return value or argument can't be null, right? There's Nullable to make value types nullable, but nothing to make reference types non-nullable? [and what's taking them so long?] Noted uncurable mlady posted:electron Noted. Sentence: hanged by the neck until dead
|
# ? Jan 18, 2018 17:48 |
|
Munkeymon posted:WPF is being neglected/in maintenance mode in favor of UWP because they figured out too late that it's to hard or impossible to offload things WPF does to a mobile GPU because of the way it's structured under the hood, IIRC. WPF, like Forms, won't go away because that would break thousands of internal applications that Microsoft's primary customers depend on. IIRC, WinRT's existence has less to do with WPF not having mobile GPU support, but more to do with the really dumb internal politics at the time. WPF is not being neglected, nor is it "in maintenance mode". It's still a major, supported framework for building applications on Windows and new features are being added to it. Hell, even WinForms is getting new features in Windows 10, such as better high DPI support out of the box. It's not just because of legacy reasons WinForms is still around. If you're making a simple program (Like CRUD, or whatever), and just need to wire something up quickly, WinForms is great for that. WPF and UWP have a bit of a learning curve to it that makes it less ideal for those use cases (even if, in the end, it would probably result in a more sustainable application if you need to do any maintenance on it).
|
# ? Jan 18, 2018 18:04 |
|
hackbunny posted:Another question: correct me if I'm wrong, but .NET still doesn't have a standard way to specify/suggest that a return value or argument can't be null, right? There's Nullable to make value types nullable, but nothing to make reference types non-nullable? [and what's taking them so long?] It's coming: https://blogs.msdn.microsoft.com/dotnet/2017/11/15/nullable-reference-types-in-csharp/
|
# ? Jan 18, 2018 18:06 |
|
Drastic Actions posted:WPF is not being neglected, nor is it "in maintenance mode". It's still a major, supported framework for building applications on Windows and new features are being added to it. Hell, even WinForms is getting new features in Windows 10, such as better high DPI support out of the box. When I google WPF and find a page full of articles wondering if it's dead, it's being neglected. High DPI support isn't a new feature as far as I'm concerned as a dev/user but rather keeping it in step with Windows.
|
# ? Jan 18, 2018 18:56 |
|
WinForms and WPF are dead ends. Don't let the fact they're still getting bug fixes fool you -- only getting bug fixes is the definition of being in "maintenance mode". All the dev love is behind the UWP platform now. And to be honest, UWP isn't as god awful as it used to be. But even in the presence of roadmaps that only lead straight over a cliff I'd still say that, when it comes to making desktop apps for Windows, WinForms and WPF are still your best options. biznatchio fucked around with this message at 22:05 on Jan 18, 2018 |
# ? Jan 18, 2018 21:44 |
|
UWP is not for desktop apps, is it? It's for sandboxed store apps, right? That's the main thing stopping me e: ... MFC then? New Yorp New Yorp posted:It's coming: That's what I found, too. It's not very promising that it seems to be a C# thing only hackbunny fucked around with this message at 23:04 on Jan 18, 2018 |
# ? Jan 18, 2018 22:58 |
|
hackbunny posted:UWP is not for desktop apps, is it? It's for sandboxed store apps, right? That's the main thing stopping me UWP apps can run on the desktop, they're not limited to phones only, but they're meant to be distributed via the store, not as standalone software. If your users are not likely to want to use the store, that's going to be a big factor. edit: also, UWP apps will limit you to running on Win10. Non-nullable objects in C#8 is entirely a set of compiler rules - it doesn't affect the generated IL at all. So it's not a feature of .net itself, it's just the C# compiler getting cleverer/stricter. I guess the same rules could be built into the VB.net compiler as well, although I'm not sure why anyone would want to start a new .net project in VB in the first place. beuges fucked around with this message at 23:21 on Jan 18, 2018 |
# ? Jan 18, 2018 23:18 |
|
beuges posted:Non-nullable objects in C#8 is entirely a set of compiler rules - it doesn't affect the generated IL at all. So it's not a feature of .net itself, it's just the C# compiler getting cleverer/stricter.
|
# ? Jan 18, 2018 23:33 |
|
Funking Giblet posted:Wonder what nameof does in this scenario Just a guess, but if you have C# code:
Although, now I’m curious what nameof(“string”) or nameof((object)”string”) would return ...
|
# ? Jan 19, 2018 01:56 |
|
beuges posted:UWP apps can run on the desktop, they're not limited to phones only, but they're meant to be distributed via the store, not as standalone software. If your users are not likely to want to use the store, that's going to be a big factor. edit: also, UWP apps will limit you to running on Win10. Aren't UWP apps stuck inside a sandbox? Like they can't (for example) touch the greater filesystem?
|
# ? Jan 19, 2018 02:41 |
|
LongSack posted:Although, now I’m curious what nameof(“string”) or nameof((object)”string”) would return ... CS8081, apparently.
|
# ? Jan 19, 2018 03:22 |
|
Night Shade posted:CS8081, apparently. Well that is one solution if performance isn't a huge concern - to a nameof check and catch the exception.
|
# ? Jan 19, 2018 04:21 |
|
That's a compiler error, not an exception. nameof(thing) is replaced with a string constant by the compiler. It's got some smarts in there about taking the last identifier in a dotted path of identifiers, so nameof(System.Object.ToString) gets replaced with "ToString", but it doesn't work on literals or anything that needs to be evaluated at runtime. It also doesn't work how you may think for generic type parameters - nameof(TKey) is always "TKey", not typeof(TKey).Name. It basically exists to give refactoring tools something they can guarantee needs to be updated instead of guessing that "MyFunction" and void MyFunction() are the same thing.
|
# ? Jan 19, 2018 04:51 |
|
Night Shade posted:That's a compiler error, not an exception. nameof(thing) is replaced with a string constant by the compiler. It's got some smarts in there about taking the last identifier in a dotted path of identifiers, so nameof(System.Object.ToString) gets replaced with "ToString", but it doesn't work on literals or anything that needs to be evaluated at runtime. I was just realizing that. Everything else I tested suggested that for "string"' and var str = "string", the literal and variable are treated identically by the compiler.
|
# ? Jan 19, 2018 04:57 |
|
What's the best way to do non-trivial validation on domain model entities in ASP.Net MVC Core MVVM? MVC has great auto-validation for ViewModels, but not if your domain models aren't going through the model binding process I have set up view models which can be validated from the DataAnnotations. But then with domain models I want to do some further checking - e.g.
At the moment I'm doing it in the controller and it doesn't feel right. It seems EF Core have washed their hands of validation entirely (doesn't even check for duplicate PKs - just throws an SQL Exception) I can use FluentValidation or some other kind of library, but it seems this still relies on the controller performing the validation (instead of validating on DbContext.Save). This won't work if I don't trust the UI layer. Ideally i'd call DbContext.Save, which would then call a custom Validate() function on my domain object. It could then return a list of DbValidationErrors or similar which I can bubble up to a UI / API. Am I missing something?
|
# ? Jan 19, 2018 06:07 |
|
beuges posted:UWP apps can run on the desktop, they're not limited to phones only, but they're meant to be distributed via the store, not as standalone software. If your users are not likely to want to use the store, that's going to be a big factor. edit: also, UWP apps will limit you to running on Win10. By "desktop app" I mean classic Windows apps, using the terminology used to describe them in the Windows UI beuges posted:Non-nullable objects in C#8 is entirely a set of compiler rules - it doesn't affect the generated IL at all. So it's not a feature of .net itself, it's just the C# compiler getting cleverer/stricter. I guess the same rules could be built into the VB.net compiler as well, although I'm not sure why anyone would want to start a new .net project in VB in the first place. What he said: mystes posted:Doesn't there have to be some sort of change to the output if it's supposed to be able to detect nullable annotations in libraries? For example, Java has no official nullable/non-nullable attribute either, but there are many unofficial ones, like android.support.annotation.NonNull, recognized and honored by other JVM languages with non-null-by-default semantics (like Kotlin) raminasi posted:Aren't UWP apps stuck inside a sandbox? Like they can't (for example) touch the greater filesystem? It would actually be preferrable to sandbox our app... but I'm afraid of the impact it would have on our third party dependencies. UWP also bans certain Win32 functions, right?
|
# ? Jan 19, 2018 09:53 |
|
hackbunny posted:Another question: correct me if I'm wrong, but .NET still doesn't have a standard way to specify/suggest that a return value or argument can't be null, right? There's Nullable to make value types nullable, but nothing to make reference types non-nullable? [and what's taking them so long?] .NET does, it's called F#. But yeah, C# will copy that eventually too. Also, WPF might be dead, but it still works fine for Windows apps (and it's far better than winforms) TheBlackVegetable fucked around with this message at 12:11 on Jan 19, 2018 |
# ? Jan 19, 2018 12:00 |
|
TheBlackVegetable posted:.NET does, it's called F#. It's the existence of F# that made me hope there was a standard or standard-ish set of attributes I could annotate stuff with. But, no. At least, nothing language-agnostic
|
# ? Jan 19, 2018 14:04 |
|
roflsaurus posted:What's the best way to do non-trivial validation on domain model entities in ASP.Net MVC Core MVVM? MVC has great auto-validation for ViewModels, but not if your domain models aren't going through the model binding process I'm confused: why can't you trust your controllers? Anyway, you could make your own DbContext that overrides the base Save method with one that calls Validate, I guess. hackbunny posted:It's the existence of F# that made me hope there was a standard or standard-ish set of attributes I could annotate stuff with. But, no. At least, nothing language-agnostic I didn't know you could do stuff like that with annotations in Java but .Net would probably do it with a wrapper type. int? is just sugar for Nullable<int>, for example. https://fsharpforfunandprofit.com/posts/fsharp-decompiled/ is an interesting look at how F# types look translted into C#
|
# ? Jan 19, 2018 15:29 |
|
nameof is particularly useful for ArgumentNullExceptions where you don't have to worry about your function parameter names deviating from the magic strings. e.g. code:
|
# ? Jan 19, 2018 17:31 |
|
|
# ? Jun 7, 2024 16:37 |
|
B-Nasty posted:nameof is particularly useful for ArgumentNullExceptions where you don't have to worry about your function parameter names deviating from the magic strings. e.g. I thought it was originally added to make observables less annoying to maintain.
|
# ? Jan 19, 2018 18:34 |