Skip to content

Commit

Permalink
Add comments option
Browse files Browse the repository at this point in the history
  • Loading branch information
RehanSaeed committed Mar 18, 2022
1 parent 68415cf commit 7556c4b
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 6 deletions.
12 changes: 12 additions & 0 deletions Source/NuGetTemplate/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,18 @@ dotnet_naming_rule.parameters_rule.severity = warning
##########################################

[*.cs]
#if (!Comments)
# SA0001: XML comment analysis is disabled due to project configuration
# Justification: Comments turned off
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA0001.md
dotnet_diagnostic.SA0001.severity = none

# SA1600: Elements should be documented.
# Justification: Comments turned off
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1600.md
dotnet_diagnostic.SA1600.severity = none

#endif
# SA1633: A C# code file is missing a standard file header.
# Justification: Comments turned off
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1633.md
Expand Down
3 changes: 3 additions & 0 deletions Source/NuGetTemplate/.template.config/dotnetcli.host.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
"ContactXmlEncoded": {
"isHidden": true
},
"Comments": {
"longName": "comments"
},
"ReadMe": {
"longName": "readme"
},
Expand Down
7 changes: 7 additions & 0 deletions Source/NuGetTemplate/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,13 @@
"valueSource": "Contact",
"valueTransform": "xmlEncode"
},
"Comments": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "true",
"displayName": "Comments",
"description": "Require comments on all code."
},
"ReadMe": {
"type": "parameter",
"datatype": "bool",
Expand Down
1 change: 1 addition & 0 deletions Source/NuGetTemplate/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<DotnetFramework>false</DotnetFramework>
<EditorConfig>true</EditorConfig>
<ImplicitUsings>true</ImplicitUsings>
<MIT>true</MIT>
<Nullable>true</Nullable>
<StyleCop>true</StyleCop>
Expand Down
2 changes: 1 addition & 1 deletion Source/NuGetTemplate/Source/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<PropertyGroup Label="Build">
<IsTrimmable Condition="'$(IsTrimmable)' == 'true'">true</IsTrimmable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<GenerateDocumentationFile Condition="'$(Comments)' == 'true'">true</GenerateDocumentationFile>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>

Expand Down
2 changes: 2 additions & 0 deletions Source/NuGetTemplate/Source/NuGetTemplate/Class1.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
namespace NuGetTemplate;

#if Comments
/// <summary>
/// Some class.
/// </summary>
#endif
public class Class1
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--#if (AuthoringMode)-->
<PropertyGroup>
<!-- Modify these constants to enable/disable a feature to debug the template. Note that this only affects the C#. -->
<DefineConstants>$(DefineConstants);</DefineConstants>
<DefineConstants>$(DefineConstants);Comments</DefineConstants>
<!-- Workaround to build this project: https://github.com/dotnet/templating/issues/1438 -->
<Framework>net6.0</Framework>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
using System;

[assembly: CLSCompliant(true)]
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
using System;

[assembly: CLSCompliant(true)]
1 change: 1 addition & 0 deletions Tests/Boxed.Templates.FunctionalTest/NuGetTemplateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public NuGetTemplateTest(ITestOutputHelper testOutputHelper)
[InlineData("NuGetAnalysisNone", "analysis-mode=AllDisabledByDefault")]
[InlineData("NuGetNoImplicitUsings", "implicit-usings=false")]
[InlineData("NuGetTrimmable", "trimmable=true")]
[InlineData("NuGetNoComments", "comments=false")]
public async Task RestoreBuildTest_NuGetDefaults_SuccessfulAsync(string name, params string[] arguments)
{
await InstallTemplateAsync().ConfigureAwait(false);
Expand Down

0 comments on commit 7556c4b

Please sign in to comment.