Skip to content

Commit

Permalink
Enable GenerateDocumentationFile (#6000)
Browse files Browse the repository at this point in the history
Enable GenerateDocumentationFile, allowing for IDE0005 to be caught during builds. Cleaned up unnecessary using statements. 

Co-authored-by: Andy Zivkovic <zivkan@users.noreply.github.com>
  • Loading branch information
jgonz120 and zivkan authored Sep 9, 2024
1 parent e2f077a commit c8dccb7
Show file tree
Hide file tree
Showing 114 changed files with 422 additions and 144 deletions.
4 changes: 2 additions & 2 deletions build/Shared/TaskResultCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal sealed class TaskResultCache<TKey, TValue>
private readonly ConcurrentDictionary<TKey, object> _perTaskLock;

/// <summary>
/// Initializes a new instance of the <see cref="ResultCache{TKey, TValue}" /> class with the specified key comparer.
/// Initializes a new instance of the <see cref="TaskResultCache{TKey, TValue}" /> class with the specified key comparer.
/// </summary>
/// <param name="comparer">An <see cref="IEqualityComparer{T}" /> to use when comparing keys.</param>
public TaskResultCache(IEqualityComparer<TKey> comparer)
Expand All @@ -39,7 +39,7 @@ public TaskResultCache(IEqualityComparer<TKey> comparer)
}

