Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
After 7 and a half years and over 400 pages, it's time for a new .NET megathread! The old thread is here.

What is .NET?

Wikipedia posted:

[The] .NET Framework ... is a software framework developed by Microsoft that runs primarily on Microsoft Windows. It includes a large class library known as Framework Class Library (FCL) and provides language interoperability (each language can use code written in other languages) across several programming languages. Programs written for .NET Framework execute in a software environment (as contrasted to hardware environment), known as Common Language Runtime (CLR), an application virtual machine that provides services such as security, memory management, and exception handling. FCL and CLR together constitute .NET Framework.

What languages can I use write to fancy-pants .NET applications?
  • C#
  • Visual Basic .NET
  • F#
  • PowerShell
  • IronRuby (alas, this project is pretty dead)
  • IronPython
  • Boo
  • Cobra

What's awesome about .NET languages?
First off, Microsoft is constantly improving the framework and languages -- there's usually a new .NET release every 1-2 years, which brings new versions of C#, VB, F#, etc. Since our last megathread in January 2007, dozens of new features have come along, several of which changed the way we write code on a day-to-day basis. The big ones are:
  • LINQ (.NET 3.5)
  • Lambda expressions
  • Task Parallel Library (TPL) (.NET 4.0)
  • Task Asynchronous Pattern (TAP) aka "async/await" (.NET 4.5)

Plus, Microsoft has created some of the best tooling around. Visual Studio is the IDE that every other IDE wishes it could be, and the .NET framework is huge and has built-in classes and methods to do just about everything.

I want to develop using Visual Studio, but I'm not paying for it!
That's fine, Microsoft has Visual Studio Community for you. Microsoft retired the rather limited "Express" edition of Visual Studio in 2014 in favor of a "Community" edition, which is free to use and full-featured.

Should I be using source control?
Yes!

If you want to stay within the Microsoft stack:

TFS is the all in one ALM solution for the Microsoft world -- it has project planning, source control, automated build, and automated release. It's a solid product, but it requires some forethought when setting it up. The standard source control model is centralized, but it also supports distributed version control by way of native Git support as of TFS2013.

If you don't care about the Microsoft stack:
  • Git is a very popular distributed VCS, but it has a notoriously steep learning curve. It's very, very powerful, though. If you need the kind of flexibility it gives you, it's definitely worth investing the time to learn. VS2012 and 2013 have decent support for basic Git operations built in, but for more complex operations you'll either need to drop to the command line or use a tool like SourceTree or TortiseGit.
  • Mercurial is another distributed VCS, similar to Git but a bit more Windows-friendly. Visual Studio integration exists in the form of VisualHg. TortoiseHg
  • Subversion still works, too! TortoiseSVN
    Visual Studio integration: VisualSvn

Really, the important thing is to use some kind of source control, even for hobbyist projects. It'll save you a lot of pain in the long-run, and possibly even in the short-run. It's entirely possible to switch source control systems if you don't like the one you're using, although the amount of pain in migrating your change history may be prohibitive, depending on where you're going from/to.

I want to make a website. What should I do?
ASP .NET MVC. Don't use ASP .NET WebForms. WebForms was an interesting attempt by Microsoft to make developing web applications closer to developing desktop applications. It didn't really accomplish that, and at this point it really just gets in the way of writing modern, dynamic sites.

I want to make a desktop application. What should I do?
WPF. Make sure you follow the Model-View-ViewModel (MVVM) pattern. Don't use WinForms. The WinForms architecture practically forces you to mix your presentation logic with your business logic, which is never a good thing.

I want to make a "Modern UI"/Metro/Windows Store application!
See above, but also look at Microsoft's Windows Store site.

I want to write a mobile app for iOS or Android!
Xamarin

I want to do some sort of stuff involving a database!
Manually writing queries is for suckers! Use an ORM, but not LINQ to SQL. LINQ to SQL is dying/dead.
Microsoft's replacement is Entity Framework. Personally, I prefer NHibernate, but both are better than LINQ to SQL.

Also,

ShaunO posted:

If you absolutely have to write ad-hoc queries, your queries don't map well to a full-blown ORM, your application is so small can't justify using a full-blown ORM, or you want to query some other IDbConnection provider. Friends don't let friends use DataTables or reinvent the wheel, use dapper.

I want to run my .NET stuff on a non-Windows OS!
Mono is an open-source implementation of the CLR for non-Windows OSes.

