Skip to content

Commit

Permalink
Merge pull request #4 from microsoft/dev/sknam/update-commandline-par…
Browse files Browse the repository at this point in the history
…ameters

Update command line parameters and code styles
  • Loading branch information
jlee671 authored Feb 10, 2023
2 parents 6d95914 + b087713 commit 3156247
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 41 deletions.
53 changes: 52 additions & 1 deletion VSConfigFinder/.editorconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
file_header_template = <copyright file="{fileName}" company="Microsoft Corporation">\nCopyright (C) Microsoft Corporation. All rights reserved.\nLicensed under the MIT license. See LICENSE.txt in the project root for license information.\n</copyright>

# All files
[*]
Expand All @@ -15,7 +16,7 @@ dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
csharp_using_directive_placement = inside_namespace:silent
csharp_using_directive_placement = inside_namespace:error
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = block_scoped:silent
Expand All @@ -35,6 +36,31 @@ csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimenta
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent
csharp_new_line_before_open_brace = all
csharp_style_throw_expression = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_style_prefer_tuple_swap = true:suggestion
csharp_style_prefer_utf8_string_literals = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
csharp_prefer_static_local_function = true:suggestion
csharp_style_prefer_readonly_struct = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion
csharp_style_prefer_switch_expression = true:suggestion
csharp_style_prefer_pattern_matching = true:silent
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_prefer_not_pattern = true:suggestion
csharp_style_prefer_extended_property_pattern = true:suggestion
csharp_style_var_for_built_in_types = true:silent
csharp_style_var_when_type_is_apparent = true:silent
csharp_style_var_elsewhere = true:silent

# Xml files
[*.xml]
Expand Down Expand Up @@ -89,3 +115,28 @@ dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_style_allow_multiple_blank_lines_experimental = true:silent
dotnet_style_allow_statement_immediately_after_block_experimental = true:silent

# Diagnostics

# CS8603: Possible null reference return.
dotnet_diagnostic.CS8603.severity = error
dotnet_style_namespace_match_folder = true:suggestion
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_readonly_field = true:suggestion
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
dotnet_style_predefined_type_for_member_access = true:silent
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
dotnet_code_quality_unused_parameters = all:warning
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
dotnet_style_qualification_for_field = false:silent
dotnet_style_qualification_for_property = false:silent
dotnet_style_qualification_for_method = false:silent
dotnet_style_qualification_for_event = false:silent
27 changes: 27 additions & 0 deletions VSConfigFinder/CommandLine/CommandLineOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// <copyright file="CommandLineOptions.cs" company="Microsoft Corporation">
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt in the project root for license information.
// </copyright>

namespace VSConfigFinder
{
using CommandLine;

/// <inheritdoc/>
public class CommandLineOptions : ICommandLineOptions
{
/// <inheritdoc/>
[Option("folderpath", Required = true, HelpText = "The source folder path to use as the root. The search will start from the root towards the bottom.")]
public string FolderPath { get; set; }

/// <inheritdoc/>
[Option("createfile", Required = false, Default = false, HelpText = "(Default: false) Bool flag that indicates whether the output gets created as a consolidated .vsconfig file instead of the Visual Studio Installer setup command line arguments.\n" +
"If --createFile is passed in, --configOutputPath can also be passed in to indicate the output directory.")]
public bool CreateFile { get; set; }

/// <inheritdoc/>
[Option("configoutputpath", Required = false, HelpText = "The optional folder path to use if --createFile is passed in. If empty or null, uses the current directory as the output path.\n" +
"This can only be used in conjunction with --createFile. If passed in without --createFile, the parameter will be ignored.")]
public string? ConfigOutputPath { get; set; }
}
}
31 changes: 31 additions & 0 deletions VSConfigFinder/CommandLine/ICommandLineOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// <copyright file="ICommandLineOptions.cs" company="Microsoft Corporation">
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt in the project root for license information.
// </copyright>

namespace VSConfigFinder
{
/// <summary>
/// The interface for the command line options.
/// </summary>
public interface ICommandLineOptions
{
/// <summary>
/// Gets or sets the folder path to be used as the root (starting point) of the search.
/// </summary>
string FolderPath { get; set; }

/// <summary>
/// Gets or sets the value indicating whether the output gets created as a consolidated .vsconfig file instead of the Visual Studio Installer setup command line arguments.
/// If --createFile is passed in, <see cref="ConfigOutputPath"/> can also be passed in to indicate the output directory.folder path to output the consolidated .vsconfig instead of the command line arguments.
/// </summary>
bool CreateFile { get; set; }

/// <summary>
/// Gets or sets the optional folder path to use if --createFile is passed in.
/// If empty or null, uses the current directory as the output path.
/// This can only be used in conjunction with --createFile. If passed in without --createFile, the parameter will be ignored.
/// </summary>
string? ConfigOutputPath { get; set; }
}
}
25 changes: 25 additions & 0 deletions VSConfigFinder/CommandLine/VSConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// <copyright file="VSConfig.cs" company="Microsoft Corporation">
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt in the project root for license information.
// </copyright>

namespace VSConfigFinder
{
using System;

/// <summary>
/// The class object that defines a .vsconfig file.
/// </summary>
internal class VSConfig
{
/// <summary>
/// Gets or sets the version of the .vsconfig file.
/// </summary>
public Version? Version { get; set; }

/// <summary>
/// Gets or sets the list of component ids.
/// </summary>
public string[]? Components { get; set; }
}
}
19 changes: 0 additions & 19 deletions VSConfigFinder/CommandLineOptions.cs

This file was deleted.

19 changes: 0 additions & 19 deletions VSConfigFinder/ICommandLineOptions.cs

This file was deleted.

14 changes: 13 additions & 1 deletion VSConfigFinder/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
namespace VSConfigFinder
// <copyright file="Program.cs" company="Microsoft Corporation">
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt in the project root for license information.
// </copyright>

namespace VSConfigFinder
{
using CommandLine;
using System.IO;

/// <summary>
/// <see cref="Program"/> class for the .vsconfig finder tool.
Expand Down Expand Up @@ -28,6 +34,12 @@ private static void Run(CommandLineOptions options)
{
Console.WriteLine("Hello! I succeeded!");
Console.WriteLine($"--createFile: {options.CreateFile}");
Console.WriteLine($"--configOutputPath: {options.ConfigOutputPath}");

if (options.CreateFile)
{
options.ConfigOutputPath ??= Directory.GetCurrentDirectory();
}
}

private static void HandleParseError(IEnumerable<Error> errors)
Expand Down
7 changes: 6 additions & 1 deletion VSConfigFinder/Utilities.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
using System.Diagnostics.CodeAnalysis;
// <copyright file="Utilities.cs" company="Microsoft Corporation">
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt in the project root for license information.
// </copyright>

namespace VSConfigFinder
{
using System.Diagnostics.CodeAnalysis;

internal class Utilities
{
private static readonly string[] AcceptedOutputOptions = new[] { "config", "commandline" };
Expand Down

0 comments on commit 3156247

Please sign in to comment.