diff --git a/eng/Common.globalconfig b/eng/Common.globalconfig index ba417e063f2..c9a18883fac 100644 --- a/eng/Common.globalconfig +++ b/eng/Common.globalconfig @@ -1022,7 +1022,7 @@ dotnet_diagnostic.SA1517.severity = none dotnet_diagnostic.SA1518.severity = suggestion # Braces should not be omitted from multi-line child statement -dotnet_diagnostic.SA1519.severity = suggestion +dotnet_diagnostic.SA1519.severity = warning # Use braces consistently dotnet_diagnostic.SA1520.severity = warning diff --git a/src/Build.UnitTests/Definition/ProjectEvaluationContext_Tests.cs b/src/Build.UnitTests/Definition/ProjectEvaluationContext_Tests.cs index 0821ce83dad..f542b837ee5 100644 --- a/src/Build.UnitTests/Definition/ProjectEvaluationContext_Tests.cs +++ b/src/Build.UnitTests/Definition/ProjectEvaluationContext_Tests.cs @@ -791,6 +791,7 @@ public void ContextCachesExistenceChecksInConditions(EvaluationContext.SharingPo project.GetPropertyValue("p").ShouldBe("val"); } else + { switch (policy) { case EvaluationContext.SharingPolicy.Shared: @@ -802,6 +803,7 @@ public void ContextCachesExistenceChecksInConditions(EvaluationContext.SharingPo default: throw new ArgumentOutOfRangeException(nameof(policy), policy, null); } + } } ); } diff --git a/src/Tasks/GenerateResource.cs b/src/Tasks/GenerateResource.cs index 1b930d2c177..c344b62e71a 100644 --- a/src/Tasks/GenerateResource.cs +++ b/src/Tasks/GenerateResource.cs @@ -3291,8 +3291,11 @@ private static bool ContainsProperlyNamedResourcesFiles(Assembly a, bool mainAss { String postfix = mainAssembly ? ".resources" : a.GetName().CultureInfo.Name + ".resources"; foreach (String manifestResourceName in a.GetManifestResourceNames()) + { if (manifestResourceName.EndsWith(postfix, StringComparison.OrdinalIgnoreCase)) return true; + } + return false; } #endif diff --git a/src/Tasks/ManifestUtil/ApplicationManifest.cs b/src/Tasks/ManifestUtil/ApplicationManifest.cs index 33cf1d87613..6997aeaadb7 100644 --- a/src/Tasks/ManifestUtil/ApplicationManifest.cs +++ b/src/Tasks/ManifestUtil/ApplicationManifest.cs @@ -952,6 +952,7 @@ private class AssemblyAttributeFlags public AssemblyAttributeFlags(string path) { using (MetadataReader r = MetadataReader.Create(path)) + { if (r != null) { IsSigned = !String.IsNullOrEmpty(r.PublicKeyToken); @@ -960,6 +961,7 @@ public AssemblyAttributeFlags(string path) HasPrimaryInteropAssemblyAttribute = r.HasAssemblyAttribute("System.Runtime.InteropServices.PrimaryInteropAssemblyAttribute"); HasImportedFromTypeLibAttribute = r.HasAssemblyAttribute("System.Runtime.InteropServices.ImportedFromTypeLibAttribute"); } + } } } #endregion diff --git a/src/Tasks/ManifestUtil/SecurityUtil.cs b/src/Tasks/ManifestUtil/SecurityUtil.cs index 8016704ee78..bf36239367a 100644 --- a/src/Tasks/ManifestUtil/SecurityUtil.cs +++ b/src/Tasks/ManifestUtil/SecurityUtil.cs @@ -413,8 +413,11 @@ private static SecurityElement XmlElementToSecurityElement(XmlElement xe) foreach (XmlAttribute xa in xe.Attributes) se.AddAttribute(xa.Name, xa.Value); foreach (XmlNode xn in xe.ChildNodes) + { if (xn.NodeType == XmlNodeType.Element) se.AddChild(XmlElementToSecurityElement((XmlElement)xn)); + } + return se; } diff --git a/src/Tasks/ManifestUtil/Util.cs b/src/Tasks/ManifestUtil/Util.cs index 847e043a111..f6715320062 100644 --- a/src/Tasks/ManifestUtil/Util.cs +++ b/src/Tasks/ManifestUtil/Util.cs @@ -101,10 +101,13 @@ public static string FilterNonprintableChars(string value) StringBuilder sb = new StringBuilder(value); int i = 0; while (i < sb.Length) + { if (sb[i] < ' ') sb.Remove(i, 1); else ++i; + } + return sb.ToString(); } @@ -337,8 +340,11 @@ internal static bool IsValidFrameworkVersion(string value) public static string PlatformToProcessorArchitecture(string platform) { for (int i = 0; i < s_platforms.Length; ++i) + { if (String.Equals(platform, s_platforms[i], StringComparison.OrdinalIgnoreCase)) return s_processorArchitectures[i]; + } + return null; } @@ -403,6 +409,7 @@ public static void WriteLog(string text) if (!logging) return; if (s_logFileWriter == null) + { try { s_logFileWriter = new StreamWriter(Path.Combine(logPath, "Microsoft.Build.Tasks.log"), false); @@ -423,6 +430,8 @@ public static void WriteLog(string text) { return; } + } + s_logFileWriter.WriteLine(text); s_logFileWriter.Flush(); }