From fb1eb3b4fbacb3c82a20921a7686a08714aeb0a9 Mon Sep 17 00:00:00 2001 From: elachlan <2433737+elachlan@users.noreply.github.com> Date: Wed, 12 Jan 2022 17:59:32 +1000 Subject: [PATCH 1/4] SA1504 All accessors should be single-line or multi-line --- eng/Common.globalconfig | 2 +- .../Solution/ProjectInSolution.cs | 21 ++++++++++++- src/Build/Definition/ProjectItem.cs | 10 +++++-- ...ItemEvaluator.OrderedItemDataCollection.cs | 7 +++-- src/Build/Instance/ProjectInstance.cs | 30 +++++++++++++++---- src/Build/Logging/BaseConsoleLogger.cs | 6 +++- src/Framework/ReuseableStringBuilder.cs | 6 +++- src/Tasks/AssemblyDependency/Reference.cs | 6 +++- .../ResolveAssemblyReference.cs | 18 +++++++++-- src/Tasks/GenerateResource.cs | 8 +++-- 10 files changed, 93 insertions(+), 21 deletions(-) diff --git a/eng/Common.globalconfig b/eng/Common.globalconfig index ba417e063f2..2b031559d9a 100644 --- a/eng/Common.globalconfig +++ b/eng/Common.globalconfig @@ -981,7 +981,7 @@ dotnet_diagnostic.SA1502.severity = suggestion dotnet_diagnostic.SA1503.severity = suggestion # All accessors should be single-line or multi-line -dotnet_diagnostic.SA1504.severity = suggestion +dotnet_diagnostic.SA1504.severity = warning # An opening brace should not be followed by a blank line dotnet_diagnostic.SA1505.severity = suggestion diff --git a/src/Build/Construction/Solution/ProjectInSolution.cs b/src/Build/Construction/Solution/ProjectInSolution.cs index 7ccd2e7dfef..f6615701399 100644 --- a/src/Build/Construction/Solution/ProjectInSolution.cs +++ b/src/Build/Construction/Solution/ProjectInSolution.cs @@ -150,16 +150,35 @@ internal ProjectInSolution(SolutionFile solution) /// public string RelativePath { + +/* Unmerged change from project 'Microsoft.Build (net6.0)' +Before: get { return _relativePath; } +After: + get { return _relativePath; +*/ + get + { + return _relativePath; + } + + } + internal set { + +/* Unmerged change from project 'Microsoft.Build (net6.0)' +Before: #if NETFRAMEWORK && !MONO // Avoid loading System.Runtime.InteropServices.RuntimeInformation in full-framework // cases. It caused https://github.com/NuGet/Home/issues/6918. _relativePath = value; #else _relativePath = FileUtilities.MaybeAdjustFilePath(value, ParentSolution.SolutionFileDirectory); -#endif +After: + _relativePath = FileUtilities.MaybeAdjustFilePath(value, ParentSolution.SolutionFileDirectory); +*/ + _relativePath = value; } } diff --git a/src/Build/Definition/ProjectItem.cs b/src/Build/Definition/ProjectItem.cs index 592a8a078a1..6dd0d58102c 100644 --- a/src/Build/Definition/ProjectItem.cs +++ b/src/Build/Definition/ProjectItem.cs @@ -184,8 +184,14 @@ public string UnevaluatedInclude { [DebuggerStepThrough] get - { return _xml.Include; } - set { Rename(value); } + { + return _xml.Include; + } + + set + { + Rename(value); + } } /// diff --git a/src/Build/Evaluation/LazyItemEvaluator.OrderedItemDataCollection.cs b/src/Build/Evaluation/LazyItemEvaluator.OrderedItemDataCollection.cs index ac9264ca6dc..c00dd4727d6 100644 --- a/src/Build/Evaluation/LazyItemEvaluator.OrderedItemDataCollection.cs +++ b/src/Build/Evaluation/LazyItemEvaluator.OrderedItemDataCollection.cs @@ -52,10 +52,13 @@ internal Builder(ImmutableList.Builder listBuilder) public ItemData this[int index] { - get { return _listBuilder[index]; } + get + { + return _listBuilder[index]; + } + set { - // Update the dictionary if it exists. if (_dictionaryBuilder is not null) { ItemData oldItemData = _listBuilder[index]; diff --git a/src/Build/Instance/ProjectInstance.cs b/src/Build/Instance/ProjectInstance.cs index 3777ecbec35..94978503a36 100644 --- a/src/Build/Instance/ProjectInstance.cs +++ b/src/Build/Instance/ProjectInstance.cs @@ -966,8 +966,14 @@ TaskRegistry IEvaluatorData @@ -1074,8 +1080,14 @@ List IEvaluatorData @@ -1086,8 +1098,14 @@ List IEvaluatorData diff --git a/src/Build/Logging/BaseConsoleLogger.cs b/src/Build/Logging/BaseConsoleLogger.cs index e3b892f2b6e..be5fc90a1e8 100644 --- a/src/Build/Logging/BaseConsoleLogger.cs +++ b/src/Build/Logging/BaseConsoleLogger.cs @@ -827,7 +827,11 @@ internal PerformanceCounter(string scopeName) /// internal bool InScope { - get { return inScope; } + get + { + return inScope; + } + set { if (!reenteredScope) diff --git a/src/Framework/ReuseableStringBuilder.cs b/src/Framework/ReuseableStringBuilder.cs index 18457bee6f6..5bd774d5870 100644 --- a/src/Framework/ReuseableStringBuilder.cs +++ b/src/Framework/ReuseableStringBuilder.cs @@ -49,7 +49,11 @@ internal sealed class ReuseableStringBuilder : IDisposable /// public int Length { - get { return _borrowedBuilder?.Length ?? 0; } + get + { + return _borrowedBuilder?.Length ?? 0; + } + set { LazyPrepare(); diff --git a/src/Tasks/AssemblyDependency/Reference.cs b/src/Tasks/AssemblyDependency/Reference.cs index 015ff467546..bff18896103 100644 --- a/src/Tasks/AssemblyDependency/Reference.cs +++ b/src/Tasks/AssemblyDependency/Reference.cs @@ -484,7 +484,11 @@ internal List GetSerializationAssemblyFiles() /// The full path to this assembly. internal string FullPath { - get { return _fullPath; } + get + { + return _fullPath; + } + set { if (_fullPath != value) diff --git a/src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs b/src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs index c6733074229..a9ec79dc413 100644 --- a/src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs +++ b/src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs @@ -322,7 +322,11 @@ public bool IgnoreTargetFrameworkAttributeVersionMismatch /// public string[] TargetFrameworkSubsets { - get { return _targetFrameworkSubsets; } + get + { + return _targetFrameworkSubsets; + } + set { ErrorUtilities.VerifyThrowArgumentNull(value, "TargetFrameworkSubsets"); @@ -450,7 +454,11 @@ public ITaskItem[] InstalledAssemblyTables /// public ITaskItem[] InstalledAssemblySubsetTables { - get { return _installedAssemblySubsetTables; } + get + { + return _installedAssemblySubsetTables; + } + set { ErrorUtilities.VerifyThrowArgumentNull(value, "InstalledAssemblySubsetTables"); @@ -477,7 +485,11 @@ public ITaskItem[] InstalledAssemblySubsetTables /// public ITaskItem[] FullFrameworkAssemblyTables { - get { return _fullFrameworkAssemblyTables; } + get + { + return _fullFrameworkAssemblyTables; + } + set { ErrorUtilities.VerifyThrowArgumentNull(value, "FullFrameworkAssemblyTables"); diff --git a/src/Tasks/GenerateResource.cs b/src/Tasks/GenerateResource.cs index 1b930d2c177..2cdb1181daf 100644 --- a/src/Tasks/GenerateResource.cs +++ b/src/Tasks/GenerateResource.cs @@ -259,11 +259,13 @@ public string StronglyTypedLanguage { set { - // Since this string is passed directly into the framework, we don't want to - // try to validate it -- that might prevent future expansion of supported languages. _stronglyTypedLanguage = value; } - get { return _stronglyTypedLanguage; } + + get + { + return _stronglyTypedLanguage; + } } /// From aac5ca3aa4dabb5cbe4dcfa684c0ece9eb0cf43f Mon Sep 17 00:00:00 2001 From: elachlan <2433737+elachlan@users.noreply.github.com> Date: Wed, 12 Jan 2022 18:08:29 +1000 Subject: [PATCH 2/4] Fix weird code fix error --- .../Construction/Solution/ProjectInSolution.cs | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/Build/Construction/Solution/ProjectInSolution.cs b/src/Build/Construction/Solution/ProjectInSolution.cs index f6615701399..5d86bf9a0c5 100644 --- a/src/Build/Construction/Solution/ProjectInSolution.cs +++ b/src/Build/Construction/Solution/ProjectInSolution.cs @@ -150,35 +150,20 @@ internal ProjectInSolution(SolutionFile solution) /// public string RelativePath { - -/* Unmerged change from project 'Microsoft.Build (net6.0)' -Before: - get { return _relativePath; } -After: - get { return _relativePath; -*/ get { return _relativePath; } - } - internal set { - -/* Unmerged change from project 'Microsoft.Build (net6.0)' -Before: #if NETFRAMEWORK && !MONO // Avoid loading System.Runtime.InteropServices.RuntimeInformation in full-framework // cases. It caused https://github.com/NuGet/Home/issues/6918. _relativePath = value; #else _relativePath = FileUtilities.MaybeAdjustFilePath(value, ParentSolution.SolutionFileDirectory); -After: - _relativePath = FileUtilities.MaybeAdjustFilePath(value, ParentSolution.SolutionFileDirectory); -*/ - _relativePath = value; +#endif } } From 4b514938bca490ddeb6d9089636614addeaaaec6 Mon Sep 17 00:00:00 2001 From: elachlan <2433737+elachlan@users.noreply.github.com> Date: Thu, 13 Jan 2022 21:49:51 +1000 Subject: [PATCH 3/4] Fix missing comment --- src/Tasks/GenerateResource.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Tasks/GenerateResource.cs b/src/Tasks/GenerateResource.cs index 2cdb1181daf..a7e131fd947 100644 --- a/src/Tasks/GenerateResource.cs +++ b/src/Tasks/GenerateResource.cs @@ -252,13 +252,15 @@ public ITaskItem[] FilesWritten } /// - /// The language to use when generating the class source for the strongly typed resource. + /// Gets or sets the language to use when generating the class source for the strongly typed resource. /// This parameter must match exactly one of the languages used by the CodeDomProvider. /// public string StronglyTypedLanguage { set { + // Since this string is passed directly into the framework, we don't want to + // try to validate it -- that might prevent future expansion of supported languages. _stronglyTypedLanguage = value; } From 6f37db8d42637298b15a65f19ce575a18d58ada9 Mon Sep 17 00:00:00 2001 From: elachlan <2433737+elachlan@users.noreply.github.com> Date: Wed, 19 Jan 2022 08:27:44 +1000 Subject: [PATCH 4/4] Fix missing comment --- .../Evaluation/LazyItemEvaluator.OrderedItemDataCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Build/Evaluation/LazyItemEvaluator.OrderedItemDataCollection.cs b/src/Build/Evaluation/LazyItemEvaluator.OrderedItemDataCollection.cs index c00dd4727d6..34d919b3a7b 100644 --- a/src/Build/Evaluation/LazyItemEvaluator.OrderedItemDataCollection.cs +++ b/src/Build/Evaluation/LazyItemEvaluator.OrderedItemDataCollection.cs @@ -59,6 +59,7 @@ public ItemData this[int index] set { + // Update the dictionary if it exists. if (_dictionaryBuilder is not null) { ItemData oldItemData = _listBuilder[index];