Esempio n. 1
0
        /// <summary>
        ///     Creates allman indent style CSharpFormatting options used in Visual Studio.
        /// </summary>
        public static CSharpFormattingOptionsUI CreateAllman( )
        {
            CSharpFormattingOptionsUI baseOptions = CreateKRStyle( );

            baseOptions.AnonymousMethodBraceStyle = BraceStyle.NextLine;
            baseOptions.PropertyBraceStyle        = BraceStyle.NextLine;
            baseOptions.PropertyGetBraceStyle     = BraceStyle.NextLine;
            baseOptions.PropertySetBraceStyle     = BraceStyle.NextLine;

            baseOptions.EventBraceStyle            = BraceStyle.NextLine;
            baseOptions.EventAddBraceStyle         = BraceStyle.NextLine;
            baseOptions.EventRemoveBraceStyle      = BraceStyle.NextLine;
            baseOptions.StatementBraceStyle        = BraceStyle.NextLine;
            baseOptions.ArrayInitializerBraceStyle = BraceStyle.NextLine;

            baseOptions.CatchNewLinePlacement  = NewLinePlacement.NewLine;
            baseOptions.ElseNewLinePlacement   = NewLinePlacement.NewLine;
            baseOptions.ElseIfNewLinePlacement = NewLinePlacement.SameLine;

            baseOptions.FinallyNewLinePlacement       = NewLinePlacement.NewLine;
            baseOptions.WhileNewLinePlacement         = NewLinePlacement.DoNotCare;
            baseOptions.ArrayInitializerWrapping      = Wrapping.DoNotChange;
            baseOptions.IndentBlocksInsideExpressions = true;

            return(baseOptions);
        }
Esempio n. 2
0
        /// <summary>
        ///     Like the Allman and Whitesmiths styles, GNU style puts braces on a line by themselves, indented by 2 spaces,
        ///     except when opening a function definition, where they are not indented.
        ///     In either case, the contained code is indented by 2 spaces from the braces.
        ///     Popularised by Richard Stallman, the layout may be influenced by his background of writing Lisp code.
        ///     In Lisp the equivalent to a block (a progn)
        ///     is a first class data entity and giving it its own indent level helps to emphasize that,
        ///     whereas in C a block is just syntax.
        ///     Although not directly related to indentation, GNU coding style also includes a space before the bracketed
        ///     list of arguments to a function.
        /// </summary>
        public static CSharpFormattingOptionsUI CreateGNU( )
        {
            CSharpFormattingOptionsUI baseOptions = CreateAllman( );

            baseOptions.StatementBraceStyle = BraceStyle.NextLineShifted2;
            return(baseOptions);
        }
Esempio n. 3
0
        public FormatStyleSettings()
        {
            InitializeComponent();

            // TO DO : Add categries
            // http://msdn.microsoft.com/en-us/library/aa302326.aspx

            // Create the AppSettings class and display it in the PropertyGrid.
            CSharpFormattingOptionsUI formatStyle = FormattingOptionsFactoryUI.CreateEmpty();

            propertyGridFormatStyle.SelectedObject = formatStyle;
        }
Esempio n. 4
0
        /// <summary>
        ///     The Whitesmiths style, also called Wishart style to a lesser extent, is less common today than the previous three.
        ///     It was originally used in the documentation for the first commercial C compiler, the Whitesmiths Compiler.
        /// </summary>
        public static CSharpFormattingOptionsUI CreateWhitesmiths( )
        {
            CSharpFormattingOptionsUI baseOptions = CreateKRStyle( );

            baseOptions.NamespaceBraceStyle       = BraceStyle.NextLineShifted;
            baseOptions.ClassBraceStyle           = BraceStyle.NextLineShifted;
            baseOptions.InterfaceBraceStyle       = BraceStyle.NextLineShifted;
            baseOptions.StructBraceStyle          = BraceStyle.NextLineShifted;
            baseOptions.EnumBraceStyle            = BraceStyle.NextLineShifted;
            baseOptions.MethodBraceStyle          = BraceStyle.NextLineShifted;
            baseOptions.ConstructorBraceStyle     = BraceStyle.NextLineShifted;
            baseOptions.DestructorBraceStyle      = BraceStyle.NextLineShifted;
            baseOptions.AnonymousMethodBraceStyle = BraceStyle.NextLineShifted;
            baseOptions.PropertyBraceStyle        = BraceStyle.NextLineShifted;
            baseOptions.PropertyGetBraceStyle     = BraceStyle.NextLineShifted;
            baseOptions.PropertySetBraceStyle     = BraceStyle.NextLineShifted;

            baseOptions.EventBraceStyle               = BraceStyle.NextLineShifted;
            baseOptions.EventAddBraceStyle            = BraceStyle.NextLineShifted;
            baseOptions.EventRemoveBraceStyle         = BraceStyle.NextLineShifted;
            baseOptions.StatementBraceStyle           = BraceStyle.NextLineShifted;
            baseOptions.IndentBlocksInsideExpressions = true;
            return(baseOptions);
        }
        private void GenerateCSharpFile(string projectName, string outputDirectory, bool xmlDocFood, bool generetaNUnit, FormatStyleEnum formatIndex, string formatFile, bool sortUsing, int templateIndex)
        {
            // To DO
            // For each file
            // http://msdn.microsoft.com/en-us/library/ee844259.aspx
            //TemplateStandard page = new TemplateStandard(xmlDocFood, sortUsing);
            //String pageContent = page.TransformText();
            //System.IO.File.WriteAllText("outputPage.cs", pageContent);

            // Format this new C# source file
            CSharpFormattingOptions format;

            switch (formatIndex)
            {
            case FormatStyleEnum.Empty:
                // Nothing to do!
                // format = FormattingOptionsFactory.CreateEmpty();
                break;

            case FormatStyleEnum.Mono:
                format = FormattingOptionsFactory.CreateMono();
                break;

            case FormatStyleEnum.KR_style:
                format = FormattingOptionsFactory.CreateKRStyle();
                break;

            case FormatStyleEnum.Allman_Visual_Studio:
                format = FormattingOptionsFactory.CreateAllman();
                break;

            case FormatStyleEnum.Whitesmiths:
                format = FormattingOptionsFactory.CreateWhitesmiths();
                break;

            case FormatStyleEnum.GNU:
                format = FormattingOptionsFactory.CreateGNU();
                break;

            case FormatStyleEnum.Custom:
                format = (CSharpFormattingOptions)CSharpFormattingOptionsUI.Load(formatFile);
                break;

            default:
                // unknow value!
                // TO DO : Throw an error
                break;
            }

            // Genereta NUnit test class
            if (generetaNUnit == true)
            {
                // Generate the project
                NStub.CSharp.CSharpProjectGenerator gen = new NStub.CSharp.CSharpProjectGenerator(String.Format("{0}_unitary_tests", projectName), outputDirectory);
                // gen.ReferencedAssemblies

                gen.GenerateProjectFile();

                /*
                 * // Generate the test case file
                 * foreach(string origFile in )
                 * {
                 *  CSharpCodeGenerator unitFile = new CSharpCodeGenerator(origFile, origFile);
                 *  unitFile.GenerateCode();
                 * }
                 */
            }
        }
Esempio n. 6
0
        /// <summary>
        ///     Creates sharp develop indent style CSharpFormatting options.
        /// </summary>
        public static CSharpFormattingOptionsUI CreateSharpDevelop( )
        {
            CSharpFormattingOptionsUI baseOptions = CreateKRStyle( );

            return(baseOptions);
        }