diff --git a/VSConfigFinder/.editorconfig b/VSConfigFinder/.editorconfig
index 5ae843a..5cc4256 100644
--- a/VSConfigFinder/.editorconfig
+++ b/VSConfigFinder/.editorconfig
@@ -1,3 +1,4 @@
+file_header_template = \nCopyright (C) Microsoft Corporation. All rights reserved.\nLicensed under the MIT license. See LICENSE.txt in the project root for license information.\n
# All files
[*]
@@ -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
@@ -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]
@@ -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
\ No newline at end of file
diff --git a/VSConfigFinder/CommandLine/CommandLineOptions.cs b/VSConfigFinder/CommandLine/CommandLineOptions.cs
new file mode 100644
index 0000000..fd3ebe2
--- /dev/null
+++ b/VSConfigFinder/CommandLine/CommandLineOptions.cs
@@ -0,0 +1,27 @@
+//
+// Copyright (C) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license. See LICENSE.txt in the project root for license information.
+//
+
+namespace VSConfigFinder
+{
+ using CommandLine;
+
+ ///
+ public class CommandLineOptions : ICommandLineOptions
+ {
+ ///
+ [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; }
+
+ ///
+ [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; }
+
+ ///
+ [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; }
+ }
+}
diff --git a/VSConfigFinder/CommandLine/ICommandLineOptions.cs b/VSConfigFinder/CommandLine/ICommandLineOptions.cs
new file mode 100644
index 0000000..7d5e374
--- /dev/null
+++ b/VSConfigFinder/CommandLine/ICommandLineOptions.cs
@@ -0,0 +1,31 @@
+//
+// Copyright (C) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license. See LICENSE.txt in the project root for license information.
+//
+
+namespace VSConfigFinder
+{
+ ///
+ /// The interface for the command line options.
+ ///
+ public interface ICommandLineOptions
+ {
+ ///
+ /// Gets or sets the folder path to be used as the root (starting point) of the search.
+ ///
+ string FolderPath { get; set; }
+
+ ///
+ /// 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, can also be passed in to indicate the output directory.folder path to output the consolidated .vsconfig instead of the command line arguments.
+ ///
+ bool CreateFile { get; set; }
+
+ ///
+ /// 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.
+ ///
+ string? ConfigOutputPath { get; set; }
+ }
+}
diff --git a/VSConfigFinder/CommandLine/VSConfig.cs b/VSConfigFinder/CommandLine/VSConfig.cs
new file mode 100644
index 0000000..caf2bd9
--- /dev/null
+++ b/VSConfigFinder/CommandLine/VSConfig.cs
@@ -0,0 +1,25 @@
+//
+// Copyright (C) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license. See LICENSE.txt in the project root for license information.
+//
+
+namespace VSConfigFinder
+{
+ using System;
+
+ ///
+ /// The class object that defines a .vsconfig file.
+ ///
+ internal class VSConfig
+ {
+ ///
+ /// Gets or sets the version of the .vsconfig file.
+ ///
+ public Version? Version { get; set; }
+
+ ///
+ /// Gets or sets the list of component ids.
+ ///
+ public string[]? Components { get; set; }
+ }
+}
diff --git a/VSConfigFinder/CommandLineOptions.cs b/VSConfigFinder/CommandLineOptions.cs
deleted file mode 100644
index 3f759bd..0000000
--- a/VSConfigFinder/CommandLineOptions.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-namespace VSConfigFinder
-{
- using CommandLine;
-
- ///
- public class CommandLineOptions : ICommandLineOptions
- {
- ///
- [Option("folderpath", Required = true, HelpText = "Set the source folder path to use as the root. The search will start from the root towards the bottom.")]
- public string FolderPath { get; set; }
-
- ///
- [Option("createfile", Required = false, HelpText = "Set the folder path to output the consolidated .vsconfig.\n" +
- "If the argument (--createfile) is not passed at all, the program will output the cli arguments that can be fed into the Visual Studio Installer setup arguments. (e.g. --add Microsoft.VisualStudio.Component.Roslyn.Compiler Microsoft.Net.Component.4.8.SDK)\n" +
- "If the argument is passed without a following folder path, the program will create and output the final .vsconfig into the current directory.\n" +
- "If the argument is passed with a following folder path, the program will create and output the final .vsconfig into the specified folder path that is followed by --createFile.")]
- public string? CreateFile { get; set; }
- }
-}
diff --git a/VSConfigFinder/ICommandLineOptions.cs b/VSConfigFinder/ICommandLineOptions.cs
deleted file mode 100644
index 0455ee3..0000000
--- a/VSConfigFinder/ICommandLineOptions.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-namespace VSConfigFinder
-{
- ///
- /// The interface for the command line options.
- ///
- public interface ICommandLineOptions
- {
- ///
- /// Gets or sets the folder path to be used as the root (starting point) of the search.
- ///
- string FolderPath { get; set; }
-
- ///
- /// Gets or sets the folder path to output the consolidated .vsconfig instead of the command line arguments.
- /// If a folder path is not provided after the argument, the output folder will default to the current directory.
- ///
- string? CreateFile { get; set; }
- }
-}
diff --git a/VSConfigFinder/Program.cs b/VSConfigFinder/Program.cs
index fa8c052..84a0245 100644
--- a/VSConfigFinder/Program.cs
+++ b/VSConfigFinder/Program.cs
@@ -1,6 +1,12 @@
-namespace VSConfigFinder
+//
+// Copyright (C) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license. See LICENSE.txt in the project root for license information.
+//
+
+namespace VSConfigFinder
{
using CommandLine;
+ using System.IO;
///
/// class for the .vsconfig finder tool.
@@ -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 errors)
diff --git a/VSConfigFinder/Utilities.cs b/VSConfigFinder/Utilities.cs
index 71010a1..06d9c71 100644
--- a/VSConfigFinder/Utilities.cs
+++ b/VSConfigFinder/Utilities.cs
@@ -1,7 +1,12 @@
-using System.Diagnostics.CodeAnalysis;
+//
+// Copyright (C) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license. See LICENSE.txt in the project root for license information.
+//
namespace VSConfigFinder
{
+ using System.Diagnostics.CodeAnalysis;
+
internal class Utilities
{
private static readonly string[] AcceptedOutputOptions = new[] { "config", "commandline" };