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
RICHUNCLEPENNYBAGS
Dec 21, 2010

ether posted:

I'll be THAT guy and say stylecop in itself is a dumb tool that serves no purpose but make peoples lives harder for no real reason. Codereviews are the prime moment to explain WHY you have certain coding guidelines. Still bitter because codereviews where tagged as a waste of time and we got stylecop instead "because it serves the same purpose", loving asshats, and it made most of our legacycode even more obtuse.

Aside from the personal bitterness there are some dumbass rules in stylecop that kill overarching code-structure (encase public/privates/events/etc in regions, alphabetize functions), make code less clear (disallowing a _-prefix for locals, thus making it less clear that you have scoping issues) and mess with 'code' that doesn't get compiled (all the fuckery with HOW you must comment things)

Sure but come on. What discussion is there to be had about whitespace? Everyone else should use the same scheme I'm using because otherwise the commit log shows every line of each file changing. And discussions sometimes become a backdoor way about people whining about your decisions and saying none of this would be happening if you did it their way which gets tiresome.

RICHUNCLEPENNYBAGS fucked around with this message at 01:27 on Jul 7, 2015

Adbot
ADBOT LOVES YOU

Mellow_
Sep 13, 2010

:frog:

RICHUNCLEPENNYBAGS posted:

Sure but come on. What discussion is there to be had about whitespace? Everyone else should use the same scheme I'm using because otherwise the commit log shows every line of each file changing. And discussions sometimes become a backdoor way about people whining about your decisions and saying none of this would be happening if you did it their way which gets tiresome.

People should just adhere to the style the leads say to use.

It's loving terrible to see a commit where every line has changed due to formatting and you have no loving clue what that dev did unless their commit message is rather verbose (it won't be).

RICHUNCLEPENNYBAGS
Dec 21, 2010

AuxPriest posted:

People should just adhere to the style the leads say to use.

It's loving terrible to see a commit where every line has changed due to formatting and you have no loving clue what that dev did unless their commit message is rather verbose (it won't be).

Yes, this is what I want to avoid

uXs
May 3, 2005

Mark it zero!
Has anyone gotten xunit to work with vnext? I have a project in vnext and it doesn't work for me.

Two paths I tried:

Add the test project as a vnext class library, with "Class Library (Package)". Tried to install xunit and xunit.runner.dnx, but when I try to run 'dnx . test' (or dnx . xunit.runner.dnx), I get a nullreference exception. Most likely this is a version conflict between dnx and the xunit version, which I tried to resolve by getting ever more bleeding edge versions of xunit and the dnx libraries it requires, but nothing I tried works.

Other try was to add the test project as a normal class library, and add references to xunit and xunit.runner.visualstudio. This made a bogus test (Assert.True(true);) appear in the VS Test Explorer window, but then I get problems when I try to add references to the other (vnext) projects in my solution. Instead of adding a reference to the project I have to add a reference to the .dll it makes, and I also need references to a bunch of other crap (mostly EF libraries) that start to conflict with each other and make the entire thing refuse to build.

So, anyone able to actually make it work, and if so, how exactly? Preferably completely in vnext.

raminasi
Jan 25, 2005

a last drink with no ice
I have a call to Directory.Delete failing because the directory contains a read-only file. The thing is, the directory is empty. Explorer does report it has having read-only files in it (the "read-only" in the directory properties is in the "partial" state), even though when you examine the directory there's nothing there. (No hidden files, either, and DirectoryInfo.GetFiles returns an empty list.)

To make matters worse, this isn't a one-time problem - my program is creating this weird directory, and I don't know how or why. It's just a straightforward Directory.CreateDirectory call.

e: And just like that, the problem goes away :ghost:

raminasi fucked around with this message at 20:56 on Jul 7, 2015

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION
Working on a pretty large project at the moment that is requiring a lot of thought. We've been exploring CQRS as a possible approach, and it seems to match our needs well, but there are some aspects of CQRS that I'm completely confused about, and none of us can decipher the best-practice ways to handle some of these concerns. For reference, we've been using these articles extensively: https://www.cuttingedge.it/blogs/steven/pivot/entry.php?id=91 and http://www.cuttingedge.it/blogs/steven/pivot/entry.php?id=92