/// <summary>
/// Initializes a new instance of the <see cref="ResultCache{TKey, TValue}" /> class.
/// Initializes a new instance of the <see cref="TaskResultCache{TKey, TValue}" /> class.
/// </summary>
public TaskResultCache()
{
Expand Down
6 changes: 6 additions & 0 deletions build/common.project.props
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@
<VsixPublishDestination>$(ArtifactRoot)$(VsixOutputDirName)\</VsixPublishDestination>
</PropertyGroup>

<!-- Write out .XML files for projects all projects, required to enforce IDE0005 on build. -->
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DocumentationFile Condition=" '$(DocumentationFile)' == '' AND '$(IsNetCoreProject)' != 'true' ">$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>

<!-- Set the output location for all non-test projects -->
<!-- Test projects currently fail when the output dir is moved -->
<PropertyGroup Condition=" '$(TestProject)' != 'true' OR '$(Shipping)' == 'true'">
Expand Down
12 changes: 5 additions & 7 deletions build/common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,7 @@
<SymbolTargetsToGetPdbs Condition="'$(SymbolTargetsToGetPdbs)' == ''">GetDebugSymbolsProjectOutput</SymbolTargetsToGetPdbs>
<LocTargets>GetBuildOutputWithLocMetadata</LocTargets>
</PropertyGroup>

<!-- Write out .XML files for projects that will be packed. -->
<PropertyGroup Condition=" '$(PackProject)' == 'true' ">
<GenerateDocumentationFile Condition=" '$(GenerateDocumentationFile)' == '' ">true</GenerateDocumentationFile>
<DocumentationFile Condition=" '$(DocumentationFile)' == '' AND '$(GenerateDocumentationFile)' == 'true' AND '$(IsNetCoreProject)' != 'true' ">$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>


<ImportGroup Condition=" '$(PackProject)' == 'true' AND '$(NuGetBuildTasksPackTargets)' != '' ">
<Import Project="$(NuGetBuildTasksPackTargets)" />
</ImportGroup>
Expand All @@ -45,6 +39,10 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<PropertyGroup Condition=" '$(PackProject)' != 'true' ">
<WarningsNotAsErrors>$(WarningsNotAsErrors);CS0419;CS1570;CS1572;CS1573;CS1574;CS1584;CS1587;CS1591</WarningsNotAsErrors>
</PropertyGroup>

<ItemGroup Condition=" '$(PackProject)' == 'true' ">
<None Include="$(MSBuildThisFileDirectory)..\icon.png" Pack="true" PackagePath="\" Visible="false" />
<None Include="$(MSBuildProjectDirectory)\README.md" Pack="true" PackagePath="\"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
using NuGet.PackageManagement.Telemetry;
using NuGet.Packaging;
using NuGet.Packaging.Core;
using NuGet.Packaging.Signing;
using NuGet.ProjectManagement;
using NuGet.ProjectManagement.Projects;
using NuGet.Protocol.Core.Types;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal ExperimentationConstants(string flightFlag, string flightEnvironmentVar

/// <summary>
/// The environment variable means of enabled this feature.
/// Might be <see cref="null"/>.
/// Might be <c>null</c>.
/// </summary>
internal string FlightEnvironmentVariable { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public interface IVsSolutionManager : ISolutionManager
IReadOnlyList<object> GetAllProjectRestoreInfoSources();

/// <summary>
/// Gets the current open solution directory. <see cref="null"/> if the there's no open solution.
/// Gets the current open solution directory. <c>null</c> if the there's no open solution.
/// </summary>
Task<string> GetSolutionDirectoryAsync();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public static async Task CollapseAllNodesAsync(IDictionary<string, ISet<VsHierar
/// <summary>
/// Gets all the hierarchies of all the NuGet compatible projects
/// </summary>
/// <param name="vsSolution">The VS Solution instance. Must not be <see cref="null"/>. </param>
/// <param name="vsSolution">The VS Solution instance. Must not be <c>null</c>. </param>
/// <returns>Hierarchies of the NuGet compatible projects</returns>
/// <remarks>This method assumes the solution is open.</remarks>
public static List<IVsHierarchy> GetAllLoadedProjects(IVsSolution vsSolution)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public interface IVsProjectAdapter
/// </summary>
/// <param name="itemName">The item name.</param>
/// <param name="metadataNames">The metadata names to read.</param>
/// <returns>An <see cref="IEnumerable{(string ItemId, string[] ItemMetadata)}"/> containing the itemId and the metadata values.</returns>
/// <returns>An <see cref="IEnumerable{T}"/> containing the itemId and the metadata values.</returns>
IEnumerable<(string ItemId, string[] ItemMetadata)> GetBuildItemInformation(string itemName, params string[] metadataNames);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal NuGetFeatureFlagConstants(string name, string environmentVariable, bool

/// <summary>
/// The environment variable used to override the enabled or disabled state of this feature.
/// Might be <see cref="null"/>.
/// Might be <c>null</c>.
/// </summary>
internal string EnvironmentVariable { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@

#nullable enable

using System;
using System.Threading;
using System.Threading.Tasks;

namespace NuGet.SolutionRestoreManager
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public interface IVsSolutionRestoreService5 : IVsSolutionRestoreService4
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
{
/// <summary>
/// An entry point used by CPS to indicate given project needs to be restored.
Expand Down
5 changes: 4 additions & 1 deletion src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Diagnostics;
using Microsoft.Build.Framework;
using NuGet.Commands;
using NuGet.Common;
using NuGet.Packaging;
using ILogger = NuGet.Common.ILogger;

#if DEBUG
using System.Diagnostics;
#endif

namespace NuGet.Build.Tasks.Pack
{
public class PackTask : Microsoft.Build.Utilities.Task, IPackTaskRequest<ITaskItem>
Expand Down
2 changes: 1 addition & 1 deletion src/NuGet.Core/NuGet.Build.Tasks/BuildTasksUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ public static string GetPackagesConfigFilePath(string projectFullPath)
/// <summary>
/// Gets the path to a packages.config for the specified project if one exists.
/// </summary>
/// <param name="projectFullPath">The full path to the project directory.</param>
/// <param name="projectDirectory">The full path to the project directory.</param>
/// <param name="projectName">The name of the project file.</param>
/// <returns>The path to the packages.config file if one exists, otherwise <see langword="null" />.</returns>
/// <exception cref="ArgumentNullException"><paramref name="projectDirectory" /> -or- <paramref name="projectName" /> is <see langword="null" />.</exception>
Expand Down
1 change: 1 addition & 0 deletions src/NuGet.Core/NuGet.Build.Tasks/ConsoleOutLogMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using Microsoft.Build.Framework;
using Newtonsoft.Json;

namespace NuGet.Build.Tasks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NuGet.Common;
using NuGet.Frameworks;

#if NETFRAMEWORK || NETSTANDARD
using System.Linq;
#endif

namespace NuGet.Build.Tasks
{
public class GetReferenceNearestTargetFrameworkTask : Microsoft.Build.Utilities.Task
Expand Down
5 changes: 4 additions & 1 deletion src/NuGet.Core/NuGet.Build.Tasks/RestoreTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
Expand All @@ -14,6 +13,10 @@
using NuGet.Common;
using NuGet.ProjectModel;

#if DEBUG
using System.Diagnostics;
#endif

namespace NuGet.Build.Tasks
{
/// <summary>
Expand Down
7 changes: 5 additions & 2 deletions src/NuGet.Core/NuGet.Build.Tasks/WriteRestoreGraphTask.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Microsoft.Build.Framework;
using Newtonsoft.Json;
using NuGet.Commands;

#if DEBUG
using System;
using System.Diagnostics;
#endif

namespace NuGet.Build.Tasks
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,7 @@ private UpdateLevel GetUpdateLevel(NuGetVersion resolvedVersion, NuGetVersion la
/// </summary>
/// <param name="package">The package to get the latest version for</param>
/// <param name="listPackageArgs">List args for the token and source provider></param>
/// <param name="packagesVersionsDict">A reference to the unique packages in the project
/// to be able to handle different sources having different latest versions</param>
/// <param name="cancellationToken"></param>
/// <returns>A list of tasks for all latest versions for packages from all sources</returns>
private async Task<KeyValuePair<string, List<IPackageSearchMetadata>>> GetPackageVersionsAsync(
string package,
Expand Down Expand Up @@ -573,8 +572,7 @@ private IList<Task> PrepareCurrentVersionsRequests(
/// <param name="packageSource">The source to look for packages at</param>
/// <param name="listPackageArgs">The list args for the cancellation token</param>
/// <param name="package">Package to look for updates for</param>
/// <param name="packagesVersionsDict">A reference to the unique packages in the project
/// to be able to handle different sources having different latest versions</param>
/// <param name="cancellationToken"></param>
/// <returns>An updated package with the highest version at a single source</returns>
private async Task<IEnumerable<IPackageSearchMetadata>> GetLatestVersionPerSourceAsync(
PackageSource packageSource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal interface IPackageSearchResultRenderer
/// Adds a message for a source, if search is unsuccessful.
/// </summary>
/// <param name="source">The source</param>
/// <param name="error">The error message to be rendered</param>
/// <param name="packageSearchProblem"></param>
/// <returns></returns>
void Add(PackageSource source, PackageSearchProblem packageSearchProblem);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public void Start()
/// </summary>
/// <param name="results">An enumerable of package search metadata to be processed and added to the table.</param>
/// <param name="table">The table where the results will be added as rows.</param>
/// <param name="verbosity">The verbosity level for the search results.</param>
private static async void PopulateTableWithResultsAsync(IEnumerable<IPackageSearchMetadata> results, Table table, PackageSearchVerbosity verbosity)
{
CultureInfo culture = CultureInfo.CurrentCulture;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ internal static class PackageSearchRunner
/// </summary>
/// <param name="sourceProvider">The provider for package sources.</param>
/// <param name="packageSearchArgs">Package search arguments</param>
/// <param name="cancellationToken"></param>
/// <returns>A task that represents the asynchronous operation.</returns>
public static async Task<int> RunAsync(
IPackageSourceProvider sourceProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ internal static class DependencyGraphPrinter
/// </summary>
/// <param name="dependencyGraphPerFramework">A dictionary mapping target frameworks to their dependency graphs.</param>
/// <param name="targetPackage">The package we want the dependency paths for.</param>
/// <param name="logger"></param>
public static void PrintAllDependencyGraphs(Dictionary<string, List<DependencyNode>?> dependencyGraphPerFramework, string targetPackage, ILoggerWithColor logger)
{
// print empty line
Expand All @@ -49,6 +50,7 @@ public static void PrintAllDependencyGraphs(Dictionary<string, List<DependencyNo
/// <param name="frameworks">The list of frameworks that share this dependency graph.</param>
/// <param name="topLevelNodes">The top-level package nodes of the dependency graph.</param>
/// <param name="targetPackage">The package we want the dependency paths for.</param>
/// <param name="logger"></param>
private static void PrintDependencyGraphPerFramework(List<string> frameworks, List<DependencyNode>? topLevelNodes, string targetPackage, ILoggerWithColor logger)
{
// print framework header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ private static void ValidateFrameworksOptionsExistInAssetsFile(LockFile assetsFi
/// <summary>
/// Returns the path to an assets file for the given project.
/// </summary>
/// <param name="project">Evaluated MSBuild project</param>
/// <param name="assetsFilePath"></param>
/// <param name="projectPath"></param>
/// <param name="logger">Logger for the 'why' command</param>
/// <returns>Assets file for the given project. Returns null if there was any issue finding or parsing the assets file.</returns>
private static LockFile? GetProjectAssetsFile(string assetsFilePath, string? projectPath, ILoggerWithColor logger)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ internal static class AddPackageCommandUtility
/// <param name="logger">Logger</param>
/// <param name="packageId">Package to look for</param>
/// <param name="prerelease">Whether to include prerelease versions</param>
/// <param name="cancellationToken"></param>
/// <returns>Return the latest version available from multiple sources and if no version is found returns null.</returns>

public static async Task<NuGetVersion> GetLatestVersionFromSourcesAsync(IList<PackageSource> sources, ILogger logger, string packageId, bool prerelease, CancellationToken cancellationToken)
Expand Down Expand Up @@ -63,6 +64,7 @@ public static async Task<NuGetVersion> GetLatestVersionFromSourcesAsync(IList<Pa
/// <param name="logger">Logger</param>
/// <param name="packageId">Package to look for</param>
/// <param name="prerelease">Whether to include prerelease versions</param>
/// <param name="cancellationToken"></param>
/// <returns>Returns the latest version available from a source or a null if non is found.</returns>
public static async Task<NuGetVersion> GetLatestVersionFromSourceAsync(PackageSource source, ILogger logger, string packageId, bool prerelease, CancellationToken cancellationToken)
{
Expand Down
5 changes: 4 additions & 1 deletion src/NuGet.Core/NuGet.Commands/Internal/HashCodeCombiner.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;

#if !NETFRAMEWORK && !NETSTANDARD
using System;
#endif

namespace Microsoft.Extensions.Internal
{
internal struct HashCodeCombiner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ private void AddCentralTransitiveDependencyGroupsForPackageReference(PackageSpec
/// </summary>
/// <param name="targetGraph">The <see cref="RestoreTargetGraph" /> to get centrally defined transitive dependencies for.</param>
/// <param name="targetFrameworkInformation">The <see cref="TargetFrameworkInformation" /> for the target framework to get centrally defined transitive dependencies for.</param>
/// <param name="centralPackageTransitivePinningEnabled">A value indicating whether or not central transitive dependency version pinning is enabled.</param>
/// <returns>An <see cref="IEnumerable{LibraryDependency}" /> representing the centrally defined transitive dependencies for the specified <see cref="RestoreTargetGraph" />.</returns>
private IEnumerable<LibraryDependency> GetLibraryDependenciesForCentralTransitiveDependencies(RestoreTargetGraph targetGraph, TargetFrameworkInformation targetFrameworkInformation)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ private static ProjectStyle GetProjectStyle(IMSBuildItem projectSpecItem)
/// </summary>
/// <param name="projectSpecItem">The <see cref="IMSBuildItem" /> to get the central package management settings from.</param>
/// <param name="projectStyle">The <see cref="ProjectStyle?" /> of the specified project. Specify <see langword="null" /> when the project does not define a restore style.</param>
/// <returns>A <see cref="Tuple{T1, T2, T3, T4}" /> containing values indicating whether or not central package management is enabled, if the ability to override a package version
/// <returns>A <see cref="Tuple{T1, T2, T3, T4}" /> containing values indicating whether or not central package management is enabled, if the ability to override a package version </returns>
public static (bool IsEnabled, bool IsVersionOverrideDisabled, bool IsCentralPackageTransitivePinningEnabled, bool isCentralPackageFloatingVersionsEnabled) GetCentralPackageManagementSettings(IMSBuildItem projectSpecItem, ProjectStyle projectStyle)
{
if (projectStyle == ProjectStyle.PackageReference)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#if IS_DESKTOP
using System.Security;
using System.Threading;
using System.Threading.Tasks;
#endif

namespace NuGet.Commands.SignCommand
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
using System.Threading.Tasks;
using NuGet.Common;
using NuGet.Configuration;
using NuGet.Packaging;
using NuGet.Packaging.Signing;
using NuGet.Protocol;
using static NuGet.Commands.TrustedSignersArgs;

#if IS_SIGNING_SUPPORTED
using NuGet.Packaging;
using NuGet.Protocol;
#endif

namespace NuGet.Commands
{
/// <summary>
Expand Down
5 changes: 4 additions & 1 deletion src/NuGet.Core/NuGet.Common/CryptoHashUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
using System;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Security.Cryptography;

#if !IS_CORECLR
using System.Reflection;
#endif

namespace NuGet.Common
{
public static class CryptoHashUtility
Expand Down
2 changes: 2 additions & 0 deletions src/NuGet.Core/NuGet.Common/NetworkProtocolUtility.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#if !IS_CORECLR
using System.Net;
#endif

namespace NuGet.Common
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public PackageSourceMappingProvider(ISettings settings)
/// <summary>
/// Supports the disabling of saving to disk for any <see cref="ISettings"/> changes.
/// </summary>
/// <param name="settings">The settings to be used by the provider.</param>
/// <param name="shouldSkipSave">True to avoid saving any changes to disk and only modify the <see cref="ISettings"/> in memory.
/// Default is false.</param>
public PackageSourceMappingProvider(ISettings settings, bool shouldSkipSave)
Expand Down
Loading

0 comments on commit c8dccb7

Please sign in to comment.