diff --git a/eng/Common.globalconfig b/eng/Common.globalconfig index fd878420d57..a8b55e10e68 100644 --- a/eng/Common.globalconfig +++ b/eng/Common.globalconfig @@ -277,7 +277,7 @@ dotnet_diagnostic.CA1821.severity = warning dotnet_diagnostic.CA1822.severity = none # Avoid unused private fields -dotnet_diagnostic.CA1823.severity = suggestion +dotnet_diagnostic.CA1823.severity = warning # Mark assemblies with NeutralResourcesLanguageAttribute dotnet_diagnostic.CA1824.severity = warning diff --git a/src/Build/Collections/RetrievableEntryHashSet/HashSet.cs b/src/Build/Collections/RetrievableEntryHashSet/HashSet.cs index 7c3efec3bac..50349f0f2e8 100644 --- a/src/Build/Collections/RetrievableEntryHashSet/HashSet.cs +++ b/src/Build/Collections/RetrievableEntryHashSet/HashSet.cs @@ -93,8 +93,10 @@ internal class RetrievableEntryHashSet : ICollection, { // store lower 31 bits of hash code private const int Lower31BitMask = 0x7FFFFFFF; +#if NEVER // cutoff point, above which we won't do stackallocs. This corresponds to 100 integers. private const int StackAllocThreshold = 100; +#endif // when constructing a hashset from an existing collection, it may contain duplicates, // so this is used as the max acceptable excess ratio of capacity to count. Note that // this is only used on the ctor and not to automatically shrink if the hashset has, e.g, @@ -121,7 +123,7 @@ internal class RetrievableEntryHashSet : ICollection, // temporary variable needed during deserialization private SerializationInfo _siInfo; - #region Constructors +#region Constructors public RetrievableEntryHashSet(IEqualityComparer comparer) { @@ -204,7 +206,7 @@ protected RetrievableEntryHashSet(SerializationInfo info, StreamingContext conte _siInfo = info; } - #endregion +#endregion // Convenience to minimise change to callers used to dictionaries public ICollection Keys @@ -230,7 +232,7 @@ public ICollection Values get { return this; } } - #region ICollection methods +#region ICollection methods // Convenience to minimise change to callers used to dictionaries internal T this[string name] @@ -481,9 +483,9 @@ internal void MakeReadOnly() _readOnly = true; } - #endregion +#endregion - #region IEnumerable methods +#region IEnumerable methods public Enumerator GetEnumerator() { @@ -508,9 +510,9 @@ IEnumerator IEnumerable.GetEnumerator() return new Enumerator(this); } - #endregion +#endregion - #region ISerializable methods +#region ISerializable methods // [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)] [SecurityCritical] @@ -533,9 +535,9 @@ public virtual void GetObjectData(SerializationInfo info, StreamingContext conte } } - #endregion +#endregion - #region IDeserializationCallback methods +#region IDeserializationCallback methods public virtual void OnDeserialization(Object sender) { @@ -580,9 +582,9 @@ public virtual void OnDeserialization(Object sender) _siInfo = null; } - #endregion +#endregion - #region HashSet methods +#region HashSet methods /// /// Add item to this HashSet. @@ -630,7 +632,7 @@ public void UnionWith(IEnumerable other) } } -#if NEVER +#if NEVER /// /// Takes the intersection of this set with other. Modifies this set. /// @@ -1152,9 +1154,9 @@ public static IEqualityComparer> CreateSetComparer() #endif #endif - #endregion +#endregion - #region Helper methods +#region Helper methods /// /// Initializes buckets and slots arrays. Uses suggested capacity by finding next prime @@ -1723,7 +1725,7 @@ private int InternalGetHashCode(string item) return _comparer.GetHashCode(item) & Lower31BitMask; } - #endregion +#endregion // used for set checking operations (using enumerables) that rely on counting internal struct ElementCount diff --git a/src/MSBuild.UnitTests/PerfLog_Tests.cs b/src/MSBuild.UnitTests/PerfLog_Tests.cs index 700671f1a8d..82128c129b6 100644 --- a/src/MSBuild.UnitTests/PerfLog_Tests.cs +++ b/src/MSBuild.UnitTests/PerfLog_Tests.cs @@ -26,12 +26,6 @@ namespace Microsoft.Build.UnitTests { public class PerfLogTests { -#if USE_MSBUILD_DLL_EXTN - private const string MSBuildExeName = "MSBuild.dll"; -#else - private const string MSBuildExeName = "MSBuild.exe"; -#endif - private readonly ITestOutputHelper _output; public PerfLogTests(ITestOutputHelper output) diff --git a/src/Shared/FileUtilities.cs b/src/Shared/FileUtilities.cs index 238d8d66792..e936cd1fed0 100644 --- a/src/Shared/FileUtilities.cs +++ b/src/Shared/FileUtilities.cs @@ -1089,27 +1089,6 @@ internal static string MakeRelative(string basePath, string path) return StringBuilderCache.GetStringAndRelease(sb); } - /// - /// Helper function to create an Uri object from path. - /// - /// path string - /// uri object - private static Uri CreateUriFromPath(string path) - { - ErrorUtilities.VerifyThrowArgumentLength(path, nameof(path)); - - Uri pathUri; - - // Try absolute first, then fall back on relative, otherwise it - // makes some absolute UNC paths like (\\foo\bar) relative ... - if (!Uri.TryCreate(path, UriKind.Absolute, out pathUri)) - { - pathUri = new Uri(path, UriKind.Relative); - } - - return pathUri; - } - /// /// Normalizes the path if and only if it is longer than max path, /// or would be if rooted by the current directory. diff --git a/src/Shared/UnitTests/EngineTestEnvironment.cs b/src/Shared/UnitTests/EngineTestEnvironment.cs index bc73e420dc1..958e63e6f0c 100644 --- a/src/Shared/UnitTests/EngineTestEnvironment.cs +++ b/src/Shared/UnitTests/EngineTestEnvironment.cs @@ -22,7 +22,9 @@ namespace Microsoft.Build.UnitTests public partial class TestEnvironment { // reset the default build manager and the state it might have accumulated from other tests +#pragma warning disable CA1823 // Avoid unused private fields private object _resetBuildManager = new ResetDefaultBuildManager(); +#pragma warning restore CA1823 // Avoid unused private fields private class ResetDefaultBuildManager { diff --git a/src/Tasks/GenerateResource.cs b/src/Tasks/GenerateResource.cs index 4dabaed7f16..1cb9808bd88 100644 --- a/src/Tasks/GenerateResource.cs +++ b/src/Tasks/GenerateResource.cs @@ -926,17 +926,7 @@ public override bool Execute() private static bool allowMOTW; private const string CLSID_InternetSecurityManager = "7b8a2d94-0ac9-11d1-896c-00c04fb6bfc4"; - - private const uint ZoneLocalMachine = 0; - - private const uint ZoneIntranet = 1; - - private const uint ZoneTrusted = 2; - private const uint ZoneInternet = 3; - - private const uint ZoneUntrusted = 4; - private static IInternetSecurityManager internetSecurityManager = null; // Resources can have arbitrarily serialized objects in them which can execute arbitrary code diff --git a/src/Tasks/LockCheck.cs b/src/Tasks/LockCheck.cs index 566553eff41..fcd8a41a300 100644 --- a/src/Tasks/LockCheck.cs +++ b/src/Tasks/LockCheck.cs @@ -83,8 +83,6 @@ internal struct RM_UNIQUE_PROCESS public FILETIME ProcessStartTime; } - const int RM_INVALID_SESSION = -1; - const int RM_INVALID_PROCESS = -1; const int CCH_RM_MAX_APP_NAME = 255; const int CCH_RM_MAX_SVC_NAME = 63; const int ERROR_SEM_TIMEOUT = 121; diff --git a/src/Tasks/ManifestUtil/SecurityUtil.cs b/src/Tasks/ManifestUtil/SecurityUtil.cs index abdcce405f9..def1e2bdc0f 100644 --- a/src/Tasks/ManifestUtil/SecurityUtil.cs +++ b/src/Tasks/ManifestUtil/SecurityUtil.cs @@ -46,8 +46,8 @@ public static class SecurityUtilities #if !RUNTIME_TYPE_NETCORE private const int Fx2MajorVersion = 2; private const int Fx3MajorVersion = 3; -#endif private static readonly Version s_dotNet40Version = new Version("4.0"); +#endif private static readonly Version s_dotNet45Version = new Version("4.5"); #if !RUNTIME_TYPE_NETCORE diff --git a/src/Tasks/ManifestUtil/Util.cs b/src/Tasks/ManifestUtil/Util.cs index ebc38e86e2b..984e66d8d3d 100644 --- a/src/Tasks/ManifestUtil/Util.cs +++ b/src/Tasks/ManifestUtil/Util.cs @@ -29,9 +29,10 @@ internal static class Util internal static readonly string logPath = GetLogPath(); private static readonly char[] s_fileNameInvalidChars = { '\\', '/', ':', '*', '?', '"', '<', '>', '|' }; private static StreamWriter s_logFileWriter; +#if !RUNTIME_TYPE_NETCORE // Major, Minor, Build and Revision of CLR v2.0 private static readonly int[] s_clrVersion2 = { 2, 0, 50727, 0 }; -#if RUNTIME_TYPE_NETCORE +#else // Major, Minor, Build and Revision of CLR v4.0 private static readonly int[] s_clrVersion4 = { 4, 0, 30319, 0 }; #endif diff --git a/src/Tasks/ManifestUtil/mansign2.cs b/src/Tasks/ManifestUtil/mansign2.cs index 2923d63cddb..5faa4ccb921 100644 --- a/src/Tasks/ManifestUtil/mansign2.cs +++ b/src/Tasks/ManifestUtil/mansign2.cs @@ -281,20 +281,6 @@ private void init() #endif } - private static XmlElement FindIdElement(XmlElement context, string idValue) - { - if (context == null) - return null; - - XmlElement idReference = context.SelectSingleNode("//*[@Id=\"" + idValue + "\"]") as XmlElement; - if (idReference != null) - return idReference; - idReference = context.SelectSingleNode("//*[@id=\"" + idValue + "\"]") as XmlElement; - if (idReference != null) - return idReference; - return context.SelectSingleNode("//*[@ID=\"" + idValue + "\"]") as XmlElement; - } - public override XmlElement GetIdElement(XmlDocument document, string idValue) { // We only care about Id references inside of the KeyInfo section @@ -320,9 +306,6 @@ internal class SignedCmiManifest2 private const string Sha1SignatureMethodUri = @"http://www.w3.org/2000/09/xmldsig#rsa-sha1"; private const string Sha1DigestMethod = @"http://www.w3.org/2000/09/xmldsig#sha1"; - private const string wintrustPolicyFlagsRegPath = "Software\\Microsoft\\Windows\\CurrentVersion\\WinTrust\\Trust Providers\\Software Publishing"; - private const string wintrustPolicyFlagsRegName = "State"; - private SignedCmiManifest2() { } internal SignedCmiManifest2(XmlDocument manifestDom, bool useSha256) diff --git a/src/Tasks/NativeMethods.cs b/src/Tasks/NativeMethods.cs index f2308684706..9adcab120cc 100644 --- a/src/Tasks/NativeMethods.cs +++ b/src/Tasks/NativeMethods.cs @@ -779,7 +779,9 @@ internal struct CRYPTOAPI_BLOB #region PInvoke private const string Crypt32DLL = "crypt32.dll"; private const string Advapi32DLL = "advapi32.dll"; +#if !RUNTIME_TYPE_NETCORE private const string MscoreeDLL = "mscoree.dll"; +#endif //------------------------------------------------------------------------------ // CreateHardLink @@ -1127,9 +1129,9 @@ internal static extern int CreateAssemblyNameObject( [DllImport(MscoreeDLL, SetLastError = true, CharSet = CharSet.Unicode)] internal static extern uint GetFileVersion(String szFullPath, StringBuilder szBuffer, int cchBuffer, out uint dwLength); #endif - #endregion +#endregion - #region Methods +#region Methods #if FEATURE_HANDLEPROCESSCORRUPTEDSTATEEXCEPTIONS /// /// Given a pointer to a metadata blob, read the string parameter from it. Returns true if @@ -1250,8 +1252,8 @@ internal static unsafe int CorSigUncompressData(IntPtr data, out int uncompresse return count; } - #endregion - #region InternalClass +#endregion +#region InternalClass #if FEATURE_COM_INTEROP /// /// This class is a wrapper over the native GAC enumeration API. @@ -1491,6 +1493,6 @@ public static string AssemblyPathFromStrongName(string strongName) } } #endif - #endregion +#endregion } } diff --git a/src/Tasks/ResolveKeySource.cs b/src/Tasks/ResolveKeySource.cs index 676d5a4d249..95e3a2ecf68 100644 --- a/src/Tasks/ResolveKeySource.cs +++ b/src/Tasks/ResolveKeySource.cs @@ -24,7 +24,9 @@ namespace Microsoft.Build.Tasks public class ResolveKeySource : TaskExtension { private const string pfxFileExtension = ".pfx"; +#if !RUNTIME_TYPE_NETCORE private const string pfxFileContainerPrefix = "VS_KEY_"; +#endif #region Properties diff --git a/src/Tasks/ResolveSDKReference.cs b/src/Tasks/ResolveSDKReference.cs index 1a489c2c402..972b81c1d3c 100644 --- a/src/Tasks/ResolveSDKReference.cs +++ b/src/Tasks/ResolveSDKReference.cs @@ -661,16 +661,6 @@ internal class SDKReference : IEquatable /// private const string X64Arch = "X64"; - /// - /// X86 architecture name - /// - private const string X86Arch = "X86"; - - /// - /// ARM architecture name - /// - private const string ARMArch = "ARM"; - /// /// ANY CPU architecture name /// diff --git a/src/Tasks/ResourceHandling/MSBuildResXReader.cs b/src/Tasks/ResourceHandling/MSBuildResXReader.cs index f3f3d5db1ff..86dc5d50311 100644 --- a/src/Tasks/ResourceHandling/MSBuildResXReader.cs +++ b/src/Tasks/ResourceHandling/MSBuildResXReader.cs @@ -72,13 +72,8 @@ private static void ParseAssemblyAlias(Dictionary aliases, XEleme // Consts from https://github.com/dotnet/winforms/blob/16b192389b377c647ab3d280130781ab1a9d3385/src/System.Windows.Forms/src/System/Resources/ResXResourceWriter.cs#L46-L63 private const string Beta2CompatSerializedObjectMimeType = "text/microsoft-urt/psuedoml-serialized/base64"; private const string CompatBinSerializedObjectMimeType = "text/microsoft-urt/binary-serialized/base64"; - private const string CompatSoapSerializedObjectMimeType = "text/microsoft-urt/soap-serialized/base64"; private const string BinSerializedObjectMimeType = "application/x-microsoft.net.object.binary.base64"; - private const string SoapSerializedObjectMimeType = "application/x-microsoft.net.object.soap.base64"; - private const string DefaultSerializedObjectMimeType = BinSerializedObjectMimeType; private const string ByteArraySerializedObjectMimeType = "application/x-microsoft.net.object.bytearray.base64"; - private const string ResMimeType = "text/microsoft-resx"; - private const string StringTypeNamePrefix = "System.String, mscorlib,"; private const string StringTypeName40 = "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; private const string MemoryStreamTypeNamePrefix = "System.IO.MemoryStream, mscorlib,";