Lets examine the process of updating a Person record, for example. If I want to update a Person record, there may be a couple of associated Address records I also need to update. Obviously this would all be best done within a database transaction so that if one part fails I can roll the whole thing back. With CQRS this operation is broken down into two commands - UpdatePersonalDetailsCommand and UpdateAddressCommand. Both of these are commands that may be useful to run alone, or in combination within a transaction. What is an acceptible way to handle this? I've seen mention of "Aggregate Services" and "Facade Services", which I gather to be classes that can be used for exactly this purpose: depend on a couple of different command handlers, run them in the correct order within a transaction along with any other logic required. The problem with this is that now my code for transaction management is written directly into the Facade:

code:
    public class PersonUpdater : IUpdater<Person>
    {
        private ICommandHandler<UpdatePersonalDetailsCommand> updatePersonalDetails;
        private ICommandHandler<UpdateAddressCommand> updateAddress;
        private IDatabase db;

        public PersonUpdater(ICommandHandler<UpdatePersonalDetailsCommand> updatePersonalDetailsHandler,
                             ICommandHandler<UpdateAddressCommand> updateAddressHandler,
                             IDatabase db)
        {
            this.updatePersonalDetails = updatePersonalDetailsHandler;
            this.updateAddress = updateAddressHandler;
            this.db = db;
        }

        public void Update(Person person)
        {
            db.BeginTransaction();

            try
            {
                var updatePersonalDetailsData = new UpdatePersonalDetailsCommand()
                {
                    Person = person
                };
                updatePersonalDetails.Handle(updatePersonalDetailsData);
    
                if (person.UsualAddress != null)
                {
                    var updateUsualAddressData = new UpdateAddressCommand()
                    {
                        Address = person.UsualAddress
                    };
                    updateAddress.Handle(updateUsualAddressData);
                }
                
                if (person.PostalAddress != null)
                {
                    var updatePostalAddressData = new UpdateAddressCommand()
                    {
                        Address = person.PostalAddress
                    };
                    updateAddress.Handle(updatePostalAddressData);
                }

                db.CompleteTransaction();
            }
            catch
            {
                db.AbortTransaction();
                throw;
            }
        }
    }
As you can see, not only is the logic for a database transaction in the wrong place, it's also creating another dependency which instinctively seems wrong to me. Try not to get too hung up on the specific code in my example (it's just cobbled together for illustrative purposes), my real question is about where to handle the transaction, because throwing it in there with the actual logic to perform the operation seems wrong. I understand this is a complicated question with (probably) a complicated answer, but at this point I'd be happy for just some good links or Google terms to try out.

Iverron
May 13, 2012

I can't say that this will answer any of your questions and you've probably already run across it, but this is the best example of best practices (or implementation even) I've personally found on CQRS:

https://github.com/MarkNijhof/Fohjin

Mr Shiny Pants
Nov 12, 2012

The Wizard of Poz posted:

Working on a pretty large project at the moment that is requiring a lot of thought. We've been exploring CQRS as a possible approach, and it seems to match our needs well, but there are some aspects of CQRS that I'm completely confused about, and none of us can decipher the best-practice ways to handle some of these concerns. For reference, we've been using these articles extensively: https://www.cuttingedge.it/blogs/steven/pivot/entry.php?id=91 and http://www.cuttingedge.it/blogs/steven/pivot/entry.php?id=92


Is the address attribute in the same aggregate root as the person?

If so I would make it one command with all the updates you would need, the command would encapsulate all the changes to the person object including the address changes.

I don't see why you would need to break the transaction up into multiple commands?

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION

Mr Shiny Pants posted:

Is the address attribute in the same aggregate root as the person?

If so I would make it one command with all the updates you would need, the command would encapsulate all the changes to the person object including the address changes.

I don't see why you would need to break the transaction up into multiple commands?

Well a business could also have an address, for instance, and I'd like to avoid repeating the logic for saving addresses. At any rate, that was just an example, basically we have commands that may need to be run alone or as part of a larger process (or as part of multiple processes).

I've been doing some research on aggregate roots, and I think this is the path I need to explore some more.

Mr Shiny Pants
Nov 12, 2012

The Wizard of Poz posted:

Well a business could also have an address, for instance, and I'd like to avoid repeating the logic for saving addresses. At any rate, that was just an example, basically we have commands that may need to be run alone or as part of a larger process (or as part of multiple processes).

I've been doing some research on aggregate roots, and I think this is the path I need to explore some more.

Per my understanding of CQRS and DDD:

