|
Gul Banana posted:I'm looking forward to using it in a wizard system I've got which inverts flow of control by having external code orchestrate and rerun the async method. The orchestrated method suspends itself and returns control to the orchestrator by awaiting; right now that code has to use tons of TaskCompletionSources and keep track of them using faux continuations. I can make the whole thing simpler when custom awaitables are returnable. I wrote a blog post about how to "hibernate an async method" -- basically, serialize the state of an async callstack to disk, and deserialize it afterwards. I wonder if this might be useful? https://blogs.msdn.microsoft.com/lucian/2016/04/20/async-workflow-2/
|
# ? Oct 2, 2016 02:16 |
|
|
# ? Jun 1, 2024 13:38 |
|
Gul Banana posted:i didn't think finally blocks were automatically CERs, though. you need to inherit from criticalhandle or something? and use attributes also, i think Yeah I think you might be right actually, and ThreadAbortExceptions get delayed until after finally blocks and finalisers by the runtime anyway. I haven't spent a lot of time in this area of the framework.
|
# ? Oct 2, 2016 05:47 |
|
i don't want to make assumptions, but it's possible that part of ConcurrentDictionary.cs is just a cargo cult technique..
|
# ? Oct 2, 2016 12:40 |
|
ljw1004 posted:I wrote a blog post about how to "hibernate an async method" -- basically, serialize the state of an async callstack to disk, and deserialize it afterwards. I wonder if this might be useful? oh man, i have to read through this. your lambda-based approach to accessing the state machine is much nicer than a prototype i ended up discarding for that same wizard system: https://gist.github.com/gulbanana/5d2e2291a42e717ce73d12d2f19c8306 what i ended up doing instead was running the munged method repeatedly, 'jumping' around parts of it by re-executing with a host function which was sometimes a dummy. that works almost all the time and it lets me feel smart by writing continuation combinators, but it does have the huge drawback that wizard implementations have to be strictly deterministic or it breaks in weird ways! your checkpoint approach seems like it could avoid that problem entirely, though i'm not 200% comfortable with "_type_AsyncMethodBuilderCore.GetMethod("TryGetStateMachineForDebugger", BindingFlags.NonPublic | BindingFlags.Static);".
|
# ? Oct 2, 2016 12:44 |
|
ljw1004 posted:but it's back-compat for what in retrospect was a bad original design and if we could go back in time to remove it then we would. What do you mean by this? That is, what was the bad aspect of the design?
|
# ? Oct 2, 2016 19:52 |
|
EssOEss posted:What do you mean by this? That is, what was the bad aspect of the design? code:
If you wrote the function "f" like this, then you likely never considered what would happen when someone gave you an async lambda. You likely just execute the lambda and expect a synchronous result. If you invoke the function "f" like this, then you likely assume that the function "f" will behave "properly" when given an async lambda, and you'll be disappointed.
|
# ? Oct 2, 2016 20:27 |
|
Gul Banana posted:i don't want to make assumptions, but it's possible that part of ConcurrentDictionary.cs is just a cargo cult technique.. Heh. Maybe. There is some stuff about it on the documentation for Thread.Abort https://msdn.microsoft.com/en-us/library/5b50fdsz(v=vs.110).aspx but I clearly made the leap to constrained execution based on some badly remembered stuff I read a while ago
|
# ? Oct 3, 2016 00:29 |
|
ljw1004 posted:We discussed in LDM that we honestly don't expect more than three or so people to realistically write custom tasklike types, and the three were all in the meeting. (Stephen Toub who writes ValueTask, and Oren Novotny who owns IObservable, and Stephen Toub who'd be on point to write IAsyncAction). yesss monad transformers
|
# ? Oct 3, 2016 03:13 |
|
This is kind of a general question which I think will boil down to personal preference for some people, but anyway... I'm finding a fairly common pattern arising in my MVC projects. Whenever I have a form that needs to be filled out, I'll frequently need to load in some other information for the page as well. As an example, we'll take this ViewModel for a form to allow a student to enrol into a course: code:
Now if there's an error, in order to correctly reload the form with the error messages present I'm going to need to either include those three information properties in the form as hidden fields, or I'm going to need to make sure I populate them in the event of an error so the page can be rendered again without error. I find this really clunky and awkward, and it seems to violate the DRY principle as I end up with two separate pieces of code responsible for populating those properties on the ViewModel. How do you guys tend to handle these "extra baggage" fields when handling forms?
|
# ? Oct 3, 2016 05:32 |
|
The Wizard of Poz posted:This is kind of a general question which I think will boil down to personal preference for some people, but anyway... If it's just the simple stuff like CourseName and the Dates in your example, then I tend to just use a hidden field in the form, for the sake of simplicity. I don't know if that's the 'right' thing to do or not (I suspect it's not and you should be restricting the client to POSTing back only the fields that are required). For more involved stuff like drop-down menu options or things like that, I will create private methods in the controller and call them from the actions that need them - either one that takes the ViewModel as a parameter and populates it with everything it needs, or just methods that return IEnumerable<SelectListItem> (or whatever other things are required) that you can call to get the various bits the ViewModel needs. This second pattern is more flexible as you can use it with different ViewModels that happen to rely on the same sources of information (i.e. lists of suppliers, customers, whatever). chippy fucked around with this message at 12:32 on Oct 3, 2016 |
# ? Oct 3, 2016 12:28 |
|
Hmm yeah I will tend toward private methods in the controllers as well. I don't know, it just feels clunky having that information mixed in among the input fields. It feels like I'm working against MVC somehow, and that there must be a more accepted way.
|
# ? Oct 4, 2016 01:20 |
|
Ok, what am I missing here, is this intended or is this known or do I need to report this?code:
If you run these tests in a generic Unit Test project, both will flag as Skipped/Inconclusive/'yellow' But if you run these tests in a UWP Unit Test project, the async version will flag as a hard *Fail*/'red' - no other changes.
|
# ? Oct 4, 2016 01:27 |
|
with what error message? does it fail also when using mstest v2, the one which is mostly the same between environments?
|
# ? Oct 4, 2016 03:35 |
|
Gul Banana posted:with what error message? does it fail also when using mstest v2, the one which is mostly the same between environments? What do you mean, error message? It's the same thing, it's just that in UWP it counts as a hard 'Fail', the same as Assert.Fail() - whereas in standard projects it's counted as a skip - like flagging a test [Ignore]
|
# ? Oct 4, 2016 04:25 |
|
The Wizard of Poz posted:Hmm yeah I will tend toward private methods in the controllers as well. I don't know, it just feels clunky having that information mixed in among the input fields. It feels like I'm working against MVC somehow, and that there must be a more accepted way. Same here, hidden input fields for simple objects. Sometimes I need to edit lists of child records on the same page, so in that case they go down in their own property like: code:
code:
Someone please tell me there's an easier way for setting up parent/child editable pages in asp.net mvc?!
|
# ? Oct 4, 2016 04:42 |
|
mortarr posted:Someone please tell me there's an easier way for setting up parent/child editable pages in asp.net mvc?! Quite an old post but this is the approach I prefer personally: http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/ This only covers a list but you can use it with a viewmodel with top-level fields and a collection of child viewmodels to edit a parent record and child records in one page.
|
# ? Oct 4, 2016 10:44 |
|
The Wizard of Poz posted:Hmm yeah I will tend toward private methods in the controllers as well. I don't know, it just feels clunky having that information mixed in among the input fields. It feels like I'm working against MVC somehow, and that there must be a more accepted way. Hopping on the private method train. I usually have properties in my ViewModels organized into display-only data and user-editable data. The display-only data is then populated by a private method in the controller while the user-editable data is posted. This is the most flexible configuration, since there are cases where you might have a lot of display-only data that you don't want to be posting back and forth from the server.
|
# ? Oct 4, 2016 15:19 |
|
I'm trying to figure out a neat way to hold onto a collection of Entity Framework Include() expressions and retrieve them generically. Let's say I have the following Entities:code:
code:
code:
How can I get that list of includes? I've considered putting it on the ViewModel as a static property, but then there's no way to enforce the presence of the static property using a type constraint, so there's no way to access that static property generically. Ideas?
|
# ? Oct 5, 2016 00:35 |
|
The Wizard of Poz posted:I'm trying to figure out a neat way to hold onto a collection of Entity Framework Include() expressions and retrieve them generically. Let's say I have the following Entities: Not sure if it's helpdul, but Automapper has ProjectTo() which (I think) you use in a similar way to what you are proposing, although you may need to map things beforehand. Maybe digging in to its source would give you some pointers? If you use its MapTo() method, automapper will project the IQueryable to a list (or similar) and then hit EF once for each of the items in the list (I think this is called the select n+1 problem). Instead, you can use ProjectTo, and it will build a smarter EF query and get all the props at once. It sounds like it's using includes the same way you mention, but I don't know what magic is going on under the hood.
|
# ? Oct 5, 2016 06:34 |
|
mortarr posted:Not sure if it's helpdul, but Automapper has ProjectTo() which (I think) you use in a similar way to what you are proposing, although you may need to map things beforehand. Maybe digging in to its source would give you some pointers? Yeah I've approached it from the projection angle as well, but the problem is I have calculated fields on the Entity that need to be mapped to the ViewModel. This is because the Entity is part of a code library that is shared across projects and I want the business logic for the Entity to remain consistent. In my example I've actually explicitly turned it into a List<> myself so that it forces EF to run the query once to get the entire collection, with the Includes. THEN once I have the list of Entities, I map them using AutoMapper. Edit for clarification: code:
putin is a cunt fucked around with this message at 06:52 on Oct 5, 2016 |
# ? Oct 5, 2016 06:48 |
|
The Wizard of Poz posted:At this stage it's worth mentioning that I've written an IQueryable<T> extension method called IncludeAll() that takes an array of Expression<Func<T, object>> and calls Include() for each. So, it's pretty goofy but you could do something like this: C# code:
edit: this is yet another place where I wish C# had typeclasses (or static interfaces, or whatever they're called on the Roslyn GH issue nowadays). Bognar fucked around with this message at 16:16 on Oct 5, 2016 |
# ? Oct 5, 2016 16:06 |
|
Bognar posted:So, it's pretty goofy but you could do something like this: This is somewhat similar to what I wound up doing, happy to see that it's not an easy thing to solve elegantly. For the record I did this: First I made an interface similar to yours: code:
code:
|
# ? Oct 6, 2016 23:16 |
Is there a way to make an XML serializer print like this:pre:<Contact> <FirstName>Bob</FirstName> <MiddleName></MiddleName> <LastName>Smith</LastName> </Contact> pre:<Contact> <FirstName>Bob</FirstName> <MiddleName /> <LastName>Smith</LastName> </Contact> v That is (un)fortunately beyond the scope of my responsibility. Polio Vax Scene fucked around with this message at 17:43 on Oct 7, 2016 |
|
# ? Oct 7, 2016 17:37 |
|
I suggest you fix whatever is consuming that XML, as the two snippets are completely equivalent. Bad XML parsers must die by starvation!
|
# ? Oct 7, 2016 17:41 |
|
Polio Vax Scene posted:Is there a way to make an XML serializer print like this: From what I've seen googling, there isn't an option out of the box, but I did find a solution that seems simple enough to implement here https://www.experts-exchange.com/questions/28413488/Manipulating-the-output-of-empty-XML-elements-for-NET-serialization.html
|
# ? Oct 8, 2016 17:51 |
|
very dumb question incoming, I hope Xamarin questions are kosher in this thread. Although I'm pretty experienced with C# due to extensive use of very old versions of mono in unity, I have 0 experience with .NET related stuff in most other formats. I'm a bit in over my head as I try to set up a Xamarin.Forms solution. Most guides have really nice step-by-step instructions, but inevitably what I see doesn't match what the guide shows. Right now, I'm using Xamarin Studio and I'm creating a PCL iOS / Android App. I disabled the "Use XAML for user interface" button during setup because when I left it checked it seemed to create a different project setup than al the tutorials I was looking at. My only point of confusion now, I guess, is why there seems to be a LaunchScreen.storyboard in my MyApp.ios project? I can't seem to find any other references to why this would be here. No tutorials show it in the pictures.
|
# ? Oct 8, 2016 22:55 |
|
bomblol posted:very dumb question incoming, I hope Xamarin questions are kosher in this thread. Although I'm pretty experienced with C# due to extensive use of very old versions of mono in unity, I have 0 experience with .NET related stuff in most other formats. I'm a bit in over my head as I try to set up a Xamarin.Forms solution. Most guides have really nice step-by-step instructions, but inevitably what I see doesn't match what the guide shows. Right now, I'm using Xamarin Studio and I'm creating a PCL iOS / Android App. I disabled the "Use XAML for user interface" button during setup because when I left it checked it seemed to create a different project setup than al the tutorials I was looking at. My only point of confusion now, I guess, is why there seems to be a LaunchScreen.storyboard in my MyApp.ios project? I can't seem to find any other references to why this would be here. No tutorials show it in the pictures. So first, I highly encourage you to go to our developer docs site. They get updated frequently and might be a better place to start. This is what's created when you turn off the "Use XAML for user interface" button when making a new project. and this is with using XAML The only difference should be the use of XAML in the PCL project. There is a LaunchScreen storyboard in the iOS project because there needs to be one (It's used to show your apps logo and then start from AppDelegate. You can see it being used in the info.plist). Basically it's following the standard iOS startup for an app to initialize the Xamarin.Forms stuff, so then it goes to what you have in the PCL. I'm not sure what you're confused by though, could you post what tutorials you're trying to follow and what you're trying to do? EDIT: Oh yeah, I should say, IMO, you should start with XAML instead of doing it programmatically. Most tutorials are going to follow that because way more people like using XAML. Drastic Actions fucked around with this message at 23:16 on Oct 8, 2016 |
# ? Oct 8, 2016 23:13 |
|
I've been looking at 3 resources, one of which is on the official site: Tutsplus Sitepoint Xamarin Normally I don't struggle with something as simple as getting a development environment set up and creating Hello World-esque technologies, but my lack of familiarity with .NET or the history of Xamarin has kind of left me reeling. They're all at least slightly outdated, so none of them even mentioned the XAML option, although I certainly have no personal reason not to use it other than it seems that the resources I was using did not. I've been mostly using the one on the Xamarin website e: is the only difference that checking "Use XAML for user interface" does is making the initital App.cs a xaml and xaml.cs like all the other ones the tutorial had me add, instead of just giving it to you as a single .cs file? That would clear up 90% of my confusion. I used React without JSX so I understand the terror of trying to create layouts in code and the preference for using markup for that. bomblol fucked around with this message at 23:40 on Oct 8, 2016 |
# ? Oct 8, 2016 23:28 |
|
bomblol posted:I've been looking at 3 resources, one of which is on the official site: First, I would ignore the tutsplus tutorial. It's pretty old and it's for VS anyway. The XAML option was introduced, to the best of my knowledge, in Cycle 7 which was early this summer. So yeah, our tutorial is slightly little out of date in terms of what the template contains when you make it (like how the LaunchScreen storyboard is created now for iOS, before it was programmatic), but you should still be able to follow it. Originally, when a forms project was created, it would not generate XAML at all, only the app.cs with the mainpage created programmatically. The option was introduced because the first thing most users did was remove the app.cs code and make App.xaml and a MainPage.xaml. The tutorials also assume you have some passing knowledge of .NET and C#. Like, the first HelloWorld doc has basic dependency injection in it. You may want to start with more basic C# stuff first. You can try using Xamarin Workbooks as a REPL to play around with it. Drastic Actions fucked around with this message at 23:49 on Oct 8, 2016 |
# ? Oct 8, 2016 23:45 |
|
Drastic Actions posted:First, I would ignore the tutsplus tutorial. It's pretty old and it's for VS anyway.
|
# ? Oct 8, 2016 23:59 |
|
What are you getting stuck at? I am going through the same thing myself.
|
# ? Oct 9, 2016 00:02 |
|
(sorry for formatting, posting from my phone) Hey goons, I have an asp mvc-4 application that uses jquery to send an ajax request that passes a string back to the server which then is supposed to write that string to a file. Problem is under certain conditions, the string is pretty long. 4 million characters or more. Once the request is sent, the server throws this error: quote:Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the steering exceeds the value set on the maxJsonLength property This gets thrown by System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit) The breakpoint I've set in my controller's method I'm trying to invoke over ajax doesn't get triggered, the server is throwing this exception before MyController.SaveToFile() gets called. I've Googled around and found a handful threads on StackOverflow citing this error, but the suggestions did not work for me. I've tried adding <jsonSerialization maxJsonLength="2147483644" /> to my <system.web.extensions> node in the web.config, and I've also tried <add key="aspnet:MaxJsonSerializationMembers" value="2147483644" /> to the <appSettings> node. I've tried with just one, then the other, they both. Our application was recently just rewritten by some Indian company. Used to be a lovely VB ASP.net application which only used plain old vanilla JS and had only a vague sense of any sort of architectural foresight. Now it's a mediocre C# app that uses jquery, C#, and MVC. I say this because I noticed in the web.config there was this key: <add key="JSONMAXJSONLENGTH" value="2147483644" />. I tried removing this but it made no difference. I also googled for simply "asp.net key JSONMAXJSONLENGTH" and got a whopping 10 results -- 1 of which is a question I posted on SO the other day. But yea. So I'm absolutely clueless as to why the internal serializer class isn't respecting my web.config value. Anyone have any ideas? Sab669 fucked around with this message at 13:45 on Oct 13, 2016 |
# ? Oct 13, 2016 13:43 |
|
Sab669 posted:I've tried adding <jsonSerialization maxJsonLength="2147483644" /> to my <system.web.extensions> node in the web.config, and I've also tried <add key="aspnet:MaxJsonSerializationMembers" value="2147483644" /> to the <appSettings> node. Just to make sure, did you have it in this exact format? code:
|
# ? Oct 13, 2016 14:36 |
|
Bognar posted:Just to make sure, did you have it in this exact format? Yea that's the format I used. Just a pain to type it all out on my phone quote:
This might be a dumb question but how would I do that? I'm still pretty new to ajax, we just call $.ajax({ async, cache, data, dataType, type, url, contentType, traditional, headers, beforeSend, success, error, complete}) Where data is my multimillion character string, url is myController/SaveToFile, then beforeSend, success, error and complete are just a few functions that do the following: validate a token, perform some validation on the results, log the error, and do whatever is needed to the UI respectively. data is initially just a single dimension array with 4 strings: "FileName", "FileNameValue.rtf", "RtfErrorList", "The four million character string to be written to the file" We call JSON.stringify and pass this array. What we get back is sent as the data object in the ajax request. Is this what you're saying I should change?
|
# ? Oct 13, 2016 15:11 |
|
Continue stringifying your data, but when you AJAX it give it to JQuery like { json: serializedData } then either don't specify a contentType or use "application/x-www-form-urlencoded; charset=UTF-8" which is the default. This will send it to your server as a form-encoded POST with one parameter json that has all of your info. Then you can use it in your Action method like this: code:
|
# ? Oct 13, 2016 16:30 |
|
Thanks for the explanation, I'll at least give it a shot. SaveToFile actually returns void, it creates the file from the object passed it an argument and stores it in a session variable. The function defined by the success parameter just shows a pop-up for them to then save it. So that should be fine, right? I guess I'd just need to change the type of the parameter and handle the parsing of the data myself. Sab669 fucked around with this message at 17:05 on Oct 13, 2016 |
# ? Oct 13, 2016 16:59 |
|
Yeah that should work - return type doesn't have any effect on the parameter binding.
|
# ? Oct 13, 2016 18:42 |
|
Is there any way to get LINQ to SQL type functionality with an Oracle database?
|
# ? Oct 13, 2016 19:04 |
|
You can use Entity Framework against an oracle DB. I believe they even ship a fully managed driver via nuget.
|
# ? Oct 13, 2016 19:35 |
|
|
# ? Jun 1, 2024 13:38 |
|
Thanks, I'll have to read up on EF, I haven't any real clue how it differs (or how data interactions in C#/.net work at all yet, really)
|
# ? Oct 13, 2016 19:45 |