|
raminasi posted:The Ctrl-T search is way better than in vanilla. That and the Shift+Alt+L
|
# ? May 17, 2018 03:04 |
|
|
# ? Jun 8, 2024 09:39 |
|
Someone mentioned NancyFx to me today, and I've read all their documentation and I'm just not seeing the value proposition vs. asp.net webapi. Yes Nancy looks a little less verbose, but I haven't run into enough problems where I see it's...flexibility or 'streamlined' framework as a substantial benefit Am I missing some obvious use cases?
|
# ? May 17, 2018 05:08 |
|
Nurbs posted:Someone mentioned NancyFx to me today, and I've read all their documentation and I'm just not seeing the value proposition vs. asp.net webapi. Yes Nancy looks a little less verbose, but I haven't run into enough problems where I see it's...flexibility or 'streamlined' framework as a substantial benefit Having just taken a quick glance at it, it would be excellent for very quickly prototyping something but I'm kind of with you that I can't see how you'd be able to rely on it in a real world application - it would get very untidy very quick.
|
# ? May 17, 2018 05:13 |
|
raminasi posted:The Ctrl-T search is way better than in vanilla. This and the context aware Alt-Enter are the main reason I keep using it.
|
# ? May 17, 2018 05:25 |
|
a hot gujju bhabhi posted:I use it primarily for its code style features, since I work a lot of inherited code and I like to try to bring it into line with good style while I work on it, having the highlighting from ReSharper is super handy for that. I haven't done much with ASP.NET Core MVC yet, and I'm especially unfamiliar with the changes to bundling / minification, but I imagine it wouldn't be too hard to write a custom tag helper that reads the bundle config and does what you want. e.g. pass the output file name into the custom tag helper, and depending on the environment the custom tag helper decides to either render a single script tag for that output file, or parse the bundleconfig.json file to find the corresponding input files and render script tags for them.
|
# ? May 17, 2018 05:56 |
Nurbs posted:Someone mentioned NancyFx to me today, and I've read all their documentation and I'm just not seeing the value proposition vs. asp.net webapi. Yes Nancy looks a little less verbose, but I haven't run into enough problems where I see it's...flexibility or 'streamlined' framework as a substantial benefit I'm pretty sure it appeared long time ago and asp.net propositions weren't there yet.
|
|
# ? May 17, 2018 07:07 |
|
NiceAaron posted:I haven't done much with ASP.NET Core MVC yet, and I'm especially unfamiliar with the changes to bundling / minification, but I imagine it wouldn't be too hard to write a custom tag helper that reads the bundle config and does what you want. e.g. pass the output file name into the custom tag helper, and depending on the environment the custom tag helper decides to either render a single script tag for that output file, or parse the bundleconfig.json file to find the corresponding input files and render script tags for them. Yeah you're quite right, I was hoping for a built in thing but rolling my own probably won't be too tricky if all else fails. Thanks for the suggestion.
|
# ? May 17, 2018 07:25 |
|
Shy posted:I'm pretty sure it appeared long time ago and asp.net propositions weren't there yet. yeah IIRC Nancy's been around since 2010, as a .NET answer to Sinatra
|
# ? May 17, 2018 07:47 |
|
NancyFX is pretty nice, it has some structuring that you have to be aware of. But the guys who wrote it are really good.
|
# ? May 17, 2018 22:37 |
|
Anyone know how I can authenticate an httpclient request when all I am passing in is an api key (key/value pair)? I have a bunch of code using Basic authentication and passing in a username/password combo, but in this case all I need to pass in is "api-key" and the key value. I'm working with the following: code:
code:
Essential fucked around with this message at 23:27 on May 17, 2018 |
# ? May 17, 2018 23:07 |
|
Anyone know of any extensions like these (basically Ctrl + D in VS Code) for Visual Studio 2012? https://marketplace.visualstudio.com/items?itemName=thomaswelen.SelectNextOccurrence Little things like this are why I end up doing larger coding in VS code rather than Visual Studio...
|
# ? May 18, 2018 17:41 |
|
The Dark Wind posted:Anyone know of any extensions like these (basically Ctrl + D in VS Code) for Visual Studio 2012? https://marketplace.visualstudio.com/items?itemName=thomaswelen.SelectNextOccurrence If you're forced to use the 6-year-old VS2012, I don't blame you for using VS Code instead. Is there some issue with solution/project migration that's keeping you on '12, or is your employer just cheap as hell? VS has improved substantially since then, and it's worth paying for the newest version.
|
# ? May 18, 2018 19:22 |
|
Time for my annual “anyone know of a good print library” question. I’m talking about report oriented stuff, which is mostly FixedDocuments rather than FlowDocuments. Where I’ve done them, holy crap is it a pain in the rear end, throwing together grids, stackpanels, textboxes, etc. and having to track the y-values (“heights”) of the various controls for pagination. Generally, if I can get away with it, I instead offer an option to export the data to excel (thanks EPPlus!) in the name of “flexibility” - here’s the data, do with it what you will. I’d kill for a decent print library though.
|
# ? May 19, 2018 03:41 |
|
E: I figured it out
underage at the vape shop fucked around with this message at 08:15 on May 19, 2018 |
# ? May 19, 2018 07:50 |
|
If your ElapsedTicks are smaller than Stopwatch.Frequency (in other words, if the test took less than a second) integer division will give you a 0 there. Just casting ElapsedTicks to a double should fix it. Or multiply by a billion before dividing. Also, now that I check I think you're actually multiplying by 100 million.
|
# ? May 19, 2018 08:11 |
|
Sindai posted:If your ElapsedTicks are smaller than Stopwatch.Frequency (in other words, if the test took less than a second) integer division will give you a 0 there. Just casting ElapsedTicks to a double should fix it. Or multiply by a billion before dividing. Yeah I made a mistake with data types like an idiot. And you were right, it was only 100 million
|
# ? May 19, 2018 08:16 |
|
To be honest I would have written it as 1000*1000*1000 because I don't trust myself to count past my fingers.
|
# ? May 19, 2018 08:20 |
|
Normally I write it like 1 000 000 000 then delete the spaces, but today I was feeling cocky.
|
# ? May 19, 2018 16:44 |
|
underage at the vape shop posted:Normally I write it like 1 000 000 000 then delete the spaces, but today I was feeling cocky. C# 7 has digit separators. http://www.davidhayden.me/blog/csharp-7-underscore-as-digit-separator-in-numeric-literals
|
# ? May 19, 2018 16:58 |
|
LongSack posted:Time for my annual “anyone know of a good print library” question. I’m talking about report oriented stuff, which is mostly FixedDocuments rather than FlowDocuments. Where I’ve done them, holy crap is it a pain in the rear end, throwing together grids, stackpanels, textboxes, etc. and having to track the y-values (“heights”) of the various controls for pagination. I feel your pain. I couldn't take the FixedDocument/FlowDocument madness anymore and wrote a text-based, fixed-width printing utility where you specify your column headers, widths, and alignment, and just write rows/cells in a loop. It re-prints headers on page-breaks too. It's not as "cool" as text that flows and wraps and all that, but it works well. Luckily my customers don't care if it's not flashy, they just want something that works and is simple. I've been meaning to open-source it (GitHub, Nuget, etc), but I keep reading horror stories from OSS maintainers. epswing fucked around with this message at 18:42 on May 19, 2018 |
# ? May 19, 2018 18:34 |
|
epalm posted:I feel your pain. I couldn't take the FixedDocument/FlowDocument madness anymore and wrote a text-based, fixed-width printing utility where you specify your column headers, widths, and alignment, and just write rows/cells in a loop. It re-prints headers on page-breaks too. It's not as "cool" as text that flows and wraps and all that, but it works well. Luckily my customers don't care if it's not flashy, they just want something that works and is simple. I've been meaning to open-source it (GitHub, Nuget, etc), but I keep reading horror stories from OSS maintainers. That’s an interesting idea for stuff that’s truly tabular - pick a fixed-pitch font and go for it. That would solve about 90% of my issues, too, and would be fun to write. That leaves “the beast” - a character portfolio manager for authors. So much of the data is variable length, it really does require all the lower level controls and height tracking. I’d try to write something myself, but it seems rather daunting.
|
# ? May 20, 2018 00:58 |
|
The easiest way to actually generate printable files nowadays is probably to use some sort of html to pdf conversion program or library, but this won't easily integrate into a desktop application as easily as it would with a web page.
|
# ? May 20, 2018 01:33 |
|
New Yorp New Yorp posted:C# 7 has digit separators. this is huge
|
# ? May 20, 2018 13:32 |
|
mystes posted:The easiest way to actually generate printable files nowadays is probably to use some sort of html to pdf conversion program or library, but this won't easily integrate into a desktop application as easily as it would with a web page. Use Razor templates, RazorLight to render them and HTML to PDF to print them. If HTML to PDF isn't getting the rendering quite right, use Chrome programmatically to render the page and print it.
|
# ? May 21, 2018 00:06 |
|
Any AutoMapper geniuses here? I need to know if there's a way to configure a mapping such that it uses one or another property as the source object for all mappings depending on a conditional. Something like this: C# code:
Edit: Oh by the way, I know about resolvers etc, but I was hoping to create a mapping that can be used as an EF projection. putin is a cunt fucked around with this message at 03:03 on May 21, 2018 |
# ? May 21, 2018 03:00 |
|
Ugh. Either I'm going down a XY problem path, or I'm clashing with Microsoft's 'my way or the highway' approach. Possibly both. So I have an ASP.NET Core WebAPI application. It can be launched in two different configurations (sort of a master/slave setup), and based on this launch option I want it to change some behaviour (eg. use different auth options, expose some folders rather than others), and the part that's giving me trouble: I want it to expose either one set of controllers or another. Some controllers are active in both, and the configurations / controller sets might change as the application grows, so I would rather not split the application into multiple assemblies if at all possible. I thought I'd managed to get it working by adding a custom IStartup class, which configured the IApplicationBuilder and IServiceCollection in the appropriate way, then adding .AddControllersAsServices() and explicitly listing which controllers I wanted to be available. (This also came with the bonus of letting me explicitly call their constructors instead of having to trust the DI system.) Well, it's mostly working, in the sense that if I try to call an endpoint on a controller that isn't listed I correctly get a 404. However, the absolute fuckers in the MVC internals appear to be still doing some reflection-based loading, because if I define the same endpoint route in two different controllers, it does not care in the slightest that only one of the controllers is currently registered in the application - it goes 'durr, this path exists somewhere else in the assembly' and throws a 500: quote:Request starting HTTP/1.1 POST http://localhost:8085/api/v1/logout 0 Looking further into it, it seemed as if I could override this behaviour by also specifying a custom IApplicationFeatureProvider<ControllerFeature> (did I mention I loving love OO engineering?), but it didn't actually work. The next step looks like it might lie in the even more friendly-named IActionDescriptorCollectionProvider, but I guess this is where I should call it quits and just find a different solution, or put up with the limitation by adding more routes. Anyway, even if this post gets immediately followed by a brutal takedown showing how my idea was fundamentally wrong in the first place, I still want to say this: death to reflection.
|
# ? May 23, 2018 18:55 |
|
.NET Core 2 .NET Framework 4.6.1 TFS Version 16.122.27409.2 Visual Studio is 2017 15.5.6 I have a Solution with three active projects in it. A .NET Core Model, a WPF UI, and Unit Tests. I wanted logging, so I look to see which Nuget package has the most downloads. log4net, sounds great, love that apache license. Builds fine on my machine, no problems. Builds fine on the other developer's machines. Doesn't build on TFS. Because it can't find the log4net reference. w t f. Restore Nuget is in the tasks, but its only restoring it in the .NET Core Model project, not the UI WPF project where I actually want it? nuget.Config is in play but has all the same sources that my local machine has, since I'm the one who checked it into git. Just looking for some hints on places to look...
|
# ? May 23, 2018 20:36 |
|
roadhead posted:Just looking for some hints on places to look... Start here: https://fsprojects.github.io/Paket/getting-started.html In my experience, whenever you're doing anything non-trivial with nuget dependencies (such as mixing runtimes), first install paket, then try to solve your problem. At the very least, you'll have plain text files to maintain and plain text outputs to read, instead of cryptic XML diffs and VS squiggles.
|
# ? May 23, 2018 20:50 |
|
NihilCredo posted:Ugh. Either I'm going down a XY problem path, or I'm clashing with Microsoft's 'my way or the highway' approach. Possibly both. This has to be happening somewhere that the application build the default routes with the controller and action names. That all has to be done thru reflection, right? Or am i misunderstanding when/how this err happens?
|
# ? May 23, 2018 20:51 |
|
I learned something today that I wanted to share, just in case it helps anyone else. HttpClient should NOT be used in a using block, even though it implements IDisposable. This can cause some serious performance problems. For us, specifically we had an Azure Function that was scaling up in ways we couldn't understand. It turns out it was due to wrapping an httpclient in a using block. What can happen is it leaves ports open and can even utilize all ports and hang the system up while waiting to free up resources. Many of you may already know this, but I wanted to share just in case. Here's the link I found originally on the issue: https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/ . Here is a link from Microsoft describing it: https://docs.microsoft.com/en-us/azure/architecture/antipatterns/improper-instantiation/ I was mistaken in that I thought anything that implements IDisposable should always be in a using block.
|
# ? May 23, 2018 22:28 |
|
They've added HttpClientFactory in .NET Core 2.1 (currently in preview/RC), in part to help devs deal with stuff like that https://blogs.msdn.microsoft.com/webdev/2018/02/28/asp-net-core-2-1-preview1-introducing-httpclient-factory/
|
# ? May 23, 2018 23:23 |
|
override the nuget version in the build step to at least 4.5.0 NihilCredo posted:Start here: or do this, paket is also good and iirc already has support for lock files e: but it is another tool that doesn't come bundled with vs (maybe if you install f# into your visual studio), so there's that Essential posted:I was mistaken in that I thought anything that implements IDisposable should always be in a using block. this is not helped by the fact that roslyn and resharper both will bitch at you about not either using{} it or implementing idisposable yourself edit: also consider serilog, because structured logging is amazing
|
# ? May 24, 2018 00:27 |
|
NihilCredo posted:Ugh. Either I'm going down a XY problem path, or I'm clashing with Microsoft's 'my way or the highway' approach. Possibly both. There's a whole lot to unpack here. To start, you're trying to treat one project as though it were two. Fundamentally this is problematic, so I'd recommend splitting the projects. You can put all the business logic into a shared project so that you don't have to write everything twice. There's no such thing as ASP.NET Core WebAPI - do you mean ASP.NET WebAPI or ASP.NET Core? I'm assuming from the content of the post it's the latter, which isn't a big deal but it will help you filter out useless stuff when Googling. I'm also a bit confused by the message you're getting. How is it possible that controllers with two different names have the same route, have you manually configured the routing this way somewhere? Can you show us your Startup.cs? Finally, I'm not sure what you mean about "trusting" the DI system. You configure it yourself, what's the issue you're having with the built-in DI stuff?
|
# ? May 24, 2018 01:46 |
Essential posted:I was mistaken in that I thought anything that implements IDisposable should always be in a using block. Why does it implement IDisposable in the first place, if you are not supposed to dispose it?
|
|
# ? May 24, 2018 07:30 |
|
Because Microsoft is far from immune to bad software design (see DLL Hell v2.0: .NET Core Edition: .NET Standard Strikes Back: the Return of the MethodNotFoundException)
|
# ? May 24, 2018 07:48 |
|
SimonChris posted:Why does it implement IDisposable in the first place, if you are not supposed to dispose it? What EssOEss said, but also because you should technically dispose it when it's no longer needed, which of course is a bit hard to define depending on how you are using it.
|
# ? May 24, 2018 07:56 |
Essential posted:Many of you may already know this, but I wanted to share just in case. Here's the link I found originally on the issue: https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/ . Someone in the comments to that article claim that you then need to dispose the HttpResponseMessages, or you will have memory leaks. Like this: code:
|
|
# ? May 24, 2018 08:30 |
|
Essential posted:I learned something today that I wanted to share, just in case it helps anyone else. HttpClient should NOT be used in a using block, even though it implements IDisposable. This can cause some serious performance problems. For us, specifically we had an Azure Function that was scaling up in ways we couldn't understand. It turns out it was due to wrapping an httpclient in a using block. What can happen is it leaves ports open and can even utilize all ports and hang the system up while waiting to free up resources. There was another poster here that had a problem when using the client in async methods. When an exception occurs in a HttpClient it will silently drop all other requests on different threads because it is one object IIRC. If you just use HttpWebRequest do you still have this problem? I usually just use the HttpWebRequest directly, or does this also use the HttpClient?
|
# ? May 24, 2018 08:35 |
|
HttpWebRequest has been in .NET since the early days, whereas HttpClient is newer, so I would expect the former to be the lower level primitive - possibly HttpClient might be using HttpWebRequest internally (or at least some of the HttpClient implementations - there are several over the different .NET variations!).
|
# ? May 24, 2018 09:02 |
|
|
# ? Jun 8, 2024 09:39 |
Speaking of HTTP clients, as far as I can tell HttpWebRequest is the only way to use NTLM authentication with the current credentials? Is that right?
|
|
# ? May 24, 2018 09:22 |