The idea is that you have entities in your model (your bounded context) and that these entities are categorized into aggregate roots. These aggregate roots are responsible for every update, create or delete that happens to the entities that they are responsible for. Reading is done from a different source. ( does not have to be, this is up to you )
So let's say you have a person entity in your domain model, you could build an aggregate root that handles all updates, creates and deletes to the person entity. This includes all the properties of the model, including the address because it is a property of a person. You send the command to the aggregate root, it updates the desired entity, and saves the command in the past tense. <- if you use eventsourcing.

You could split this out into multiple commands, you could have updatePersonAddressCommand, or just put them all in one command updatepersoncommand with all the properties you want changed. It is up to the aggregate root to do the necessary updates to the entity. If you use a DB you can create one transaction that does all this in the background.
You could also have a Address aggregate root, but this seems needlessly complex to me.

In your example you could have a business aggregate root that is responsibly for all business entities in your bounded context and a person root that has all the person entities. What you put in aggregate roots is really defined by the entities in your domain and if they are logical entities that are usually created, updated, deleted in one operation without being dependent on other entities. ( a customer, a business, an order etc. etc.)

That these entities span multiple tables in your DB is not important, that is an implementation detail. It is really more of a model, how it gets persisted in the background ( DB, eventsourcing ) is not something that should define your domain model and the entities. As for having to do the save logic twice: You could have a method that just takes an address and persists it, this can ofcourse be called by multiple aggregate roots. The important part is that the root is responsible for initiating it.

As for operations spanning multiple roots you have something called a "saga" in CQRS. There is a presentation about these by Udi Dahan describing exactly this.

I've built a small ordering application that uses Postgress in the background to persist the data and the general flow is:

Command comes in -> mapping command to aggregate root -> validate command -> aggregate root runs the command (updates DB etc etc.) -> saves the command in the past tense into a directory.

So if I have a customer that updates something like an address:

UpdateCustomerAddressCommand -> UpdateCustomerAddressCommand maps to CustomerRoot -> Validate command: Are all the neccessary fields filled in? -> Send to Customer Root -> Run Command on the Root ( update DB whatever) -> Save the command and the values it held as UpdatedCustomerAddressCommand.

You can think of these Aggregate roots as boundaries for all operations and treat them as how you would consume webservices. You have an API you use to talk to them and can make them as complicated as you want. ( Data access layers, etc etc. )

I hope this helps.

Mr Shiny Pants fucked around with this message at 12:13 on Jul 8, 2015

Che Delilas
Nov 23, 2009
FREE TIBET WEED
The company I work for runs an ASP.NET webforms application. It is having performance issues due to how we have grown and the number (and way) it talks to other devices. I have been tasked with attempting to make some of the more painful, I/O-bound calls asynchronous, because we're spending a lot of time waiting for responses from remote services that could be spent servicing other web requests.

I am posting here to ask the veterans to sanity check my assumptions and conclusions after the bit of research I have done.

First, the important fact: This application currently targets .NET Framework 4.0.

What I think I know:

- There is no way to make ASP.NET work with the async/await in framework version 4.0. Not even with the Bcl.Async library.
- Pre-4.5, the task-based asynchronous pattern does not really exist; any "asynchronous" programming is achieved through the use of additional threads.
- The thread pool will not help, since the point is to free up pool threads for web requests, therefore I can't use Tasks.

What I think my options are:

- Convince everyone to retarget the project to framework version 4.5 or higher.
- Attempt to handle threading manually

So, to the vets out there: are my assumptions correct? Do I have any other options than what I've outlined? I frankly don't think it's going to be all that terribly painful to get our code targeted to 4.5. The people who have been at the company a while are not thrilled about the idea though, because the last time they retargeted it was to go from like 2.0 to 4.0, and it was a nightmare.

I really, really don't want to attempt that second option if I don't have to; I'm completely green when it comes to threading, and everything I've read says that it's very difficult to get right. We may have a greybeard or two at the company that can do it, but I know they're busy on more urgent, more important, more customer-facing problems and features than this. Besides that, our codebase is old and rusty enough that I'd really rather do this the "right" way (it's I/O bound work, it's made for the TAP) rather than incur more technical debt.

Funking Giblet
Jun 28, 2004

Jiglightful!
Are any of the async tasks fire and forget? Or can you defer the response via a websocket or something? Using an ESB might help.

Kekekela
Oct 28, 2004

Che Delilas posted:


What I think my options are:

- Convince everyone to retarget the project to framework version 4.5 or higher.
- Attempt to handle threading manually


If you and your company are cool with server side javascript you could offload the requests to some node module and implement your async patterns there.

Gul Banana
Nov 28, 2003