Should I be writing unit tests?
Yes! There are some links to a few different unit testing frameworks in this post, but don't worry too much about which one you choose. Writing testable code is harder than writing test code, and the frameworks are all pretty similar to one another.

Books/References
General

Unit Testing
  • The Art of Unit Testing (Osherove)
  • Dependency Injection in .NET (Seeman)

Frameworks/Tools
  • NuGet - Microsoft's package manager. It's built into modern versions of Visual Studio and it makes finding, installing, and configuring third-party libraries a breeze. You can also set up your own NuGet server for distributing internal libraries, if you want!
  • Autofac, an IoC container for .Net. Getting started guide.
  • Automapper. AutoMapper is a neat little tool to help mapping one object to another.
  • Elmah (Error Logging Modules and Handlers), an application-wide error logging facility for ASP.Net. Here's a list of guides and articles.
  • FluentValidation, a validation library that uses a fluent interface and lambda expressions for building validation rules for your business objects.
  • Json.NET, JSON serialization and deserialization
  • NUnit, a different unit testing framework
  • XUnit, yet another unit testing framework
  • SpecFlow, a behavior-driven development tool -- define a domain-specific language, map your language to test actions, then write your tests in plain English! This is great when you're working on a complex system that requires extensive validation from non-developers. A BA can help you write your tests, and then bugs are their fault!
  • Sandcastle/Sandcastle Help File Builder - A toolset that will turn all those documentation comments into actual documentation. Sandcastle generates intermediate files from the comments, and SHFB turns the intermediate files into final outputs that can also include conceptual content (tutorials, overviews, etc.). Multiple targets are supported, and you can use it standalone or with a convenient Visual Studio plugin. It works best with C# and VB.NET, but F# is mostly doable with some tweaking.

Visual Studio Plugins
  • ReSharper - General code inspection/analysis/refactoring. Highly recommended, but not free!
  • GhostDoc - Generates useful XML comments for your methods, you just fill in the blanks. Pretty great if you're working on any sort of public-facing API.

Thanks to Drastic Actions, mortarr, Dust!!!, ShaunO, Dr. Poz, Knyteguy, GrumpyDoctor, and Destroyenator, wwb, and other people I probably forgot to include here for suggestions and links!

New Yorp New Yorp fucked around with this message at 00:08 on Apr 17, 2015

Adbot
ADBOT LOVES YOU

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
Update: 11/12/2014: VS2015, C#6/VB14, .NET 2015

ljw1004 posted:

Plug:

We launched "VS2015 Preview" today: download

For .NET, it's going completely open source. The .NET team will do their development (checkins, bugs, ...) all in the open. If for whatever reason you wanted to package up your own tweaked version of System.Xml.dll with your app, say, you'll be able to do that.

For WPF, it has a solid roadmap for the future.

For VB/C#, here are complete lists of all new language features in C#6 and VB14.

Here in the VB/C#/.NET teams we're pretty excited! We'll writing more on the .NET blog, C# blog and VB blog, once we have time to write it in the coming weeks :)



EDIT: Got to mention the new VS2013 Community Edition. It's free, and a major step up from the "express" editions - kind of like the "Pro" version of VS, also allowing VS extensions. It's free for any non-enterprise application development.

New Yorp New Yorp fucked around with this message at 17:50 on Nov 12, 2014

raminasi
Jan 25, 2005

a last drink with no ice
How do GhostDoc and Sandcastle/SHFB compare?

Mr. Crow
May 22, 2008

Snap City mayor for life
(from old thread)

zerofunk posted:

Has anyone ever had issues with different results from using the VS 2012 Test Runner and running mstest.exe from the command line? We have some Automapper Exceptions thrown due to some type mismatches (silly things like float -> double, and int? -> int). These are causing test failures if I run our tests from mstest.exe. When I run directly from VS2012, everything passes. I'm not even sure where to start in figuring out why that is happening.

Could be that VS is using one set of Test Settings and running via command line you're using a different (default/none) set of Test Settings.

Yet another reason to not use MSTest for unit testing.

edit: You can check if VS is using one in the Test -> Test Settings menu.

zerofunk
Apr 24, 2004
Thanks, I'll look into that on Monday. I didn't set all of this up initially, so I'm not really sure what's in the test settings. I've inherited a lot of decisions on this in terms of libraries/frameworks. Thankfully the project is still very new so it's not too difficult to shift directions on some things.

