Looking for a configurable pretty printer for C# code - c#

I work on a team with about 10 developers. Some of the developers have very exacting formatting needs. I would like to find a pretty printer that I could configure to these specifications and then add to the build processes. In this way no matter how badly other people mess up the format when it is pulled down from source control it will look acceptable.

The easiest solution is for the team lead to mandate a format and everyone use it. The VS defaults are pretty good.
Jeff Atwood did that to us here on Stack Overflow and while I rebelled at first, I got over it :) Makes everything much easier!

Coding standards are definitely something we have. The coding formatting I am talking about is imposed by a grizzled architect that is, lets say, set in his ways and extremely particular. Lets just pretend that we can not address the human factor. I was looking for a way to circumvent the whole human processes.
The visual studio defaults sadly do not address line breaks very well. I am just making this line chopping style up but....
ServiceLocator.Logger.WriteDefault(string.format("{0}{1}"
,foo
,bar)
,Logging.SuperDuper);
another example of formatting visual studio is not too hot at....
if( foo
&& ( bar
|| baz
|| apples
|| oranges)
&& IsFoo()
&& IsBar() ){
}
Visual studio does not play well at all will stuff like this. We are currently using ReSharper to allow for more granularity with formating but it sadly falls sort in many areas.
Don't get me wrong though coding standards are great. The goal of the pretty printer as part of the build process is to get 'perfect' looking code no matter how well people are paying attention or counting their spaces.
The edge cases around code formatting are very solvable since it is a well defined grammar.
As far as the VS defaults go I can only say: BSD style or die!
So all that brings me full circle back to: Is there a configurable pretty printer for C#? As much as lexical analysis and parsing fascinate I have about had my fill making a YAML C# tool chain.

Your issue was the primary intent for creating NArrange (beta). It allows configurable reformatting of C# code and you can use one common configuration file to be shared by the entire team. Since its focus is primarily on reordering members in classes and controlling regions, it is still lacking many necessary formatting options (especially formatting within member code lines).
The normal usage scenario is for each developer to run the tool prior to check-in. I'm not aware of any one running it is part of their build process, but there is no reason why you couldn't, since it is a command-line tool. One idea that I've contemplated is running NArrange on files as part of a pre-commit step. If the original file contents being checked in don't match the NArrange formatted output on the source repository server, then the developer didn't reformat to the rules and a check-in error can be raised.
For more information, see my CodeProject article on Using NArrange to Organize C# Code.
Update 2023-02-25: NArrange appears to have moved to Github. The NArrange site (referenced above) is no longer available although there are copies in web.archive.org

I second Jarrod's answer. If you have 2 developers with conflicting coding preferences, then get the rest of the team to vote, and then get the boss to back the majority decision.
Additionally, the problem with trying to automatically apply a pretty printer like that, is that there will always be exceptional cases where your blanket coding standard is not the best or most readable solution, and you will lose out by squashing them with an automated tool.
Coding Standards are just that, standards. They don't call them Coding Laws or Coding Rules, and there's a good reason for that.

Related

