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
No Safe Word
Feb 26, 2005

Chasiubao posted:

What's everyone's opinion on the var keyword? I'm in the middle of a religious discussion on code reviews.

Team 1 has no hard and fast rules: use var where it makes sense, for super long nested generics, etc.

Team 2 insists that it should only be used when the type is immediately discernible from the rhs.

Use var like all the time basically. (Both teams are correct, and it should almost always be immediately discernible from the RHS or you should consider refactoring)

Adbot
ADBOT LOVES YOU

No Safe Word
Feb 26, 2005

GrumpyDoctor posted:

Is there a way to get more detailed information about what's causing a TypeLoadException? I know the type it can't find, but I haven't the faintest idea why it can't find the type, and I'm pulling my hair out trying to figure out what's going on.

It's always a binding redirect :v:

No seriously, whenever it hasn't been some NuGet package (or rogue developer) doing something stupid with binding redirects, I've been able to fairly easily step through the normal places .NET looks for poo poo and figure it out manually, but we also don't do much mucking about with assembly loading.

No Safe Word
Feb 26, 2005

Telerik's JustDecompile is pretty good too but by god if they aren't getting annoying with some of their nagware-like stuff. Hard to grouse about a free tool, but it used to be way less annoying :(

No Safe Word
Feb 26, 2005

NihilCredo posted:

Speaking of using{}, if a using (foo) {} block lasts until the end of the method, is it in any way different from just declaring foo as a local variable?

Yes, if foo has a Dispose defined and an exception is thrown in that block/scope, the using version will invoke the Dispose method and the other will not.

Conceptually speaking (and maybe in actual compiler mojo), using is syntactic sugar for:

code:
var foo = ...;
try 
{
		
}
finally
{
   foo.Dispose();
}

No Safe Word
Feb 26, 2005

Use VsVim and write a vim macro to do it :getin:

No Safe Word
Feb 26, 2005

Brady posted:

Will this work if it's not a file, but a directory instead? Unable to test right this moment but I'm gonna try this and GI_Clutch's solution when I can. Thanks guys.

The docs explicitly state that you get an empty string if it's a directory.

No Safe Word
Feb 26, 2005

epalm posted:

Or looking at your own code 2 years later and asking what the gently caress you were thinking :v:

2 years? More like 2 days or 2 hours :v:

No Safe Word
Feb 26, 2005

Boz0r posted:

I just upgraded from Visual Studio 2013 to 2015, and I'm missing a feature. In a small line above each class and function definition, it mentioned how many references to the function, who created it, and a little more. I also have ReSharper installed, and I don't remember installing anything else in 2013. Anyone know what I'm talking about?

it's called codelens if that helps, it was built-in to visual studio but I immediately turned it off :v:

No Safe Word
Feb 26, 2005

Mr Shiny Pants posted:

I did this one as well, the problem with it is that it doesn't teach why you do stuff only how to do stuff.

And it doesn't even really do that because the actual best way to get the cert is the answer dump. Even with a fair amount of experience in the subject area, the tests still have a decent amount of random esoteric crap that you might not have ever encountered.

No Safe Word
Feb 26, 2005

ToxicSlurpee posted:

Computers are basically expensive hammers. They're tools suited to specific tasks.
This is like the worst possible analogy. Computers are general-purpose machines. Hammers are one-purpose machines. Digital computers are suited to a specific class of problems I suppose, it's just that class of problems is: "ones that can be digitized and input". Coincidentally that covers a REALLY LARGE problem space.

No Safe Word
Feb 26, 2005

Calidus posted:

Anyone have experience with Visual Studio online? I want to put my visual studio 2010 installation out to pasture, but buying TF for 2 to 3 developers seems kinda stupid. I was also debating on switching over to git, this projects to immgrate looks pretty nice: https://github.com/git-tfs/git-tfs

git-tfs is pretty decent but if you have a fair amount of branch history and/or have done any nontrivial branching/reparenting or otherwise futzing with the hierarcy, git-tfs will straight up fail. I wanted to do the same but just couldn't. But if it's a relatively simple repository, it works quite well.

No Safe Word
Feb 26, 2005

Windows 10 is completely fine for .NET 4.x development, we have several guys at work who have updated their machines and there's been zero issues.

No Safe Word
Feb 26, 2005

Ithaqua posted:

Learn C# instead. You can do basically all the same things in either language and the standard library is the same, but there are tons more jobs in C#.

Also it'll be way easier to learn since he already knows Java/C++

No Safe Word
Feb 26, 2005

Dr. Poz posted:

We upgraded to VS2015 today! Happy Day! Question: Looking over the Git integration features, it seems like Visual Studio automatically stages all changes. Is this the case? Is there any way to disable this behavior?

VS doesn't stage anything until you're actually committing and AFAIK there's no way to actually stage stuff either. For this and several other reasons, I've fallen back to using the git bash terminal with occasionally jumping to Sourcetree for multi-branch management and visualization needs. The integrated stuff I do use is nice though (cloning a repo, displaying the current branch, and.. that's it). Glad they're embracing git but it's still not good enough inside the IDE for me to throw aside my external tools :eng99:

No Safe Word
Feb 26, 2005

Dr. Poz posted:

So if I'm understanding correctly, the files are not actually staged (i.e. I hit the command line, type "git status" and my modifications aren't staged) but them being "Included" means that if I commit from withing VS that it will stage/commit all "Included" files in a one step process. Is that right?

Here, a blank solution in a new repo (I added the .sln file and as the first commit before taking this screenshot, hence the lock and not the green plus):


I added a text file to the solution, typed some text in it, and saved the text file and the solution (Save All), this is what shows in the git command line:


And this is what it looks like in the "Changes" window:


So it's in the "included" section even though it's not staged, which is confusing. You can manually add them with git add and that display doesn't change.

So I just prefer to use the command line now :v:

No Safe Word fucked around with this message at 23:24 on Jan 13, 2016

No Safe Word
Feb 26, 2005

epalm posted:

Zero.


Still takes a long time. Close to a minute.


Standalone PC. Windows 7, MS Security Essentials. My co-workers are working on the same code from the same repository, and they don't have this issue.

Edit: this is going to be one of those "I suggest you re-install your entire operating system" scenarios isn't it.

This all reads like something that should be submitted to Mark Russinovich for his "Case of the Unexplained" series that he presents at every TechEd: https://technet.microsoft.com/en-us/sysinternals/bb963887.aspx

Honestly, you could go watch some of those and maybe get an idea of how to troubleshoot it. To nobody's surprise a lot of them hinge around running SysInternals tools :)

No Safe Word
Feb 26, 2005

epalm posted:

I downloaded and ran Process Monitor, and then ran the ASP project. PM collected 500,000 events. I don't know what's signal and what's noise, but I'm combing through it to see if anything sticks out. I'm actually looking for a line that says "check this checkbox in Visual Studio to solve your specific problem" :)

Edit: a lot of the procmon data seems to be related to files in C:\FusionLogs :confused: no idea what that folder is, or does. The hunt continues.
That's apparently some standard .NET assembly binding failure logging thing. There's a viewer app for it as well, so looking in there may tell you why you're having assembly binding issues.

No Safe Word
Feb 26, 2005

ProcMon wins again! Seriously the SysInternals stuff is kinda ugly and busy but super freaking useful. Process Explorer has been my Task Manager replacement since Ye Olde WinXP days.

No Safe Word
Feb 26, 2005

redleader posted:

We mostly follow the MS guidelines, but use K&R-style braces rather than Allman. I kinda like it.

Yeah we mostly follow them with this exception plus we pretty much always use interpolated strings now instead of using string concatenation basically ever since we're using C# 6.

No Safe Word
Feb 26, 2005

Malcolm XML posted:

Service bus is a clusterfuck and does not scale well

[[citation needed]]

We've run some preliminary performance tests and it has held up okay, what about it doesn't scale well?

No Safe Word
Feb 26, 2005

Malcolm XML posted:

It's based on SQL server internally and has all the issues that brings when dealing with thousands+ events a second especially the whole noisy neighbor thing that wrecks cloud sql

Also some of the guarantees it offers are not easily scaled across data centers and failure domains compared with the relaxed guarantees of azure queues which force you to not rely on them (distributed locking is subtle and hard)

That said u can use it for slow and small data

Did you try using express queues/topics? https://azure.microsoft.com/en-us/documentation/articles/service-bus-performance-improvements/#express-queues-and-topics

No Safe Word
Feb 26, 2005

gariig posted:

Generally Allman style (the one from Unity) because it is Microsoft's default within Visual Studio. Programmers Stackexchange has some info on it and why it might be.

Be consistent is most important but if you want K&R style braces you are going to be fighting an uphill battle against Visual Studio defaults

It's not difficult at all to tell Visual Studio to format things differently. But having it consistently actually follow the rules you set, on the other hand, is indeed an uphill battle.

Of note, in 22 Eargesplitten's example, the default Visual Studio style actually doesn't put spaces between function names and the parens for the args. So that looks like a custom style rule being applied.

You can change it in the Text Editor settings for each language under Tools > Options

No Safe Word
Feb 26, 2005

In this thread?

code:
string foo;

No Safe Word
Feb 26, 2005

Bognar posted:

For your enjoyment, I downloaded and grepped the entire reference source for "----":

http://pastebin.com/zegbjEtQ

Some of my favorites:

code:
/// We occ----ionally need a no-op enumerator to stand-in when we don't have data left

Clbuttic

No Safe Word
Feb 26, 2005

bing_commander posted:

I'm looking for a C# book. Is the recommendation in the op still up to date?

I like Lippert's Essential C# personally

No Safe Word
Feb 26, 2005

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.


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.
Because when you have to convert

code:
Foo SomeMethod(...)
{
    Foo foo = ...;
    ...
    return foo;
}
and there's nothing in SomeMethod that is actually await-able, you can just do this:


code:
Task<Foo> SomeMethod(...)
{
    Foo foo = ...;
    ...
    return Task.FromResult(foo);
}
Note that if you actually do have stuff you can await it just becomes:

code:
async Task<Foo> SomeMethod(...)
{
    Foo foo = ...;
    // do awaitable stuff
    return foo;
}
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.

No Safe Word
Feb 26, 2005

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 :haw:

No Safe Word
Feb 26, 2005

ljw1004 posted:

cool stuff including the Channel 9 series I watched all of

Thanks for this, it's already driving some changes in our library code at my work. One question though: what do you do in the cases where you are implementing an interface or an abstract method that is async by design because in the cases where the implementers can use async/await, doing so is very useful, but there are cases where some cannot reasonably do any truly asynchronous stuff? Obviously shoe-horning things into a Task is a big time red flag as you referenced in your 4th tip.

So, for example, we have a custom logging library that has a bunch of different targets (console, file system, Azure blob storage, etc.), so we have an asynchronous interface:

C# code:
interface ILogger
{
    Task LogMessageAsync(string message);
}
(some simplifications/omissions, of course)

For the Azure and file system loggers, there are natural Async methods we can await, but for the console one there's not:
C# code:
public Task LogMessageAsync(string message)
{
    Console.WriteLine( ... );   // nothing to await and no Console.WriteLineAsync call
}
Obviously, that method is "fine" and will compile, but we treat warnings as errors so it actually doesn't compile in our solution without suppressing the warning :v: But really, what do you do in these scenarios? Is wrapping in Task.Run so bad here?

No Safe Word
Feb 26, 2005

Destroyenator posted:

Untested, but I think this would do it?
C# code:
public Task LogMessageAsync(string message)
{
    Console.WriteLine( ... );   // nothing to await and no Console.WriteLineAsync call
    return Task.FromResult(0);
}

Well yeah the other (and probably better?) version would be:

C# code:
     return Task.CompletedTask;
But it's "shoe-horning" task stuff in there and the call is still actually synchronous.

No Safe Word
Feb 26, 2005

PSA: ILSpy is just way better than Telerik's JustDecompile and it isn't nagware

No Safe Word
Feb 26, 2005

The Wizard of Poz posted:

Real quick informal poll:

Of the devs who work on a VM, what are your experiences with it? What kind of resources do you have available within the VM?

We're having a lot of trouble getting our VMs up to speed here and I'm hoping for some advice. We develop mostly web apps, and starting up the MVC projects in debug seems to take forever on our VMs. Even just opening the projects seems to take far too long. Is Visual Studio just a slow IDE, or is it likely that it is straining for resources?

It's easy enough to find bare minimum system requirements for this kind of thing, but getting actual real world "This is what you would actually WANT to have" figures is tricky.
Until a role shift that doesn't require nearly as much time in Visual Studio I was spending 100% of my time in a Virtualbox VM with the following specs:
- 10GB of virtual RAM (the laptop has 16GB)
- allowed to use all 4 cores, with an execution cap of 100%
- running Windows 10, VS 2015
- network was actually plumbed through 3 different interfaces: 1 pure NAT, 1 bridged directly to the wired ethernet, 1 bridged directly to wireless (I mostly kept the latter two disabled but if I needed to I would disable/enable from within Windows and it worked like a charm)
- 150GB VDI disk

This is on a relatively recent laptop (~2 years old now):
- i7 5600U 2.6GHz, quad core
- 500 GB SSD

The base OS is running Debian Jessie.

The performance was pretty good. Not amazing, but pretty good. I was able to drive all three screens via three separate VBox screens which was nice. It flipped out when I docked/undocked fairly regularly though. Rebooting the VM fixed it though.

No Safe Word
Feb 26, 2005

code:
static void Main(string[ ] args)
{
    double? a = 10;
    double? b = null;
    var c = a - b;
    Console.WriteLine(c);
}
What's the rationale behind the result here?

The result is null

No Safe Word
Feb 26, 2005

B-Nasty posted:

I'd still recommend AzureSB in cases where using cloud stuff is allowed. The basic level should cost you less than a few dollars a month, and the 'standard' level is about $10/month (assuming always on) and includes topics and other advanced functionality. Self-hosting Rabbit with redundancy may end up costing more in time+hardware costs.


Of all the Azure infrastructure pieces I use at work, Service Bus is probably the best of them (Cosmos DB is pretty good too, in spite of its stupid name). Would definitely concur with this. The one thing that is moderately lacking is official tooling for it, though you can do simple stuff in the Azure Portal, and the third party Azure SB Explorer is good enough to do all we need.

No Safe Word
Feb 26, 2005

No Pants posted:

This blog post came out last month, and it's good reading if you have any interest in what ConfigureAwait does.

That's a pretty good article, shared with my team here.

.NET Megathread 3.5: await GetGoodPosts().ConfigureAwait(false)

Adbot
ADBOT LOVES YOU

No Safe Word
Feb 26, 2005

Yeah the (weak) joke was "I don't care what thread good posts end up in just get them there ASAP"

:eng99:

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