aBagorn
Aug 26, 2004
Has anyone tried out ASP.NET vNext on a Linux/Mac box yet?

Unfortunately I don't have any box to work on right now (can't spin up a VM on the work PC and don't have the RAM to do it at home) but depending on how well it works I'd consider switching up the hosting for my personal site, as well as offering non-windows hosted web applications for people.

Dietrich
Sep 11, 2001

Nice op.

I just had tfs needlessly complicate things for me yet again, so allow me to re-endorse using Git flavored repos. Makes everything much better.

crashdome
Jun 28, 2011

Dietrich posted:

Nice op.

I just had tfs needlessly complicate things for me yet again, so allow me to re-endorse using Git flavored repos. Makes everything much better.

I've never used Git because gently caress command line. Although, I do find TFS a bit confusing at times. I thought Git would be more confusing. Is that not true? Can I seamlessly browse my projects in VS with Git? Can I type a comment in a textbox and push pending changes to Git? I'm a lone developer with a few read-only accounts to my projects.

If so, I'd try setting up a Git repo just to play with. It's just as easy to set up Git in VS online as it is to use their TFS. I just thought I would be forced to use a command line or third party tools to use it?

raminasi
Jan 25, 2005

a last drink with no ice

crashdome posted:

I've never used Git because gently caress command line. Although, I do find TFS a bit confusing at times. I thought Git would be more confusing. Is that not true? Can I seamlessly browse my projects in VS with Git? Can I type a comment in a textbox and push pending changes to Git? I'm a lone developer with a few read-only accounts to my projects.

If so, I'd try setting up a Git repo just to play with. It's just as easy to set up Git in VS online as it is to use their TFS. I just thought I would be forced to use a command line or third party tools to use it?

If you want to anything fancy (e.g. any history rewrites), you'll have to go third-party, but basic commit/push/fetch/branch stuff is done easily within VS.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

crashdome posted:

I've never used Git because gently caress command line. Although, I do find TFS a bit confusing at times. I thought Git would be more confusing. Is that not true? Can I seamlessly browse my projects in VS with Git? Can I type a comment in a textbox and push pending changes to Git? I'm a lone developer with a few read-only accounts to my projects.

If so, I'd try setting up a Git repo just to play with. It's just as easy to set up Git in VS online as it is to use their TFS. I just thought I would be forced to use a command line or third party tools to use it?

I'm not a fan of Git, but every time I talk about why I don't like Git I get dogpiled by people telling me I'm stupid, so I won't get into it. The Git tools in VS2013 are solid. They're not great, but they're usable and getting better with every update. Doesn't hurt to try it... just open up the Team Explorer and add a new repo, and you should be off and running.

If you have any TFS questions, you can PM me or ask here... I know TFS like the back of my hand.

Gul Banana
Nov 28, 2003

crashdome posted:

I've never used Git because gently caress command line. Although, I do find TFS a bit confusing at times. I thought Git would be more confusing. Is that not true? Can I seamlessly browse my projects in VS with Git?
not from within VS, no. if you open a solution that's within a git repository it detects it and opens the repo in VS, so that's what i do.

quote:

Can I type a comment in a textbox and push pending changes to Git? I'm a lone developer with a few read-only accounts to my projects.
yes, commits merge pushes all work.

the vs git integration was not great until recently, but in 2013 i like it a lot

crashdome
Jun 28, 2011
OK, thanks everyone. I don't want to cause a rift but, I just never heard or saw anyone talk about how easy Git was. Only that it was "better" and then spout about command line this and command line that. I will try it out. Right now, environmentally TFS might suit me better. Although, I do want to not appear stupid when confronted with a Git repo in the future either.

