« first day (914 days earlier)      last day (4260 days later) » 

19:00
its an extension method from linq
Not a property?
use .Length
What is the different?
.Length is a property on the array and is O(1)
.Count is an operation on IEnumerable and is O(n)
19:06
@drch In theory. There is a special case for lists though.
actually i lied
yeah just decompiled
:P
BUT IN GENERAL
LIES! ALL LIES! :D
just remove using System.Linq; from the top and you wont have to worry about it ;)
Oh yeah, I remember frickin [KnownType]s
We set up unit tests to make sure that all our model classes had that shit set up right, since otherwise you'd just get a vague WCF error at runtime.
Yeah knowntype is one of those things that leaves scars on your brain do you don't forget
19:16
Switching everything to use properties and have capitalized is going to take a while :\
Refactor the field to be Capitol first and vs will rename all references
How would I do that?
Or just refactor like normal, you mean?
Rename it and click the red line that highlights under it
When you rename it, a little tag will come up that you can hover over.
It will have an option for auto-renaming.
Oh.
I see. Very useful. Thanks.
Not sure what I did, but I now have 134 errors... :D
The more I rename, the more errors I am getting. 250 and counting.
19:28
Are you doing the refactoring auto-rename?
For what I can, but by the time I learned that, I was about halfway through.
Finding and replacing, mostly.
If you undo and redo the rename, you would get the option again.
I could. This isn't to much of it, though, most of it is a change from getXXX to XXX with the properties being used instead.
My API was a bit bad too it looks in hindsight.
Valuable experience.
Can you elaborate on that?
19:38
The best way to get better at programming is to unintentionally write bad code.
Only if you know it is bad :D
find good code to check out
I hope that I can get this reviewed if I finish it.
For codereview on SO.
what does it do
19:41
Is there a. for example, length limit?
It's a lot easier to see why bad code is bad than why good code is good.
Oh. Asteroids clone.
wpf or xna?
@Pawnguy7 We don't do code review on SO.
or web
19:42
XNA. But it would be more about the non-XNA parts.
That's fine.
Is that no SO?
Or did you mean, specifically, this... main part?
I meant specifically SO.
19:43
Not sure if they call this an offshot or if it is special, but it is obviously different.
Ah.
This isn't the main part, this is chat.
SO != SE
Well.
> It's built and run by you as part of the Stack Exchange network of Q&A sites
And yes, I know this is chat.
also not stackoverflow
No, but SO is an offshot of SE officially I think, although it came before SE.
Yeah, so?
19:46
so SO?
Never mind. I forget why I am arguing this :D
SO was the original. From its successes, SE was built, and SO was incorporated as the flagship site in the SE network.
4 mins ago, by Kendall Frey
@Pawnguy7 We don't do code review on SO.
19:47
Actually, SE came after SU and SF too.
whats sf
ah right
so i just thought it would be funny to find a moderately nsfw stackexchange and post it here cause the image automatically comes up
so i tried porn.stackexchange.com and sex.stackexchange.com
and then remmebered that im on the client's VPN
You didn't check the list, did you?
no but i did now
theyre boring
oooohhh homebrewing
19:51
lolwut
hmm... to go to PAX, or not to go to PAX...
@Pheonixblade9 ikr? I'm debating the same thing about E3.
That awkward moment when no one on your team knows what long polling is.
@ShotgunNinja lol one of my coworkers asked me to buy a bunch of tickets. I bought 10 tickets for various days
@Pheonixblade9 For PAX or E3?
20:03
@ShotgunNinja PAX Prime.
I live only a couple miles away from where it's held
Oh. Well, I was going to say, if you have a leftover E3 pass...
last year there were a ton of cosplayers on my bus, it was funny
nah I live in Seattle not LA
Who keeps pinning dumb shit?
@KendallFrey idk, I was just thinking the same thing
@KendallFrey: i usually longpoll in the shower
GET IT?
LOLZ
20:08
That was me.
I want to do an experiment.
Everyone pick a random number between 1 and 10.
OEPN OR CLOSED INTERVAL
DID I WIN?
8
∞
8
20:09
3.
@KendallFrey I don't think they're following your instructions very well.
ok, starting to think I did something wrong with my question
@deltree Hm?
This could work, but I have no idea how to do it. Could you please point me in the right direction? Speed is irrelevant if I can't get the tests to run at all. — deltree 6 mins ago
guess that link was my comment
odd
-3
Q: How do I Reset a Static Field (i.e. trigger it to be created again the next time the class is created)?

deltreeSo here's a sample singleton: public class Singleton { private static Singleton _instance = new Singleton(); private Singleton() { //do stuff } public static Singleton Get() { return _instance; } } I'm trying to run multiple tests on this singleton...

that question
-3 and everyone just disappeared, as if it were answered
20:13
Just a suggestion.... NEVER USE SINGLETONS EVER.
static instances are only initialized once
They violate so many of the most basic conventions of proper object-oriented programming.
@ShotgunNinja I didn't use singletons
> So here's a sample singleton
@drch "This is code I'm testing, not that I've written."
20:15
@deltree Why link a question that has Singleton everywhere, then?
This is code I'm testing, not that I've written.
^ in the question text
Are you a professor?
I'm a developer who tests things before he changes them
Okay, fair enough.
So long as you have a plan to move away from singletons, I'm happy.
I am trying to understand the downvotes though
20:17
Probably because people assume you've written the code.
No one likes singletons here, in my experience.
also its a very simple principle and the attitude sucks
I don't even use Static Classes outside of testing. I live eat sleep and breathe IoC
attitude?
did I present a bad attitude? how can I fix that?
meh whatevs
to the code itself
the static field initializer will be run once
so you can't "reset" it
you could explicitly set it
somewhere in the CLR or something, there's a flag being set that says "don't re-initialize this"
so if I knew where that was I bet I could reset it
its the way static works
> If a static constructor (Section 10.11) exists in the class, execution of the static field initializers occurs immediately prior to executing that static constructor. Otherwise, the static field initializers are executed at an implementation-dependent time prior to the first use of a static field of that class. The example
20:19
the guy's asking about how to test this code, though. Basically one way is to have a new CLR for each test case.
A coworker of mine once encountered a bug due to static initializers being run in different order when the code was compiled in release mode instead of debug mode.
@redtuna which I'd be happy to write 5000 lines of code to do if I just knew how
(it was kinda fragile crappy code we were maintaining)
@MikeF ewwww
@deltree well it depends on how your tests are set up. If it's an old-style "run this program with a command-line argument to indicate which test to run" then it should work already. If you're using Visual Studio's built-in test thingamagig, perhaps it's possible but I don't know how.
it may be useful for you to put more information in the question about how you are doing your testing.
20:22
Write a batch script or something that automates re-running of subsequent test cases in separate CLRs. Then have a test case in your main testing framework that uses system calls to execute the batch script, and parses text output to determine whether or not the tests passed.
@redtuna I read something about building your own testing framework
In your shoes I'd go the old-style route for those specific tests that need to look at the singleton's singletonness, and leave the rest as is.
@deltree yes, that's the way I'd go for this case since you absolutely positively can't change the code.
is it true that you cant change the code at all? can you refactor it to create a provider that you can mock?
@redtuna updated for ya
with a default implementation of grabbing your static object
20:25
@drch I am testing the code while I'm waiting for write access to TFS (don't ask)
oh you can't change the singleton code at all.. nvm then
I don't know much about VS's built-in testing thing. Perhaps it has a setting for what you need?
@deltree Saying (don't ask) is even more reason to want to know all about it.
is it worth writing a bunch of complicated code that dynamically loads assemblies into a separate domain?
You could have just said "I'm a consultant" or something, and been done.
20:27
@redtuna I think a console app may work, and I'll just return the value to the program and assert against it
But now I'm curious as to why exactly it cannot be said.
@ShotgunNinja I just started with the company and as you can see from the singleton thing they're not exactly competent, so "Source Control" is something of a mystery here
@deltree or you can make it take as argument the name of the code function to run, and use reflection to load and run it. Then you can write tests as normal, you just invoke them differently. Whichever is easier for you.
@deltree ...you aren't using source control?
@deltree no source control? major ouch.
20:28
@Pheonixblade9 He said he's on TFS, but doesn't have access yet.
that's sort of like modern medicine without penicillin
yeah...
source control is kind of like backups. When you need it, you need it badly.
From the looks of it, I'd guess they're just setting up source control based on your request, and they don't know how to add you to the system their IT guy whipped together?
@redtuna could you maybe put a bit of code together as an example to attach to your answer? Then I could mark it as the answer
20:30
let me see what I can whip up for you
write a batch script to run mstest once for each test
thanks, I hate to ask for code, but I am so tired of crappy SO answers to this question
@deltree I hear you, man.
When people misunderstand something being asked on SO, stuff goes sour quickly.
I think I got the point across on the last line of my Note in the question: I am not interested in code advice. This is StackOverflow, not CodeReview.
^ That sounds a little pedantic... I should hope that people know how to answer for SO rather than CR.
However, if it's a problem, then I'd imagine that a precursor statement with a gentler tone would get the point across far better.
20:32
@ShotgunNinja if you'd spent 2 days reading SO answers to the question I'm asking that consisted of "well just build the singleton this way"
@ShotgunNinja I'm all ears, Like I said, I wasn't trying to be rude in tone
@drch that might actually be better than what I was proposing.
you could whip up a quick program that searches all classes marked [Test] and their methods and output that into a .bat
I'm not sure I understand
drch you should write that up as an answer, I think it's better than what I was suggesting.
20:34
Batch scripts, mang. They're awesome.
@redtuna your suggestion works with MSBuild, a batch script wouldn't
though deltree should still upvote me. You know, for good karma.
I did upvote you
@deltree oh cool, thanks! :)
you and SLaks, but pswg got a downvote for not reading
20:35
yeah, I was hoping SLaks would elaborate. Because it sounds like the right way to do it but I'm not sure how to do it either.
edc
edc
@deltree better yet, use a different test tool like Gallio
@ShotgunNinja s/batch/bash/ and I agree with you.
@redtuna I really think your console app trick would be the way to do it given the tools I'm bound by
@edc I wish I could upgrade my tools
20:36
@deltree well then I guess the problem's solved, let's make it happen!
edc
edc
@deltree you don't really need to change your tests at all, Gallio supports MSTest
@edc that may do the trick, but I suspect learning the new tool would take longer than fixing the problem deltree's faced with. Unless you can make a good argument that he should be using that tool instead of mstest?
example of running tests in a separate app domain
20:38
@edc post it as an answer (preferably with some sample code for same above mentioned reason)
@drch reading now
add that to the console program from redtuna and you could have the app run them all
@drch that looks like it'd work
yeah, seems like the way VS does [TestInitialize] and [TestCleanup] I can't wrap the tests from inside the assembly
edc
edc
@redtuna you have a good point. Sorry, after trying MSTest for a bit, I just don't like it.
@drch I think you may have saved the day
20:39
upvotes for all! Imaginary points galore!
i think that bit of code is assuming a consistent naming pattern for setup/teardown
you may have to do some reflection to find the one with the right attribute
@edc I don't have much experience with it either. I tried it once, and it seemed much slower than the clunky "run everything as a separate program" script we were using at the time.
@drch I'm still reading it, haven't full grasped it yet
edc
edc
@redtuna ya, many people report that MSTest is substantially slower than any other serious test suites out there.
@deltree: what version of VS are you using
20:42
2008, 2010, and 2012, but this app was built for 2010 and hasn't been upgraded yet
@edc Good to know. Which would you recommend instead? Gallio?
brgb
What was the name of that code complexity measure?
cyclomatic?
Yeah, maybe.
Thanks.
20:45
thats branching
We got this design guideline that said methods should be limited to 7 statements.
average level of indentation-squared seems like it would be a good measure
I think we'll have to re-evaluate that.
edc
edc
I like Gallio because it supports MSTest, nunit and MbUnit
@deltree: thing is there are so many attributes to consider
20:46
@MikeF Oh, don't remind me. It recommended spaces!
@KendallFrey 7 statements? Wow, that's pretty draconian.
edc
edc
so you won't run into an issue where you need to convert all your existing tests. Their test runner can also be invoked through code. The downside is they don't have a lot of docs on customizing their test runner, so there's a bit of learning curve there.
@drch attributes?
@KendallFrey I recommend spaces too. It's easier than configuring everyone's tools to agree on how wide a tab should be.
yeah like [TestCleanup] [Ignore] [AssemblyInitialize] shit like that
is it only a certain fixed list of tests that need to be run this way?
20:48
They don't need to agree. That's the joy of tabs.
@drch what does that have to do with this?
tabs are easier to arrow-key-navigate in
and take less disk space
@MikeF that's what control-arrow is for.
edc
edc
it's the tab-vs-space debate again~!
20:48
why should I have to press more keys? programming is about laziness!
That's petty compared to the customizable indents.
@drch: they tell the testrunner how to behave. your console runner would have to consider them
@KendallFrey and if your code is taking up the majority of your disk, then you're really atypical.
@MikeF Code golf!
@redtuna Like I said, petty.
@drch I'm putting together a sample app using the suggestion you provided, so if it works I'll let you know. If that's the case, you really should post it as an answer
20:49
meh, i only use rep for downvotes and i have 700 bullets atm
@drch it's not about the rep, it's about finally having an answer to a question that's been asked 30 or so times
user1125394
what do you think this would return : new[]{1}.Aggregate( (a,b) => a + b);
maybe when its this hard to fix bad code it will help people write it better in the first place
user1125394
20:51
for me it's weird since the function takes 2 args
Do you know how Aggregate works?
user1125394
but I guess the default is 0
user1125394
@KendallFrey a very little
@drch as I'm reading this, it looks like it might be so simple as AppDomain.CreateInstanceAndUnwrap().Method() for each test
maybe... just make sure you dont reference any fields in the bad classes
user1125394
20:52
but yes, it folds the list from left to right, with intermediate results
Hello guys... I just made a dll using C# Class Library... I add it as reference to my other project but it show me an error The type or namespace name 'MI could not be found (are you missing a using directive or an assembly reference?)... What I am doing wrong?
you might have to create a proxy class to get that info for you
?
wait
this could be simpler
couldn't I just use AppDomain.CreateInstanceAndUnwrap(Singleton) and then use that object in the test?
@Loclip check your warnings, there may be a hint there. You have to be using the same platform on both projects.
@Loclip Did you miss a using statement?
Show us the line where it failed.
20:54
using MI;
It was working then I made some change (not remember exactly what) and now it cant find it
@Loclip do you get any warning when you compile?
@deltree: are you able to pass the singleton in? I assume the other code is just calling Singleton.GetInstance()
Is that the main namespace of the other project?
he must be working on a project for the government of Michigan
Or a musical program.
20:56
or his initials are "M.I."
I will never forget the musical program I made.
It played songs via Console.Beep().
@KendallFrey the namespace of my dll is MI and the namespace of my other project is Test
user1125394
new string[] { "1" }.Aggregate( (a, b) => a +","+ b) // this for example I would have expected "1," not "1"
@redtuna i get the above error
It's not clear which is which.
@c'c It doesn't have an item to concat to.
So it doesn't put the comma in.
user1125394
20:58
a yes, something like the initialization
@c'c aggregate does nothing if your list has a single element
user1125394
ok
"This method works by calling func one time for each element in source except the first one. "
@Loclip did you check that MI.dll is in the references? And there's no little exclamation mark next to it?
@redtuna yes it is. no there is not
20:59
@deltree: im working on something dont run away ;)
@Loclip I'm out of ideas then :/ Someone else perhaps?
I will try to use it in other project
@drch I have to go home shortly, I want to keep on this, do you want me email?
guys, do you think it's crazy to allocate and initialize an array like this: int[] evens = Enumerate.Range(0,10).Select(x=>2*x).ToArray(); ?
@drch my current code does this, which is a bit off but close var singleton = domain.CreateInstanceAndUnwrap("ConsoleApplication3", "Singleton") as Singleton;
I would prefer to have an appdomain wrapping the assembly so that I can invoke the static class and see how the constructors are called
21:02
@redtuna. Anything or anyone that cannot be understood is crazy.
@ArgumentNullException I beg to differ.
I can't understand myself from time to time, and I'm not--- Ah, who am I kidding.
@redtuna I just used interval in class and should have it public.. Fixed now
@ArgumentNullException You're saying that code's too hard to read? You want an initialization loop instead?
@drch I'll get on in about an hour when I get home. Also, I'll be back on tomorrow. I'll keep up with my notifications
really gotta run
21:04
@Shotgun lol. Most of us are crazy, but don't know it.
@redtuna That linq looks perfectly fine to me
but maybe that means I'm crazy
@MikeF Thank you Mike. I'm glad at least someone understands me here ;)
@redtuna it's not hard to read, but it's not readable. Loop may help, but not necessary. What''s 0, 10, 2, x? Only an opinion.
@ArgumentNullException that was just a random made-up example. That said, I often use "i" or "x" or a similarly pithy variable in loops where what's being modified is clear from the name of the array. So I might have for (int i...) { distanceToStore[i] = compute(...) }. It should be pretty obvious that "i" is the store index here.
I have a similar tendency for one-letter variables in small linq lambdas
user1125394
21:14
Enumerable.Range(1, 100).Zip(Enumerable.Range(1, 100).Select(x => 2 * x), (x, y) => new Tuple<int,int>(x, y));
@c'c See, that makes total sense to me.
@redtuna. Just my opinion. I use i, j, k, l, m, n... for nested for loops, but that's just about it.
@ArgumentNullException np. Noted and appreciated :)
How did I not know about Zip until now?
Useless to me at the moment, but it's cool to know.
@c'c except perhaps that it could be shorter: Enumerable.Range(0,100).Select(x=>new Tuple<int,int>(x,2*x));
21:17
@redtuna. Basically, your question is if it's crazy to utilize linq and lambdas. The answer is no.
user1125394
clearly
@MikeF yes, it's nice. LINQ has a lot of the stuff that functional coders would expect.
@ArgumentNullException yay for sanity!
user1125394
I'm trying to see where Zip is actually useful, Select overcomes it a bit
user1125394
hmm no, if you have 2 different arrays as input
exactly
21:22
silly question i have a windows ce application that is designed to run both on Ce and Desktop. I'm using a Data Grid but while it looks fine on CE when run on desktop the caption bar is visible. the problem is becuase its targeting .netCF there is no property for Caption so i cant turn it off... any ideas??
So Zip was added in 4.0, which explains why it's news to me.
If I have a property...
And I define the set method, can I not still have an auto get method?
I don't think so
What would it get?
Because it would be something the setter's not setting
get;

set
{
Graphics = value;

lineTexture = new Texture2D(Graphics.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);

lineTexture.SetData(new[] { Color.White });
}
The setter sets it, but it also does other things at the same time now that they are valid things.
What would you even expect Get to return?
21:31
the Graphics.
The compiler can't know that's what you want
....wait, is the name of this property itself "Graphics"?
Yes.
If you execute that code, the name of this site will appear in an error.
well put, Mike.
Why is that?
21:33
"Graphics = value" will execute the setter for Graphics, infinitely recursing.
Oh.
So it is not possible to both do this and set the other things?
So just create a backing member variable m_Graphics.
(Or whatever your coding standards indicate to name things)
I guess you could say I had that before, but I was C#-itizing my code.
I think I will use auto setters/getters, and in cases where I need the other things done.
I can have a check.
I'm finding it rarer and rarer where I actually have anything special done inside property getters/setters. Usually I find it's better to keep the properties simple for maintainability, and then the code that sets the property does the other junk.
@MikeF what I usually do is have extra properties that give you more data, rather than corrupting the "POCO properties"
21:39
On second though, I think I am going to use a property and and one on the inside.
If I have a property encapsulating an object that contains x and y properties...
Can I get the components directly?
Properties are just methods, you can technically do whatever you could do in a normal method.
Auto-properties are just converted to simple member-variable-backed getters & setters at compile time.
@Pawnguy7 something like int getx { get { return m_stuff.x; } }
Yeah, wrapper properties like that can be useful.
Like.
I thought I found this to be the case when I tried accessing something once.
Something like someObject.Property.X errored... perhaps I remember incorrectly.
21:55
if m_stuff is a struct, you'll get an error if you try to write to Property.X (since you're writing to a copy of the struct, that's probably not what you really meant to do)
if the value of Property is null, you'd get an error while trying to get X on it

« first day (914 days earlier)      last day (4260 days later) »