|
I have a somewhat weird question. We have a client/server app. The client is WPF. The server is a WCF-equipped windows service. Currently, to get an object, we have some code that looks roughly likeC# code:
We want to move the server into IIS, and talk to it via ASP.NET WebAPI. The application is too big to do this all at once, so we're considering doing this in stages, so over time we can phase out WCF entirely, and eventually retire the windows service. The code to fetch a Person then becomes roughly C# code:
I want to make clear that I eventually want to use async/await, and I want to make calls to the server without freezing the UI. Just not quite yet. I've run in circles trying to keep the original method signature, so I can slowly lower myself into the async/await pool without having to cannonball in. Even if it means turning all the functions that talk to the server into 1-liners that block and return what async/await (eventually) returns. tldr: how can I use ASP.NET WebAPI with a WPF (or any C#) client without going whole-hog on async/await just yet? Ugh, I hope this makes sense. epswing fucked around with this message at 22:04 on Jul 6, 2016 |
# ? Jul 6, 2016 22:01 |
|
|
# ? Jun 10, 2024 13:28 |
|
Ultimately if the change is going to happen regardless, I would just start converting the method signatures now. You don't have to actually change the code that executes, just start making your API calls async Task<T> and add await at the call-sites, letting that bubble out as necessary. The compiler will be very helpful here. This is a very safe process that can be done separately from writing actually asynchronous code. You won't immediately gain the benefits of async/await, but it will be much easier to replace your API calls later on when you choose to do so.
|
# ? Jul 6, 2016 22:38 |
|
^^^ Yeah, Task.FromResult is your friend here. You really can't mix the two, which is why async has to "infect" your code. You're setting yourself up for a world of deadlock pain by trying to force async methods to block.
|
# ? Jul 6, 2016 22:40 |
|
Bognar posted:Ultimately if the change is going to happen regardless, I would just start converting the method signatures now. You don't have to actually change the code that executes, just start making your API calls async Task<T> and add await at the call-sites, letting that bubble out as necessary. The compiler will be very helpful here. This is a very safe process that can be done separately from writing actually asynchronous code. Something I didn't mention is there's a ton of generics and inheritance, so a change to a method in a super class which deals with "T" will basically make me have to change everything at once, instead of bit by bit. Ithaqua posted:^^^ Yeah, Task.FromResult is your friend here. The docs just say "Creates a Task<TResult> that's completed successfully with the specified result" about Task.FromResult. How does FromResult help me in my particular situation? Sorry I'm such an async/await newb :3 Anyways, point taken, I admit what I'm asking is basically "how do I swim against the current" and the real answer is "don't". But I also don't want to be stuck doing this big migration all at once.
|
# ? Jul 6, 2016 22:50 |
|
epalm posted:
Because you can make a method with a signature of async Task<Foo> but still have it do everything synchronously, then return a completed task. Things can await it, but when they call it the task that pops out is already done.
|
# ? Jul 6, 2016 22:56 |
|
epalm posted:Something I didn't mention is there's a ton of generics and inheritance, so a change to a method in a super class which deals with "T" will basically make me have to change everything at once, instead of bit by bit. code:
code:
code:
|
# ? Jul 6, 2016 23:00 |
|
No Safe Word posted:So you can't have async if you don't have await, but once you do have it, you can just return the thing itself and it being async will do all the Task stuff for you. You can have an async method with no awaits. The compiler will warn you that it will run synchronously, but that's okay.
|
# ? Jul 6, 2016 23:22 |
|
Ithaqua posted:You can have an async method with no awaits. The compiler will warn you that it will run synchronously, but that's okay. Oh I always build with warnings as errors so that would be why I thought the compiler enforced it
|
# ? Jul 6, 2016 23:25 |
|
Have any examples been made of what the new features for .csproj files will make it look like? A lot of people complained about project.json being abandoned in favor of csproj, but I don't mind it. I do wonder if that will include the NuGet side of things too.
|
# ? Jul 7, 2016 04:30 |
|
the developers of the new project system have posted some ideas and examples at https://github.com/dotnet/roslyn-project-system/issues/40 one hypothetical look (not all presently implemented) is code:
|
# ? Jul 7, 2016 05:23 |
|
I've got an application at a bunch of customer sites, and one of them wants a feature that's specific to their site that the rest are unlikely to want. I was looking at some kind of plugin system like MEF as a way to keep custom work out of the main solution, but it feels like I could be going down a rabbit hole here... Is there a common approach to this kind of requirement?
|
# ? Jul 7, 2016 08:42 |
|
mortarr posted:I've got an application at a bunch of customer sites, and one of them wants a feature that's specific to their site that the rest are unlikely to want. I was looking at some kind of plugin system like MEF as a way to keep custom work out of the main solution, but it feels like I could be going down a rabbit hole here... Is there a common approach to this kind of requirement? This sounds like a rabbit hole to me. I'd only go with the plug-in solution if you have lots of different customer-specific features that need to be implemented, xcopy deployment while running, or the customer can write their own plug-ins. I would just use an interface and pass in either AllCustomersModule or SpecificCustomerModule based on a feature flag or detect the customer, just some good old IoC/DI work.
|
# ? Jul 8, 2016 17:20 |
|
mortarr posted:I've got an application at a bunch of customer sites, and one of them wants a feature that's specific to their site that the rest are unlikely to want. I was looking at some kind of plugin system like MEF as a way to keep custom work out of the main solution, but it feels like I could be going down a rabbit hole here... Is there a common approach to this kind of requirement? If you are certain this will be the only one ( I know, I know ) I would just build a version for them and document the hell out of it.
|
# ? Jul 8, 2016 23:22 |
|
I think mef / plugins arent for me this time... I did a wee proof of concept, and while it worked, it showed some bits that might make development take a while, eg logging, loading/unloading plugins, and generally keeping the logic that belongs in the plugin inside the plugin. I already have a basic kind of feature detection, so i'll probably go that way instead. Not sure i like it architecture wise, but i can get it done that way pretty quickly. If it was for my own stuff, I would go mef all the way :-)
|
# ? Jul 9, 2016 05:31 |
|
I'm trying to be a good, little developer and insulate my app from requiring "elevation", simply because I don't want to provide security vulnerabilities from a crappy game-editing app. I figure that allowing this app to write in protected spaces would mean open the door to malicious code, so why risk it? Design-wise, I'm going to do this by checking if the file being opened requires elevation (i.e. the file is still in Program Files) and directing the user to create a new, local directory for the edited files. I'm running into a hitch with getting that implemented because I don't know how to test for that. Does FileInfo.Attributes tell me only if the file is flagged as Read Only or will it be flagged as ReadOnly if the file directory is write-protected as well? If I uncheck "Read Only" for the file in Program Files, it's still write protected. I know this because I've tried using an unelevated hex editor on the file and cannot save changes because of lowered permissions. I know I could ignore this and force the program to automatically have separate read and write files, but that would create a host of other, awkward problems. The biggest one being that these files sometimes end up in AppData and, thus, are not write-protected.
|
# ? Jul 12, 2016 23:26 |
|
Just try to open it in write mode and handle the access denied error when you can't.
|
# ? Jul 13, 2016 00:06 |
|
BirdOfPlay posted:Does FileInfo.Attributes tell me only if the file is flagged as Read Only or will it be flagged as ReadOnly if the file directory is write-protected as well? If I uncheck "Read Only" for the file in Program Files, it's still write protected. I know this because I've tried using an unelevated hex editor on the file and cannot save changes because of lowered permissions.. mystes fucked around with this message at 02:13 on Jul 13, 2016 |
# ? Jul 13, 2016 01:57 |
|
You always have to handle all possible file access exceptions anyway, because the disk state could change between whatever check you do and your actual attempt to access the file.
|
# ? Jul 13, 2016 03:24 |
|
I'm playing around with .NET on Linux and I'm wondering how to import a locally built class library into another project. I'm trying to import a dependency that can be built with .NET core but the nuget package hasn't been updated to support core yet.
|
# ? Jul 13, 2016 22:14 |
|
there's an imports: key available in project.json which lets you override what a package claims to support. use with care though, bc if it really isn't compatible you're in for a runtime crash
|
# ? Jul 14, 2016 03:32 |
|
Gul Banana posted:there's an imports: key available in project.json which lets you override what a package claims to support. use with care though, bc if it really isn't compatible you're in for a runtime crash Yeah, that's part of the problem. I don't think the version that's on NuGet will work with core. However, the version that I built from Github does. I just don't know how to integrate that version.
|
# ? Jul 14, 2016 17:28 |
|
oh! right. if you built it in the same solution, you can reference it as a dependency with {"target": "project"} instead of a version number (in visual studio the gui will let you do this via 'add reference'). otherwise, dotnet pack/nuget pack it into a nupkg and put that in a local folder package source or on myget or something.
|
# ? Jul 14, 2016 19:45 |
|
here's a test solution i made recently that just has a bunch of project files of various flavours referencing each other in different ways https://github.com/gulbanana/StructureMock
|
# ? Jul 14, 2016 19:46 |
|
Ochowie posted:Yeah, that's part of the problem. I don't think the version that's on NuGet will work with core. However, the version that I built from Github does. I just don't know how to integrate that version. Paket can reference git dependencies, and I think it works with core now.
|
# ? Jul 14, 2016 20:27 |
|
Gul Banana posted:oh! right. if you built it in the same solution, you can reference it as a dependency with {"target": "project"} instead of a version number (in visual studio the gui will let you do this via 'add reference'). otherwise, dotnet pack/nuget pack it into a nupkg and put that in a local folder package source or on myget or something. Thanks for this. So I ran dotnet pack on the repo, but I can find the nupkg anywhere. Do you know where it outputs to? I'm thinking part of the problem is that this library technically compiles for .net standard instead of .net core so I wonder if that's what is tripping me up? Edit: Also, what is the connection between applications targeting the .NET Standard and .NET Core? Can I use a .NET Standard library from a .NET Core app? Also, I can't seem to make a .NET Standard console application (maybe that's because I'm running a version of Linux, Ubuntu 15.10 that's not supported by .NET Standard?). Ochowie fucked around with this message at 22:36 on Jul 14, 2016 |
# ? Jul 14, 2016 21:10 |
|
netstandard is for libraries only, not apps. it's like an interface which is implemented by actual platforms, of which .net core (netcoreapp) is one. for example, netcoreapp1.0 implements netstandard1.6; .net 4.6.1 (net461) and UWP both implement netstandard 1.4. so a library built for netstandard1.4 would support all three, but one built for netstandard1.6 would only support .net core. docs: https://github.com/dotnet/core-docs/blob/master/docs/core/tutorials/libraries.md
|
# ? Jul 15, 2016 07:50 |
|
Ain't two frameworks wonderful? This is what I am afraid of. I hope it doesn't get any worse in the future.
|
# ? Jul 15, 2016 09:32 |
|
Gul Banana posted:netstandard is for libraries only, not apps. it's like an interface which is implemented by actual platforms, of which .net core (netcoreapp) is one. Thanks for this. Am I correct in assuming that libraries anything that can build to netstandard <= 1.6 can be used by a netcoreapp1.0 console application? I've run into something strange where the library I'm trying to build from source targets netstandard1.5 but depends on a library that isn't supported by netcoreapp1.0 (IX-Async) and I'm not sure how that's possible?
|
# ? Jul 15, 2016 18:53 |
|
your understanding of netstandard is correct. it's possible the author of the library used imports.. do you have source somewhere?
|
# ? Jul 15, 2016 19:16 |
|
actually, ix-async is open source. looking here https://github.com/Reactive-Extensions/Rx.NET/blob/master/Ix.NET/Source/System.Interactive.Async/project.json it appears that it DOES build for netstandard (with extra features if you have 1.3+). netstandard1.0 support is also listed at https://www.nuget.org/packages/System.Interactive.Async/
|
# ? Jul 15, 2016 19:18 |
|
Gul Banana posted:your understanding of netstandard is correct. it's possible the author of the library used imports.. do you have source somewhere? You mean in the Frameworks section? If so, then yes, it imports portable-net45.
|
# ? Jul 15, 2016 19:19 |
|
Incoming question that has probably been asked 1 million times before... So I have recently started learning .NET ASP MVC as a framework for software as a service applications. I have a background in Laravel MVC framework which I understand very well, but I am having a problem finding good documentation for learning ASP MVC. Most of the stuff that I am finding are "beginner tutorials" which are really just boring, slow, and generally unhelpful code-along type things. I am looking for something more along the lines of Laravel's documentation style or something that is at least not-targeted at straight coding beginners, but isn't to the point of just reading straight API docs right off the bat. The only decent looking documentation I have found along those lines is here: https://docs.asp.net/en/latest/index.html. However, it is woefully incomplete and doesn't have a section on MVC 4, which I need to use. The rest of it is mainly tutorials designed for "beginners" that are code-by-copy-paste. These aren't very helpful nor informative because they show you how to do a basic task, but don't give you any information on customization nor explain the greater API at all. Lastly, its a waste of time to re-read through long tutorials in search of information on a specific task. None of the google searching I have done has lead me to any sort of .NET MVC reference document. Even Microsoft's documentation page for MVC 4 https://msdn.microsoft.com/en-us/library/gg416514(v=vs.108).aspx is linking forums posts as opposed to Microsoft written documentation, and its still missing entire sections. So my question, is the documentation for the .NET framework really this lacking that Microsoft just links forums posts? Or is there a resource out there that google search is reluctant to link to? I am hugely disappointed so far since when I was learning Laravel it was super easy to just go to the site and get a feature list with code snippets to remind oneself of a specific part of the Frameworks functionality without having to dig through mountains of unrelated stuff. Learning .Net has just been Maybe I need to not search for .NET MVC, but rather there are specific modules that I need to be looking up? twig1919 fucked around with this message at 02:14 on Jul 16, 2016 |
# ? Jul 15, 2016 21:23 |
|
twig1919 posted:Incoming question that has probably been asked 1 million times before... Search for the specific version, like ASP.NET MVC 6 or .NET Core: This is prettty good: https://docs.asp.net/en/latest/mvc/index.html e: Whoops, looks you already had that link.
|
# ? Jul 16, 2016 22:00 |
|
twig1919 posted:Incoming question that has probably been asked 1 million times before... I definitely feel the frustration, but the usual ASP/MVC pipeline doesn't tend to be *too* complicated. I guess the question is "what are you trying to do?" With some use cases of where you're feeling burnt, we can likely provide solutions. But otherwise it seems like it could be anything from just trying to figure out Razor syntax all the way out to something like complex routing issues.
|
# ? Jul 17, 2016 16:22 |
|
We have a few MS people in this thread - I wonder if you can comment on how accurate this thread is with regard to MS internal workings. Us in the software development industry are likely to have better insight than random reddit commenters, so I would be quite interested in hearing another viewpoint here, especially as Microsoft is one of my top "If I ever want a career change" employers.
|
# ? Jul 17, 2016 17:50 |
|
I'm not an MS person, but most of those read like they were written by terrible coders who couldn't understand a system, refused to follow a team's guidelines (however silly they might be), or refused to learn how stuff worked. It doesn't take a Ph.D to figure out what ASP.NET needs to run and how to get it to run. I'm sure some part of those are true or have some kernel of truth to them, though. Technical debt, skipping full QA coverage for certain features in favour of limited opt-in deployment, developers not knowing how to work with databases are all par for the course for software development no matter where you work.
|
# ? Jul 17, 2016 18:02 |
|
Yeah those all hit home with my job too. We tried dogfooding our software for agile project management AND for our HR system (lots of custom plugins) and it was a 3-year-long nightmare.
|
# ? Jul 17, 2016 19:44 |
|
EssOEss posted:We have a few MS people in this thread - I wonder if you can comment on how accurate this thread is with regard to MS internal workings. Us in the software development industry are likely to have better insight than random reddit commenters, so I would be quite interested in hearing another viewpoint here, especially as Microsoft is one of my top "If I ever want a career change" employers. Red Mike posted:...all par for the course for software development no matter where you work. That, right there. I've technically been for a few months, but we're pretty separate from everyone else at the moment. All I could say reading that is that a lot of it is "Welcome to Software development!" Stuff. Like, no poo poo, software as complex as Windows does have weird crap going on in it. And internal infighting between teams at MS is pretty well known (hence the whole "One Microsoft" push to get people working together and not against each other). But most of what was said could be said for a lot of software projects or companies.
|
# ? Jul 17, 2016 20:26 |
|
I think there's some very talented engineers at MS based off of talking to people who work there, but the management culture they have seems rather unpleasant based on my experiences with some former MS management types.
|
# ? Jul 17, 2016 20:35 |
|
|
# ? Jun 10, 2024 13:28 |
|
When someone complains that they got chewed out for spending two weeks refactoring something merely because it was ugly I find it hard to sympathize with them.
|
# ? Jul 17, 2016 21:01 |