Is there something better than preprocessor directives (#if, etc) in C#?

Most questions of this type are seeking to alter the program behavior (things that could be decided at run time) or want to deal directly with debug printing. This is a bit different.
I have code that depends on a peripheral (like a card reader). Sometimes I don't use it, which means the library isn't present. (And I'm being nice, because "library" turns out to mean installing a 2GB software suite). When I remove the library, I can't open the device. If I can't open the device, I can't create the class member that uses it. With the class inoperative, I can't call its methods from within the code. Therefore, I can't just choose not to execute it; I need it to go away since it will not compile without the library.
Preprocessor directives like #if and all that are ok, maybe; but these things appear in more than one file, which means independently maintaining a #define at the top of each. I come from a simpler place (meaning, C) where one header file can be used to control this. I note that C# is rather hostile about #define (either the label exists, or not; no constants or calculations allowed), and that makes me think there's another way.
How do you handle this?
---Follow-up(s)---
I did read the "duplicate" Q/A's, and have a fairly good picture of what I'm dealing with. I didn't find those questions in my original search, but sometimes that's just how it is.
#Amy suggests that #define at the top is "not how it's done" but rather "put it on the command line". So, (if I realize we are sticking with this mechanism) the discussion might go to examining ways to have that happen . One does not simply drop to a terminal and do that. It happens as "IDE features" or "IDE hacks".
#Alexei Levenkov asks what I really want. I really want to (a) not get compile errors, and (b) do it by selectively leaving out the code. And, find the C# equivalent to the way I proposed.
Some more constraints are addressed by the fact that I haven't been using VS or C# for all that long. So I know a lot less than you all do. Considering I got the code from the last person and have to deal with what I see, I don't want to set up the person after me to have to figure out what "interesting" thing I might have done to make it work. Thus, things like hand-editing a project file may work but will also cause consternation down the line.
# Eric Lippert suggests "hostile" is really "sensible". I may have had my tongue too far into my cheek on that one. VS seems to be telling me I'm doing it wrong, so I sensed there's a "right way" I simply don't know about. As for the 2GB supporting application, I will go to various computers and pull down the repository and try out something, and so this "overhead" wants to propagate with it. It's worse if I'm linked through my phone to do the download. And if I build the application with everything included, the end user is then required to install that software suite before the program will run. In theory, they could be required to buy the software. If I sent you a tic-tac-toe game, and told you it wouldn't run until you installed Oracle, you'd probably pass on the whole thing.
I considered the "stub out the interface" idea, but there seemed to be more hooks into the class than I wanted to deal with. Plus, I don't know what these things do, so I have to know something about them in order to "fake" them.
In the end I decided that we're still largely using the #if scheme to get this done, and the replacement feature I imagined might exist, doesn't. And I'm using the provision in the project file(s) as cited by #Jim G. as it gets the job done and is only a little imperfect. It's good enough.
As #BJ Safdie said here:
Set them in your Compilation Properties or Build options.
You get to the build options by right-clicking the project and selecting
properties from the menu.

Common Lisp IDE for C# Developer?

UPDATE
I've decided to go with Clojure for now.
LispDev isn't ready, and Eclipse/cusp wasn't stable enough for me to feel comfortable.
As for Clojure, after a long, very frustrating, very annoying process trying to get Eclipse/CCW, Netbeans/Enclojure and IntelliJ/La Clojure working, I finally got Eclipse/CCW working. The rest are still in mostly-broken states.
(If I get around to it, I'll document what it took for me to get Eclipse/CCW working.)
So for now, I'm going to use that. I may dip back into CL, and check out LispWorks and AllegroLisp's free versions, but Clojure feels like a more natural step for me from working within the Microsoft CLR environment.
Thanks everyone for the help.
Original Question
I'm a C# developer very familiar with Visual Studio (with Resharper).
I'm new to Lisps. I've taken an interest in both Common Lisp and Clojure recently, and found plenty of good material on both of them.
I've tried Emacs + Slime, but it feels like a very backwards, dated solution. I have no doubts about its power, but it's usability is nothing like what I'm used to. I don't want to struggle with an IDE in addition to the language.
There are Eclipse plugins for both Clojure and CL. There's also a couple more options I've seen for Clojure. Since I'm not a Java dev, I know nothing about these IDEs.
Is Eclipse a good place to start? Are there other good options?
EDIT:
Here's the features I'm used to:
Syntax highlighting and autoindentation (everyone has this, so it's a moot point)
Autocomplete of functions and variable names
Realtime displays of all function overloads and parameters and the ability to arrow up/down through the list while typing in parameters
Syntax suggestions for code improvement, with the ability to do them for you ("use a const", "convert to LINQ expression (FP)", "variable will never be assigned to", "variable will never be used", "variable could be null", "function will never be used", etc.)
Extract Method/Function refactoring: select a block of text, and it can be extracted into a new function
Create Variable Refactoring: select a block of text and create a variable (e.g., a let)
Rename Refactoring: rename a function or variable declaration and all other functions using it will be updated (automated search/replace)
Go to Definition of a method/function, variable
Find Usages/References to a particular method/function, variable
Integrated folder-based project management tools and build tools
"Move class to new file" which creates a new file based on the class name, and containing all of its methods
"Rename file based on class type" which renames the file if you change the class name
F9/Click to the left of the line to add/remove breakpoints
F10/F11 to step into or over code when debugging, along with an arrow and highlighting to show which code is currently executing (step into a func execution, or just execute it here)
Most everything is available in a right-click context menu, or as a hovering combobox or textbox as you're typing.
I'm not saying emacs/slime can't do that, but if it does, it doesn't use anything similar in terms of usability techniques.
If you're used to Visual Studio and want a similar product for Lisp, the equivalent is probably going to be a similar commercial IDE. The big ones I know of are Allegro and Lispworks.
I've not personally used either one for real work (i.e., a big project), though I've tried demos. They seemed nice enough, if a bit complex and with weird UIs, but not so much better than Slime to be worth the money to me. But if you want something like VS, they may be just what you're looking for.
FWIW, I do both C# and Common Lisp in Emacs, and I find Slime to be 10 times better than any set of modes I've found for editing C# so far. Come to think of it, I don't know of any development environment for any language or platform I'd rather use -- it's that good.
One issue you may have is that Lisp itself is a different enough language than what you're used to that old ways of doing things no longer apply, so any IDE may seem "backwards" to you. (I learned Lisp long before C#, and C# seems backwards and dated to me!) So instead of learning a few Slime commands (there's not many you really need), you're learning IDE commands, which might not really be any easier for you, since the concepts are the same and don't necessarily map to VS-like IDE features.
But good luck with whatever you choose!
C# is mostly used in a batch mode. The IDE shows this. It knows the syntax of a fixed language, invokes a compiler and uses the output from various tools, like the compiler.
Common Lisp is slightly different. The IDEs are either integrated into Common Lisp (Allegro CL, LispWorks, CCL) or are in something like Emacs and connect to a running Lisp (SLIME / Emacs). The major mode of development is interactive. A program is running and the IDE modifies it.
For Emacs one uses SLIME with the extensions Paredit and Redshank. See: Editing Lisp Code with Emacs.
Syntax highlighting and autoindentation (everyone has this, so it's a moot point)
This is provided by the IDEs.
Autocomplete of functions and variable names
This is provided by the IDEs.
Realtime displays of all function overloads and parameters and the ability to arrow up/down through the list while typing in parameters
Common Lisp does not have 'overloads'. It is possible to browse generic functions (CLOS) in IDEs.
Syntax suggestions for code improvement, with the ability to do them for you ("use a const", "convert to LINQ expression (FP)", "variable will never be assigned to", "variable will never be used", "variable could be null", "function will never be used", etc.)
Lisp compilers output hints and warnings. There are also style suggestions by some.
CL-USER 15 > (defun foo (a b) a)
FOO
CL-USER 16 > (compile 'foo)
;;;* Warning in FOO: B is bound but not referenced
FOO
Implementations like LispWorks can browse the set of warnings and errors.
Extract Method/Function refactoring: select a block of text, and it can be extracted into a new function.
Tools may do that. See for example Redshank.
Create Variable Refactoring: select a block of text and create a variable (e.g., a let)
Reshank.
Rename Refactoring: rename a function or variable declaration and all other functions using it will be updated (automated search/replace)
Use the search and replace tools of the IDE. Note that since Lisp has a programmable syntax the problem is not solvable in a general way.
Go to Definition of a method/function, variable
Meta-. , Meta-X Edit definition
Find Usages/References to a particular method/function, variable
Who calls feature in IDEs.
Integrated folder-based project management tools and build tools
See System Tools.
"Move class to new file" which creates a new file based on the class name, and containing all of its methods
Common Lisp does not work this way. Methods and Classes are not connected like in C#.
"Rename file based on class type" which renames the file if you change the class name
Common Lisp does not work this way. One does not write a file for a class.
F9/Click to the left of the line to add/remove breakpoints
Depends on the IDE. Use the function BREAK otherwise.
F10/F11 to step into or over code when debugging, along with an arrow and highlighting to show which code is currently executing (step into a func execution, or just execute it here)
Use the function STEP or the IDE tool.
Most everything is available in a right-click context menu, or as a hovering combobox or textbox as you're typing.
Yes.
I would think you need to check out SLIME in more detail, since it does a lot what you describe in combination with usual Common Lisp features like STEP, BREAK and TRACE.
It might also be useful to read the manual of the LispWorks IDE, which provides the equivalent features in a portable GUI and more:
Lispworks for Windows, IDE User Guide
I'm not saying emacs/slime can't do that, but if it does, it doesn't use anything similar in terms of usability techniques.
SLIME is based on Emacs, so it is shaped by its UI. LispWorks for example uses the Emacs ideas mostly only for the editor component (which is based on an Emacs-like editor written in Common Lisp). LispWorks uses GUI tools for class browsing, generic function browsing, system management, the debugger, inspector, etc.
Maybe you should give Jabberwocky a try.
There's also LispIDE, and Lisp Studio.
Allegro Common Lisp has an IDE supplied with it which may be of interest (although I'm not sure if you can use it with other Lisps). The Eclipse plugin is called Cusp and can be found here, although there's a fork of it here called lispdev which may have been updated more recently.
There may be some useful stuff over at the Lisp Game Wiki, especially the Useful Applications page here.
Personally I like using Emacs+Slime with some of the emacs tools which are designed to make it more IDE like.
While this question is old, and the OP has turned to Clojure, I think this is still a valid question, especially for those looking to learn Common Lisp and are either reluctant to switch from Visual Studio or just want to learn something new with a tool they are familiar with, to at least reduce the barrier to entry into such a great language, the same reasons why this question was asked.
I wrote an article explaining exactly how to achieve this, using Visual Studio as a Lisp IDE, which would be an almost great substitution for EMACS + SLIME combination.
The steps to achieve this setup are:
Visual Studio 2015 (Obviously the main ingredient)
Lisp Integration Visual Studio Extension.
Have ConEmu already installed and grab the ConEmuIntegration Visual Studio Extension.
A Common Lisp implementation of your choice, set in your %PATH% (via Environment Settings)
With that setup above, you will have an embedded REPL, and hovering the mouse over the Lisp functions/macros will give you tooltips with the signatures and definitions. This should accomplish most of the features requested in the original question.
It may have been unfortunate that at the time this question was asked, these tools weren't mature enough/created to be fully integrated as it is now, OR no one was aware or interested enough at the time.
As a bonus, if you are already familiar with C++, my recommendation would be to check out Embeddable Common Lisp (ECL), as that allows you to embed Lisp into your C++ code or call C++ from Lisp, how great is that combined with Visual Studio?
If you are new to Lisp and not an emacs user presently, then I would strongly recommend the free editions of either Allegro Lisp or LispWorks. Or, if you are going the Scheme route, PLT Scheme (which is now called Racket).
All three have very feature rich IDE's. Calling trees, type ahead, in-editor breakpoints, and most of the things you are used to from traditional IDE's.
I know this is an old question but - for Clojure - how about Nightcode? I similarly didn't want to waste language-learning time learning a new editor (i.e. Emacs/SLIME) too. I found Nightcode very usable.
https://nightcode.info/
I find myself now wanting Nightcode to support Common Lisp (maybe in the form of ABCL) too!

Programmatically checking code complexity, possibly via c#?

I'm interested in data mining projects, and have always wanted to create a classification algorithm that would determine which specific check-ins need code-reviews, and which may not.
I've developed many heuristics for my algorithm, although I've yet to figure out the killer...
How can I programmatically check the computational complexity of a chunk of code?
Furthermore, and even more interesting - how could I use not just the code but the diff that the source control repository provides to obtain better data there..
IE: If I add complexity to the code I'm checking in - but it reduces complexity in the code that is left - shouldn't that be considered 'good' code?
Interested in your thoughts on this.
UPDATE
Apparently I wasn't clear. I want this
double codeValue = CodeChecker.CheckCode(someCodeFile);
I want a number to come out based on how good the code was. I'll start with numbers like VS2008 gives when you calculate complexity, but would like to move to further heuristics.
Anyone have any ideas? It would be much appreciated!
Have you taken a look at NDepend? This tool can be used to calculated code complexity and supports a query language by which you can get an incredible amount of data on your application.
The NDepend web site contains a list of definitions of various metrics. Deciding which are most important in your environment is largely up to you.
NDepend also has a command line version that can be integrated into your build process.
Also, Microsoft's Code Analysis (ships with VS Team Suite) includes metrics which check the cyclomatic complexity of code, and raises a build error (or warning) if this number is over a certain threshold.
I don't know off hand, but ut may be worth checking whether this number is configurable to your requirements. You could then modify your build process to run code analysis any time something is checked in.
See Semantic Designs C# Metrics Tool for a tool that computes a variety of standard metrics value both over complete files, and all reasonable subdivisions (methods, classes, ...).
The output is an XML document, but extracting the value(s) you want from that should be trivial with an XML reader.

C# .net Mnemonics and use in general

I'm just starting out with C# and to me it seems like Microsoft Called their new system .Net because you have to use the Internet to look everything up to find useful functions and which class they stashed it in.
To me it seems nonsensical to require procedure/functions written and designed to stand alone ( non instantiated static objects) to have their class not also function as their namespace.
That is Why can't I use Write or WriteLine instead of Console.WriteLine ?
Then when I start to get used to the idea that the objects I am using ( like string) know how to perform operations I am used to using external functions to achieve ( like to upper, tolower, substring, etc) they change the rules with numbers, numbers don't know how to convert themselves from one numeric type to another for some reason, instead you have to invoke Convert class static functions to change a double to an int and Math class static functions to achieve rounding and truncating.. which quickly turns your simple( in other languages) statement to a gazillion character line in C#.
It also seems obsessed with strong typing which interferes somewhat with the thought process when I code. I understand that type safety reduces errors , but I think it also increases complexity, sometimes unnecessarily. It would be nice if you could choose context driven types when you wish without the explicit Casting or Converting or ToStringing that seems to be basic necessity in C# to get anything done.
So... Is it even possible to write meaningful code in notepad and use cl with out Internet access? What ref book would you use without recourse to autocomplete and Network access?
Any suggestions on smoothing the process towards grokking this language and using it more naturally?
I think you're suffering a bit from the fact that you've used to working in one way during some years, and now must take time to get yourself comfortable using / developing in a new platform.
I do not agree with you , that MS hasn't been consistent on the fact that a string knows how it should convert itself to another type, and other datatypes (like ints) do not.
This is not true, since strings do not know for themselves how they should be converted to another type as well. (You can use the Convert class to Convert types to other types).
It is however true that every type in .NET has a ToString() method, but, you should not rely on that method to convert whatever you have to a string.
I think you have never worked in an OO language before, and therefore, you're having some difficulties with the paradigm shift.
Think of it this way: it's all about responsabilities and behaviour. A class is (if it is well designed) responsible for doing one thing, and does this one thing good.
There is no excuse to use notepad to code a modern language. SharpDevelop or Visual C# Express provide the functionality to work with C# in a productive way.
And no, due to the complexity, not using the internet as a source of information is also not a good option.
You could buy a book that introduces you to the concepts of the language in a structured way, but to get up-to-date information, the internet is neccessary.
Yes, there are drawbacks in C#, like in any other language. I can only give you the advice to get used to the language. Many of the drawbacks become understandable after that, even if some of them don't become less annoying. I recommend that you ask clear, direct questions with example code if you want to know how some language constructs work or how you can solve specific problems more efficiently. That makes it easier to answer those questions.
For notepad, I have no useful advice, however I would advise you to use one of the free IDE's, Microsofts Express Editions, or Sharp Develop.
The IDE will speed the groking of the language, at which point, you can switch back to notepad.
Reading your post I was thinking that you worked mostly with C or dynamic languages previously. Maybe C# is just a wrong choice for you, there are IronPython, F# and a bunch of other languages that have necessary functionality (like functions outside of classes etc.)
I disagree with you about consistency. In fact there are small inconsistency between some components of .NET, but most part of FW is very consistent and predictable.
Strong typing is a huge factor in low defect count. Dynamic typing plays nice in small/intermediate projects (like scripts, etc). In more or less complex program dynamism can introduce a lot of complexity.
Regarding internet/autocomplete - I can hardly imagine any technology with size of .NET that doesn't require a lot of knowledge sources.
Programming in c# using notepad is like buying a ferrari to drive in dirt roads.
At least use Visual Studio Express Edition. For what you wrote I understand that you come from a non OO background, try to learn the OO concept and try to use it. You will eventually understand most design decisions made for .Net.
http://en.wikipedia.org/wiki/Object-oriented_programming
Oh boy where do i start with you(this will be a long post hahaha), well, lets go little by little:
"Microsoft called their system .NET because you have to use Intenet...", the reason why is called .NET is because the SUITE OF MICROSOFT LANGUAGUES(and now some other ones too like Phyton and Ruby, etc) CAN CALL ANY LIBRARY or DLLs, example you can "NET"(Network OR CALL) a DLL that was built in Visual Basic, F#, C++ from WITHIN C# or from any of those languagues you can also call(or ".NET") C# libraries. OK ONE DOWN!!!
NEXT ONE: "it seems nonsensical to require....to have their class not also function as their namespace", this is because a Namespace can have AS MANY CLASSES AS YOU WISH, and your question:
"That is Why can't I use Write or WriteLine instead of Console.WriteLine ?".
The reason is because: "Console"(System.Console hense the "Using" statement at the beginning of your program) Namespace is where "Write" and "WriteLine" LIVES!!(you can also FULLY qualify it (or "call It"). (all this seems to me that you need to study C# Syntax), ok NEXT:
"when I start to get used to the idea that the objects...", ok in simple words:
C# is a "Strongly Type-Safe language" so that SHOULD-MUST tell you what "you are getting in to" otherwise STAY WITH "WEAK or NO TYPE SAFE LANGUAGES" LIKE PHP or C , etc. this does NOT means is bad it just MEANS IS YOUR JOB TO MAKE SURE, as i tell my students: "IF YOU NEED AN INT THEN DEFINE AN INT INSTEAD LETTING THE COMPILER DO IT FOR YOU OTHERWISE YOU WILL HAVE A LOT OF BAD BUGS", or in other words do YOUR homework BEFORE DESIGNING A PIECE OF SOFTWARE.
Note: C# is IMPLICITY TYPE SAFE language SO IF YOU WANT YOU CAN RUN IT AS UNSAFE so from then it wiLL be your job to make sure, so dont complain later(for being lazy) when bugs arrive AT RUNTIME(and a lot of times when the customer is already using your crappy software).
...and last but not least : Whey do you wan to shoot yourself by using notepad? Studio Express is FREE, even the database SQL SERVER is FREE TOO!!, unless you work for a company I WILL ASK FOR PRO, ETC. all the "extra" stuff is for large companies, teams, etc, YOU CAN DO 99% OF THE STUFF WITH THE FREE VERSIONS(and you can still buy-update to full version once you want to scalate to Distributed Software or a Large Project, or if your software becomes a big hit, Example: if you need millions of queryes or hits PER SECOND from your database or 100 people are working on same project(code) but for the majority of times for 2 or 3 "normal" developers working at home or small office the FREE ONES ARE ENOuGH!!)
cherrsss!!! (PS: Software Developer since the 80's)

ReSharper Code Cleanup/Reformat Code feature vs Versioning Control Systems

ReSharper Code cleanup feature (with "reorder members" and "reformat code" enabled) is really great. You define a layout template using XML, then a simple key combination reorganizes your whole source file (or folder/project/solution) according to the rules you set in the template.
Anyway, do you think that could be a problem regarding VCS like subversion, cvs, git, etc. ? Is there a chance that it causes many undesired conflicts ?
Thank you.
Yes, it will definitely cause problems. In addition to creating conflicts that have to be manually resolved, when you check in a file that has been reformatted, the VCS will note almost every line as having been changed. This will make it hard for you or a teammate to look back at the history and see what changed when.
That said, if everyone autoformats their code the same way (ie, you distribute that XML template to the team), then it might work well. The problems really only come in when not everyone is doing the same thing.
I'm waiting for an IDE or an editor that always saves source code using some baseline formatting rules, but allows each individual developer to display and edit the code in their own preferred format. That way I can put my open curly brace at the beginning of the next line and not at the end of the current line where all you heathens seem to think it goes.
My guess is I'll be waiting for a long time.
Just reformat the whole solution
once
AND make sure that every developer
is using Resharper
AND make sure that formatting
options are shared and versioned
(code style sharing options)
You can use StyleCop to enforce a comprehensive set of standards which pretty much forces everyone to use the same layout styles. Then all you need to do is develop a ReSharper code style specification that matches this, and distribute it to the team.
I'm still waiting for someone else to do this, and for JetBrains to clear up all the niggling details which aren't fully supported, in order to allow ReSharper to basically guarantee full StyleCop compliance.
It can definitely cause conflicts, so I would make sure you don't reformat entire files if there are people working on them in parallel.
It definitely could cause conflicts.
If you want to use this in a multi-user environment then the configuration of Resharper needs to format your code to a set of standards which are enforced in your organization regardless of whether users make use of Resharper or not.
That way you are using the tool to ensure your own code meets the standards, not blanket applying your preferences to the whole codebase.
I Agree with the previous answers that state that conflicts are possible and even likely.
If you are planning to reformat code then at least make sure that you don't mix reformat checkins with those that change the function of the actual code. This way people can skip past check-ins that are simple reformattings. It's also a good idea to make sure that everyone knows a reformat is coming up so that they can object if they have ongoing work in that area.
We're working on something to work with refactors at the source code level. We call it Xmerge, and it's now part of Plastic. It's just a first approach, since we're working on more advanced solutions. Check it here.
It might be a good idea to write a script to check out every version in your source control history, apply the code cleaning, then check it into a new repository. Then use that repository for all your work in future.

Categories