Personally, TFS seems ok to me. I like having a connection to my VS online account and can see and manipulate projects and workspaces without leaving VS. Although, I do not connect to any other TFS server and do not have to split projects or work across multiple repos. The only thing that confused me about TFS was I got a new device, loaded up VS2013, and promptly got lost setting up ONE workspace in a custom located local folder for a few related projects. I managed to work it out but, the UI is confusing for server connections (and don't get me started on logging out and logging in as another user). However, UI design overall seems great - once you are setup.

Mr Shiny Pants
Nov 12, 2012
Get the Git Extensions and download the sourcecode provider for VS.

Works pretty much as it should.

WHERE MY HAT IS AT
Jan 7, 2011
Pretty sure the thread title should be await GetGoodPostsAsync() :colbert:

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

WHERE MY HAT IS AT posted:

Pretty sure the thread title should be await GetGoodPostsAsync() :colbert:

async/await introduces just as many issues as it solves imo

Quebec Bagnet
Apr 28, 2009

mess with the honk
you get the bonk
Lipstick Apathy

GrumpyDoctor posted:

How do GhostDoc and Sandcastle/SHFB compare?

Theyre different things entirely :confused: Sandcastle compiles the inline documentation to a set of web pages or whatever. As far as I can tell, GhostDoc is good for automatically writing a comment stating that GetButts() gets the butts. Did they add compilation or something?

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Malcolm XML posted:

async/await introduces just as many issues as it solves imo

What issues does it introduce?

raminasi
Jan 25, 2005

a last drink with no ice

chmods please posted:

Theyre different things entirely :confused: Sandcastle compiles the inline documentation to a set of web pages or whatever. As far as I can tell, GhostDoc is good for automatically writing a comment stating that GetButts() gets the butts. Did they add compilation or something?

According to the website the Pro version will do it. After reading a little bit more I think I just don't understand what's useful about being able to automatically infer that GetButts() gets butts, but to each their own I guess :shobon:

And while we're on the subject, maybe SHFB should be in the OP?

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

Ithaqua posted:

What issues does it introduce?


Stupid things like configure await and having to manually spill variables (!!!!) to reduce allocations is just tedious

Also it conflates a CPS rewriting sugar (await) with parallelism which honestly is more confusing. Something along the lines of haskell async or parallel might have been cleaner

I just don't think it's at all clear how async await works behind the scenes and how much control you have over it: the actual generated code is not even CPS it's a funky state machine with a bunch of gotchas.

It needs some nicer combinators and good spec of its semantics

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
I really like what async/await gives you, but I do agree that there are some nasty hidden gotchas. My main complaint is that you're not able to easily call an async method synchronously. Doing that is basically a recipe for deadlocks, but what option do I have if I'm not running in an async ready context (e.g. console app)? This forces most libraries to expose both synchronous and asynchronous method calls which just pollutes their APIs. If calling asynchronous methods synchronously was easy then we could get rid of this silly *Async duplicate method convention and just expose async methods.

ATM Machine
Aug 20, 2007

I paid $5 for this
Visual Studio question: I'm curious as to whether there is a productivity extension that replicates Sublimes' features like line duplication, control+d selection searching, or multiple editing locations.

What I'm asking for is a Sublime flavoured Visual Studio. After working with Sublime for so long I really miss being about to ctrl+d a variable or string or whatever, then tap an arrow key to start typing after all of them at once. I was a big fan of being able to highlight something then type in a brace of some sort, and it'd put one either side of the selection.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

ATM Machine posted:

Visual Studio question: I'm curious as to whether there is a productivity extension that replicates Sublimes' features like line duplication, control+d selection searching, or multiple editing locations.

What I'm asking for is a Sublime flavoured Visual Studio. After working with Sublime for so long I really miss being about to ctrl+d a variable or string or whatever, then tap an arrow key to start typing after all of them at once. I was a big fan of being able to highlight something then type in a brace of some sort, and it'd put one either side of the selection.

ReSharper does that kind of stuff.

RICHUNCLEPENNYBAGS
Dec 21, 2010

Bognar posted:

I really like what async/await gives you, but I do agree that there are some nasty hidden gotchas. My main complaint is that you're not able to easily call an async method synchronously. Doing that is basically a recipe for deadlocks, but what option do I have if I'm not running in an async ready context (e.g. console app)? This forces most libraries to expose both synchronous and asynchronous method calls which just pollutes their APIs. If calling asynchronous methods synchronously was easy then we could get rid of this silly *Async duplicate method convention and just expose async methods.

What's wrong with Task.RunSynchronously or even just Result? Well, I mean, what's wrong that some other syntax would fix?

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

RICHUNCLEPENNYBAGS posted:

What's wrong with Task.RunSynchronously or even just Result? Well, I mean, what's wrong that some other syntax would fix?

If you have async code and try to use it synchronously, Bad Things can happen in the form of deadlocks; the async code just waits for something that's never going to happen because everything else is held up waiting for the task to complete. Of course it all depends on the synchronization context... a console app will be fine because it has no synchronization context, it just passes it off to the task scheduler.

[edit]

Even though Stephen Cleary irks me on a personal level, he knows this poo poo inside and out and explains it really well:

http://msdn.microsoft.com/en-us/magazine/jj991977.aspx

New Yorp New Yorp fucked around with this message at 07:48 on Jun 21, 2014

RICHUNCLEPENNYBAGS
Dec 21, 2010

Ithaqua posted:

If you have async code and try to use it synchronously, Bad Things can happen in the form of deadlocks; the async code just waits for something that's never going to happen because everything else is held up waiting for the task to complete. Of course it all depends on the synchronization context... a console app will be fine because it has no synchronization context, it just passes it off to the task scheduler.

[edit]

Even though Stephen Cleary irks me on a personal level, he knows this poo poo inside and out and explains it really well:

http://msdn.microsoft.com/en-us/magazine/jj991977.aspx

Yeah, but I don't see an easy fix for that.

Gul Banana
Nov 28, 2003

The 'easy fix' is typically to ConfigureAwait(false) so that you don't get marshalled onto a blocked context. however it's irritating and gives up many of the actual benefits of async.

The 'right fix' is that async code should be top-down, not bottom-up. The requirement to use async apis is an asynchronous event loop. Such as: WPF event-handing "async void"s, or ASP.NET actions. if you don't have one of those available, you have to return Task yourself; it can't be safely encapsulated. People get in trouble when they try to use async methods *internally* to implement a non-async thing. Even given that constraint, await is pretty fantastic.

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

Gul Banana posted:

The 'easy fix' is typically to ConfigureAwait(false) so that you don't get marshalled onto a blocked context. however it's irritating and gives up many of the actual benefits of async.

The 'right fix' is that async code should be top-down, not bottom-up. The requirement to use async apis is an asynchronous event loop. Such as: WPF event-handing "async void"s, or ASP.NET actions. if you don't have one of those available, you have to return Task yourself; it can't be safely encapsulated. People get in trouble when they try to use async methods *internally* to implement a non-async thing. Even given that constraint, await is pretty fantastic.

They tried to get monads in the language with linq and it was ok but I have rarely seen generators (and the difference between Ienumerator and ienumerable is subtle and almost always you actually want the former)

Now they've gotten a monad that isn't really a container and in order to sneak it in without the ability to have do-notation they put in await which manually performs CPS and then optimizes it out by using a state machine analogous to yield return

But manually implemented generators are extremely rare--everyone usually uses the combinators from linq instead and uses icollection as the base

In this case everyone has to deal with the gotchas of implemented async generators via await since the libraries aren't rich enough and there isn't enough power to have monad manipulation defined generically

And then there's synch context which is really goddamned subtle and even Jon loving skeet says he doesn't really understand it so how do you expect workaday devs to diagnose why deadlocks are happening in something they were sold as the best asynchronous pattern?

I wanna say if they dropped the async void compat layer and made it so that async behaved more like Haskell async by using speculative parallelism it might be better

Gul Banana
Nov 28, 2003

that would require investing any money in WPF ever again, though. so it ain't gonna happen

Gul Banana
Nov 28, 2003

for the other stuff it's like.. you're totally right that this stuff is not correctly generalised as it could be if they'd just put a little more mathematics into it. linq overall reads as a *rediscovery* of monads, to the point that using SelectMany as bind/>>= is needlessly obtuse. however: there's an alternative case to be made that it's a useful extraction of the common-case benefits into comprehensible patterns.

*IF* you accept the premise that M[a] is too hard for many developers, then the list monad in the form of IEnumerable<a> is a great compromise. collections cover a lot of stuff! collections with generators cover more - it's rare for people to use interesting generators, but being able to do this sort of thing

code:
class HasOneThing : IHasManyThings {
    IEnumerable<Thing> GetTheThings {
       yield myOneThing;
    }
}
is still great. async and await, if only they didn't have the danged context wart, really are a great simplification over callbacks, and the Task<T> abstraction has proven itself.

there's evidence out there. note that Scala, which already had Future and generalised do-notation, added async & is chatting happily about it. heck in .net we already had Linq 2 Tasks, weird as it was. i've seen people write this:

code:
var result = from x in GetXAsync()
              from y in GetYAsync(x)
              select CreateResult(x, y);
and i was not particularly happy to see it, but, it did work. await works better, works clearer.

Gul Banana
Nov 28, 2003

so with List and Future you have maybe 90%, 99% of the monadic power that Joe Applicationdeveloper can really use. each gets its own special case syntax. for that matter so does IO, which has "the assignment operator". Microsoft's implicit argument here is that by addressing each of these use cases as its EROI becomes high enough, they're frogmarching the world forward as fast as it will grumbly-shuffle. until someone comes up with a piece of software that doesn't need to be maintained, idk that we have proof otherwise.

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

Gul Banana posted:

so with List and Future you have maybe 90%, 99% of the monadic power that Joe Applicationdeveloper can really use. each gets its own special case syntax. for that matter so does IO, which has "the assignment operator". Microsoft's implicit argument here is that by addressing each of these use cases as its EROI becomes high enough, they're frogmarching the world forward as fast as it will grumbly-shuffle. until someone comes up with a piece of software that doesn't need to be maintained, idk that we have proof otherwise.

well clearly not, since they're adding the chained null thing which is the Maybe/Option monad

is there anything against dumping classes and only using nullable structs?


Gul Banana posted:

so with List and Future you have maybe 90%, 99% of the monadic power that Joe Applicationdeveloper can really use. each gets its own special case syntax. for that matter so does IO, which has "the assignment operator". Microsoft's implicit argument here is that by addressing each of these use cases as its EROI becomes high enough, they're frogmarching the world forward as fast as it will grumbly-shuffle. until someone comes up with a piece of software that doesn't need to be maintained, idk that we have proof otherwise.

Try using both at once. It's a clusterfuck and you actually need monad transformers to deal with it properly.

They basically tried to hide the theoretical complexity but in doing so opened a giant can of worms. Explict > implicit and unless there is a very clear way of translating from implicit to explicit ( do-notation is basically just (>>=) and lambda-binding) there's gonna be problems

F# had async workflows, which are really nice and much better for a lot of async stuff than the TAP :http://tomasp.net/blog/csharp-async-gotchas.aspx/

lcw014 or w/e get in here and explain yourself

redleader
Aug 18, 2005

Engage according to operational parameters

Malcolm XML posted:

the difference between Ienumerator and ienumerable is subtle and almost always you actually want the former

Any chance you could elaborate on this?

ShaunO
Jan 29, 2006

aBagorn posted:

Has anyone tried out ASP.NET vNext on a Linux/Mac box yet?

Unfortunately I don't have any box to work on right now (can't spin up a VM on the work PC and don't have the RAM to do it at home) but depending on how well it works I'd consider switching up the hosting for my personal site, as well as offering non-windows hosted web applications for people.

I'd be interested if you do get this working. I have the latest master of mono running fine but I'm having issues with the K runtime and running kpm restore against the web-based samples. Just weird mono exceptions and x509 certificate errors when trying to retrieve the AspNet hosting related libraries - even though I've trusted all of the right SSL certs, as far as I know. https://github.com/aspnet/home - with these samples, I was able to get the console app working fine with kpm restore, but the web samples just throw a poo poo fit. I've given up for now, I tried the mono IRC channel for help but it's dead and am not sure where to go from there, maybe I'll log an issue on that github project.

I tried using this prebuilt docker image https://registry.hub.docker.com/u/akoeplinger/mono-aspnetvnext/ as well but have exactly the same issues, though my own environment is pretty much the same anyway, so not surprising but it looks like it's only been broken for the past couple of weeks.

ShaunO fucked around with this message at 01:19 on Jun 22, 2014

Gul Banana
Nov 28, 2003

list+future IS a real problem. at that point you need IObservable, which is sort of half built-in to the language and doesn't follow the same api conventions...

my only defense of .NET there is "many programs don't need it". but one of my current projects does, and suffers from the lack ;_;
it's an ORM which hasn't been able to move to a fully asynchronous read-side API, because that doesn't compose with IQueryable. even internally it has problems needing to do things like reify sequences into lists so that disposal of db handles can take place - unnecessary data copies b/c the streaming and iterating abstractions don't compose with the deferral and concurrency abstractions :(

Gul Banana fucked around with this message at 07:52 on Jun 22, 2014

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

redleader posted:

Any chance you could elaborate on this?

code:
var x = Enumerable.Range(1,10)

foreach(int i in x.Take(5)) { Console.WriteLine(i);}
foreach(int i in x.Take(5)) { Console.WriteLine(i);}

This prints 1..5 and 1..5 as opposed to 1..5 and then 6..10 because IEnumerable is a factory for IEnumerator, which carries the state (and needs to be pumped manually via MoveNext).

I really am not sure why they chose having the factory being the primary part of the foreach loop and LINQ but it means that it's a pain in the rear end to handle delimited chunking efficiently (or as far as I can tell at least)

Volte
Oct 4, 2004

woosh woosh
I'm not even sure in what kind of nightmare land you'd want iterating over the same collection twice in a row to print two different results. IEnumerator is the iterator for IEnumerable. Iterators are mutable even when the enumerable isn't, which is why it makes no sense to expect any sort of consumer state to be encoded in the enumerable. foreach creates a new iterator (IEnumerator). If you want to use the same enumerator across multiple loops (i.e. for chunking), create it yourself before the loops and use the MoveNext method manually.

edit: also for LINQ it wouldn't be that hard to write a collection wrapper that does chunking for you implementing IEnumerable.

Volte fucked around with this message at 14:20 on Jun 22, 2014

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

Volte posted:

I'm not even sure in what kind of nightmare land you'd want iterating over the same collection twice in a row to print two different results. IEnumerator is the iterator for IEnumerable. Iterators are mutable even when the enumerable isn't, which is why it makes no sense to expect any sort of consumer state to be encoded in the enumerable. foreach creates a new iterator (IEnumerator). If you want to use the same enumerator across multiple loops (i.e. for chunking), create it yourself before the loops and use the MoveNext method manually.

edit: also for LINQ it wouldn't be that hard to write a collection wrapper that does chunking for you implementing IEnumerable.

The factory-ness of ienumerable is fine, it's just that it doesn't make a lot of sense to iterate over a factory. I would rather you have to call GetEnumerator and then have to pass that enumerator to the foreach loop, to make the forcing explicit.

The point is that the iterator encodes the current state. If you want to get another view of the collection, you call GetEnumerator which makes the "Reset" explicit.

And then you make collections immutable like they ought to be :getin:

Volte
Oct 4, 2004

woosh woosh

Malcolm XML posted:

The factory-ness of ienumerable is fine, it's just that it doesn't make a lot of sense to iterate over a factory.
I don't see why. An object is enumerable if and only if it is a factory which can create an enumerator for itself, so by that definition it only makes sense to iterate over a factory. It makes even less sense to iterate over an iterator in my opinion.

It's such an unusual situation to have to reuse an iterator over multiple loops that I don't see why just converting your foreach loops into regular for or while loops using explicit iterators is such a big deal.

Also,
C# code:
public class IteratorView<T> : IEnumerable<T> {
    private readonly IEnumerator<T> enumerator;

    private IteratorView(IEnumerator<T> enumerator) {
        this.enumerator = enumerator;
    }
 
    public static IteratorView<T> FromEnumerable(IEnumerable<T> enumerable) {
        return new IteratorView<T>(enumerable.GetEnumerator());
    }

    public static IteratorView<T> FromEnumerator(IEnumerator<T> enumerator) {
        return new IteratorView<T>(enumerator);
    }

    public IEnumerator<T> GetEnumerator() {
        return this.enumerator;
    }

    IEnumerator IEnumerable.GetEnumerator() {
        return this.enumerator;
    }
}
C# code:
var x = IteratorView<int>.FromEnumerable(Enumerable.Range(1,10));

foreach (int i in x.Take(5)) { Console.WriteLine(i); }
foreach (int i in x.Take(5)) { Console.WriteLine(i); }

// Prints 1 through 10

Deus Rex
Mar 5, 2005

Ithaqua posted:

Should I be using source control?
Yes!
  • Team Foundation Server Express is free for up to 5 developers.
  • Visual Studio Online is cloud-hosted TFS.
  • Or you can use Github or SVN or something else, just use source control for the love of God. VS2013 has native tools built in for Git, and VSO/TFS2013 both support Git source control.

Let's be clear about what you're saying here - TFS is free up to 5 developers until you have to purchase a support contract from some TFS consultant to figure out how to make it work.

Adbot
ADBOT LOVES YOU

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Deus Rex posted:

Let's be clear about what you're saying here - TFS is free up to 5 developers until you have to purchase a support contract from some TFS consultant to figure out how to make it work.

No?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply