|
|
Formatting is what makes code easy to read. I have a file with thousands of lines, many consecutive lines are surrounded by #if/#else directives - it makes it very difficult to read when the indentation is wrong.
If it works correctly for you then I guess it comes down to formatting settings. I will try to tinker with those settings.
|
|
|
|
|
Then consider structuring your code or rearchitecting to eliminate the need for all the #if/#else. You can use some patterns, like Factory, IoC, Stategy to elimiate this type of clutter and make your code more readable, extensible and maintainable.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Works fine for me. I suspect it has to do with this:
F2dk wrote: I am using Visual C# 2008 RC1
Why are you using Release Candidate software two years after the full product was launched?
All those who believe in psycho kinesis, raise my hand.
My 's gonna unleash hell on your ass. tastic!
|
|
|
|
|
Sorry, I meant SP1.
But it works for you? Hmm, that's interesting.
|
|
|
|
|
Yes fine - try removing the #IF and #ENDIF lines. If a reformat document does not fix the formatting, then you may have an unfixed problem in your code - <TeachGrannyToSuckEggsMode >this can stop formatting working correctly.</TeachGrannyToSuckEggsMode >
Good Luck!
All those who believe in psycho kinesis, raise my hand.
My 's gonna unleash hell on your ass. tastic!
|
|
|
|
|
Okay, I just figured it out.
In Options -> Text Editor -> C# -> Formatting -> New Lines, I have "Place 'else' on a new line" disabled.
Enabling it fixes the problem. (But I don't want to enable it, obviously.)
I consider this a bug in MSVC#. I wonder if it persists in VC# 2010.
|
|
|
|
|
F2dk wrote: Enabling it fixes the problem. (But I don't want to enable it, obviously.)
How can you consider it to be a bug? It's working as designed.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
By disabling "Place 'else' on a new line" I get code looking like this:
} else {
(on one line) - That is what I am used to.
But due to C#'s syntax, I can force something in between the } and the else .
For example, a comment.
if (true) {
DoSomething();
}
else {
In this case MSVC# actually doesn't know what to do about the else , so if I change its indentation and Format the document (Edit -> Advanced) then it doesn't change else 's indentation.
This is in my opinion a bug (or lack of feature) since you obviously would want the else-clause to be indented to the same level as the if-clause.
You could also put an #if directive before an else-clause. In this case MSVC# insists on indenting the else-clause by exactly 1 space.
if (true) {
DoSomething();
}
#if DEBUG
else {
Again, I would expect the else-clause to be indented to the same level as the if-clause. Would you disagree with that?
I fully understand why it doesn't happen though. (After the compiler has parsed the #if directives, all it reads is } else { and therefore it places a space before the else-clause just like I told it to by disabling the new-line-before-else option.)
But I definitely consider it a bug. Don't you?
|
|
|
|
|
Ew, } else { is ugly and unreadable.
|
|
|
|
|
No it isn't; it works great for me, e.g.:
if (install) {
key1.Write(null, menuText);
key2.Write(null, command);
} else {
key2.Delete(null);
key1.Delete(null);
}
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
And I thought VB was ugly
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
It is
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Are you having some sort of internal conflict about that?
GAC!
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
If I formatted my code in such an ugly, unreadable fashion I would consider it to be an inconvience, not a bug.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Really? Well, you have been very helpful. Thank you for your mature reply.
If you think I am the only person using this formatting in a C-esque language then you are very wrong.
Take a quick look at the Linux source code. They use it too. (Ex1, Ex2)
In PHP's primary else example they use it too.
Since I have used C and PHP for a long time before starting with C#, you really can't blame me for using this formatting. And obviously you can't argue that the formatting is unreadable since millions of people are using it. The fact that you use something else because you prefer that is irrelevant to this thread.
|
|
|
|
|
Don't take it so personally. Everyone has their own style of formatting code, and yours just happens to look like crap to a number of us here. No big deal.
BTW, if Tools|Options doesn't allow you to configure the auto-formatting the way you want it, there's this key on the left side of your keyboard, labeled "Tab" (I know, it's a fairly new feature of most computer keyboards, so you may have missed it), and it inserts a tab character when you press it. And that long one at the bottom center of your keyboard is the "Space" bar, and it adds one space each time you press it.
F2dk wrote: Take a quick look at the Linux source code. They use it too. (Ex1, Ex2)
In PHP's primary else example they use it too.
Well, if that's the case, everyone else must be wrong.
F2dk wrote: Since I have used C and PHP for a long time before starting with C#, you really can't blame me for using this formatting.
I haven't yet seen any blame cast in one direction or another.
F2dk wrote: And obviously you can't argue that the formatting is unreadable since millions of people are using it.
You mean the two people you cited represent MILLIONS of people? I'm aghast! AGHAST I SAY! WE MUST ALL CONFORM OR LOSE WHAT LITTLE SELF RESPECT WE HAVE LEFT IN OUR PITIFUL LIVES! REPENT SINNERS!
F2dk wrote: The fact that you use something else because you prefer that is irrelevant to this thread.
Not at all - this is a thread about code formatting.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
YEAH! THANKS MR. WEENIE HEAD!
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Touche
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I heard that Obama is going to require all programmers to make all lines of code the same length so that no single line feels less important than any other line. Formatting, as we know it, will be a thing of the past.
EDIT ===========
Whoever is 1-voting me - you have a big job ahead of you - I have almost 18,000 messages in the system. Have fun.
EDIT ===========
Added "single" in original statement.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
modified on Saturday, January 30, 2010 3:10 PM
|
|
|
|
|
He has, and the millions of PHP programmers, i.e. both of them, have proclaimed their support for such a common standard but have vowed to vote one for everyone who doesn't use their formatting standard.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hello,
i would like to know if its possible to build an application that can SANDBOX an monitor an EXE.
this is part of an application i am building for a project in university. i'm building a prototype of a behavior based antivirus.
techniques used:
-Signature detection using the CLAMWIN AV database. "as it is the most common method"
-N-grams "a new way to detect malicious code using N-grams more commonly used in NLP"
-sanboxing "which is what all the AV companies say they do"
any feedback would be appreciated.
thank you
Mohamed Hossam
|
|
|
|
|
|
yes EliottA like a virtual machine, but not with the interface. preferably something like sanboxie..
thx.
modified on Friday, January 29, 2010 3:41 PM
|
|
|
|
|
You may want to consider running the app within its own AppDomain - also see System.AddIn .
/ravi
|
|
|
|