iirc async model binding for webforms specifically is being introduced in 4.6 - final release July 29
if your issues are on the backend you might not particularly need the binding to be async, though

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Che Delilas posted:

What I think my options are:

- Convince everyone to retarget the project to framework version 4.5 or higher.

Re-targeting to 4.5 is essentially painless. You should have probably done this already.

EDIT: Here is a list of breaking changes - https://msdn.microsoft.com/en-us/library/hh367887%28v=vs.110%29.aspx

Bognar fucked around with this message at 14:48 on Jul 9, 2015

Che Delilas
Nov 23, 2009
FREE TIBET WEED

Funking Giblet posted:

Are any of the async tasks fire and forget? Or can you defer the response via a websocket or something? Using an ESB might help.

For the most part, the tasks are not fire and forget - they are a linear sequence of calls through several layers with potentially a lot of waiting for I/O between some of them. Websockets and ESBs are nothing I've ever worked with, but I'll look into them.

Gul Banana posted:

iirc async model binding for webforms specifically is being introduced in 4.6 - final release July 29
if your issues are on the backend you might not particularly need the binding to be async, though

I don't need the model binding; from what I've read I can wire up webforms pages to use async methods using RegisterAsyncTask in 4.5 and it will accomplish what I want.

Bognar posted:

Re-targeting to 4.5 is essentially painless. You should have probably done this already.

EDIT: Here is a list of breaking changes - https://msdn.microsoft.com/en-us/library/hh367887%28v=vs.110%29.aspx

Yeah, I combed through that link yesterday and so far I've only found one thing in there that our code actually uses (and I don't think it uses it in a way that will break). Good to hear some corroboration.

Thanks for the responses guys, they're a big help.

Mr Shiny Pants
Nov 12, 2012
F# question:

Is it possible to reduce a list to a bool?

I have a list with a couple of items and I want to check all elements leading to a final bool value if they are all correct or not.

Google leads to nothing.

Edit: Figured it out using a list.map on all elements and piping them into a Seq.exists. Seems to work fine.

A reduce to bool would be nice, don't know if it is even possible.

Mr Shiny Pants fucked around with this message at 21:24 on Jul 9, 2015

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Mr Shiny Pants posted:

F# question:

Is it possible to reduce a list to a bool?

I have a list with a couple of items and I want to check all elements leading to a final bool value if they are all correct or not.

Google leads to nothing.

Edit: Figured it out using a list.map on all elements and piping them into a Seq.exists. Seems to work fine.

A reduce to bool would be nice, don't know if it is even possible.

If you want a reducing function, then you're looking for List.fold. It takes a reducing function, a starting value, and the list to call it on. You can also use Seq.fold. Its corollary in C# LINQ is .Aggregate().

Here's an example:

https://dotnetfiddle.net/9sS7YY


However, it looks like you could just use List.exists or List.forall with a mapping function instead of piping to Seq.exists. The LINQ corollaries are .Any() and .All(), respectively.

Bognar fucked around with this message at 21:55 on Jul 9, 2015

Sedro
Dec 31, 2008
You shouldn't need the map; forall and exists accept a function to project the item
code:
Seq.forall ( fun x -> x.isCorrect )

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Bognar posted:

However, it looks like you could just use List.exists or List.forall with a mapping function instead of piping to Seq.exists. The LINQ corollaries are .Any() and .All(), respectively.

Any(), All(), or exists() are the correct functions to use here as they will short-circuit as soon as they find a (non-)matching element.

Mr Shiny Pants
Nov 12, 2012

Bognar posted:

If you want a reducing function, then you're looking for List.fold. It takes a reducing function, a starting value, and the list to call it on. You can also use Seq.fold. Its corollary in C# LINQ is .Aggregate().

Here's an example:

https://dotnetfiddle.net/9sS7YY


However, it looks like you could just use List.exists or List.forall with a mapping function instead of piping to Seq.exists. The LINQ corollaries are .Any() and .All(), respectively.

This is nice, thanks.

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost
Running into Nuget issues. When I open up any project and try to access the package manager console, I get this:

quote:


The module to process 'nuget.psm1', listed in field 'ModuleToProcess' of module manifest 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\LVDZFX1J.B5V\Modules\NuGet\NuGet.psd1' was not processed because no valid module was found in any module directory.


I'm not sure how to fix it; I didn't see anything on Google :(. Any ideas?

ljw1004
Jan 18, 2005

rum

Drastic Actions posted:

Running into Nuget issues. When I open up any project and try to access the package manager console, I get this:
...
I'm not sure how to fix it; I didn't see anything on Google :(. Any ideas?

File it as an issue at https://github.com/NuGet/Home/issues
The NuGet team there is very responsive.

epswing
Nov 4, 2003

Soiled Meat
Is it just me, or is Azure just irreparably broken? I need to vent a little bit.

I have an MVC 5 site using EntityFramework 6 sitting on Azure.

code:
EntityCommandExecutionException: An error occurred while executing the command definition.
    See the inner exception for details.
SqlException: A transport-level error has occurred when receiving results from the server.
    (provider: TCP Provider, error: 0 - The semaphore timeout period has expired.)
Win32Exception: The semaphore timeout period has expired
...
at System.Data.Entity.DbSet`1.Find(Object[] keyValues)
I'm getting these exceptions randomly. I cannot reproduce them. They seem to occur when I'm doing a simple Find() query. So far it's happened 6 times this morning, so it's more than "once in a while". Apparently they're happening because SQL Server is being moved around their datacenter. Various SO posts tell me I need to use the System.Data.Entity.SqlServer.SqlAzureExecutionStrategy instead of System.Data.Entity.Infrastructure.DefaultExecutionStrategy, to deal with that. But now transactions are broken, because they aren't supported by SqlAzureExecutionStrategy. So just for transactions, I need to suspend SqlAzureExecutionStrategy and use DefaultExecutionStrategy instead, which I've done. (Actually, a goon in this thread sent me some code he'd already written for this purpose.)

I'm using the highest Azure Sites app service plan pricing tier (Standard), and the 2nd highest Azure SQL pricing tier (Standard), which is costing my little operation around $100/mo (which is 2000% more expensive than a DigitalOcean droplet). Both Site and Database are in the same datacenter.

With all that done, I'm still getting these exceptions.

code:
using (var context = new DataContext())
{
	var user = context.Users.Find(42); // this query might fail, for reasons beyond your control!!
                                           // variety is the spice of life, no?
}
How the hell can any legitimate web app function in such an environment?
What's it going to take to fix this?

Edit: The cherry on top is that my default support plan does not include technical support. I need to pay even more money (an additional $30 per month, per developer) to get their lowest possible level of technical support :rage:

epswing fucked around with this message at 16:57 on Jul 11, 2015

Essential
Aug 14, 2003

epalm posted:

Is it just me, or is Azure just irreparably broken? I need to vent a little bit.

Unfortunately I can't provide any help on your current situation, however I can tell you that I pay the $30 per month support fee for 1 of my azure accounts and I can say the help was tremendous the 2 times I've needed it. It's seriously been the best tech support I've ever received. It was so good that the first time I needed it I kept the subscription going for 6 months now and ended up using it again a few weeks back. I think you can pay the $30 bucks for 1 month, get support and then cancel if you don't want to continue paying.

Both times I've used it the support rep has connected to my pc and then to my azure account and solved my issues. Each time they showed me various things/tricks/tools that I would never know about and both times they were able to get me going within 2 hours of when I first starting talking to them. They were super knowledgeable and explained everything they were doing. They have experts on all things azure and they may have someone who can solve your exact scenario.

RICHUNCLEPENNYBAGS
Dec 21, 2010
Well, I'm using Azure SQL and Azure Web sites at work and haven't experienced that, so I think there's something about your instance or setup in particular that's defective.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

RICHUNCLEPENNYBAGS posted:

Well, I'm using Azure SQL and Azure Web sites at work and haven't experienced that, so I think there's something about your instance or setup in particular that's defective.

Ditto this, I haven't had the SQL transient exception more than once a month, and I haven't seen it at all since we used the SQL Azure Execution Strategy. What region are you using?

Fiedler
Jun 29, 2002

I, for one, welcome our new mouse overlords.

epalm posted:

Is it just me, or is Azure just irreparably broken?
Are you using Azure SQL DB V12?

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION

Sorry it took me so long to respond, I really appreciate the amount of effort you put into this post and it helped me immeasurably, thanks!

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost

Drastic Actions posted:

Running into Nuget issues. When I open up any project and try to access the package manager console, I get this:


I'm not sure how to fix it; I didn't see anything on Google :(. Any ideas?

Found out a fix for this issue. But I never had to add crap to the devconfig file before, so I'm not sure why I had to now :shrug:.

But at least it's working.

Mr Shiny Pants
Nov 12, 2012

The Wizard of Poz posted:

Sorry it took me so long to respond, I really appreciate the amount of effort you put into this post and it helped me immeasurably, thanks!

Sure, glad I could help.

Another thing: Get a Skills Matter account, there a couple of great CQRS talks on it.

Sab669
Sep 24, 2009

http://stackoverflow.com/q/31457372/1189566

Anyone by chance able to explain this? :psyduck:

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal
Anyone using Visual Studio 2015 RC? Is it ready enough for production? I installed Windows 10 so I'm debating using it or 2013 Ult.

biznatchio
Mar 31, 2001


Buglord

Sab669 posted:

http://stackoverflow.com/q/31457372/1189566

Anyone by chance able to explain this? :psyduck:

You're not messing with the Controls collection on the TabControl directly anywhere else in your code are you? Looking at the reference source for TabControl, it seems getting an item by index directly pulls from an internal list of TabPages, whereas removing by index simply removes from the Controls collection by index -- directly poking at the Controls collection would get those two collections out of sync with each other.

Removing an item by TabPage reference (as opposed to by index) calls the Controls.Remove overload with the object reference as well, which would explain why that works to remove the right page when RemoveAt wouldn't. It really sounds like an extra item is in your Controls collection.

biznatchio fucked around with this message at 17:13 on Jul 16, 2015

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Knyteguy posted:

Anyone using Visual Studio 2015 RC? Is it ready enough for production? I installed Windows 10 so I'm debating using it or 2013 Ult.

I've been using it for months. It's fine.

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost

Knyteguy posted:

Anyone using Visual Studio 2015 RC? Is it ready enough for production? I installed Windows 10 so I'm debating using it or 2013 Ult.

VS 2015 RTM is coming out in a few days. RC should be fine though, and the few performance issues I had with it went away with the RTM build I'm using, so it should be fine.

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal
^ Sweet. Thanks.

Sab669
Sep 24, 2009

biznatchio posted:

You're not messing with the Controls collection on the TabControl directly anywhere else in your code are you? Looking at the reference source for TabControl, it seems getting an item by index directly pulls from an internal list of TabPages, whereas removing by index simply removes from the Controls collection by index -- directly poking at the Controls collection would get those two collections out of sync with each other.

Removing an item by TabPage reference (as opposed to by index) calls the Controls.Remove overload with the object reference as well, which would explain why that works to remove the right page when RemoveAt wouldn't. It really sounds like an extra item is in your Controls collection.

The method that mkves tabs from Active / Archived takes two TabControls and an index. So this is most likely it.

TabPage tp = source.TabPages[index]
destination.TabPages.Add(tp)

is the jist of it. Sorry for no formatting, on mobile.

Sab669 fucked around with this message at 19:11 on Jul 16, 2015

biznatchio
Mar 31, 2001


Buglord

Sab669 posted:

The method that mkves tabs from Active / Archived takes two TabControls and an index. So this is most likely it.

TabPage tp = source.TabPages[index]
destination.TabPages.Add(tp)

is the jist of it. Sorry for no formatting, on mobile.

That doesn't look like it's the culprit, it's accessing through the TabPages property, not the Controls property.

You could write some simple code just before your bad RemoveAt() call to loop over the Controls property and dump out everything that's in there. The RemoveAt() is going to remove based off those indexes, not the indexes you'd get by doing the same dump over the TabPages property. They should normally return the same set of objects, but I'm betting they don't in your case, and when you find what's in Controls but not in TabPages, you can work backward and find out how it got in there.

edit: Actually, I see the problem: it won't work right if you add a tab page to a tab control without removing it from the original tab control it was on first. The two lines of code you have above show the problem. Add a source.TabPages.Remove(tp) between those two lines.

Adbot
ADBOT LOVES YOU

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Bognar posted:

I'll start compiling a list of all the things that I use in R# (it's a lot), but off the top of my head:

....

I'm intentionally leaving out all the C# linting, since Roslyn is coming out with promises of doing that for us. However, for me the navigation options are huge - I know all the hotkeys so I can zip around a codebase super fast without ever touching the mouse (aided by VsVim). If VS had good replacements for advanced navigation, I would consider leaving R# behind.

Adding to this, a simple but awesome feature that I find myself missing without R# is Move Type to File. Often when prototyping things I'll jam a bunch of classes together in a file, then come back afterwards and refactor into their own files - this is pretty painful with having to create each file manually then copying the code in and trying to get the using statements right.

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