Skip to content

add warning codes with nowarn support for pack - #2013

Merged
rohit21agrawal merged 12 commits into
devfrom
dev-ragrawal-packwarnings
Feb 14, 2018
Merged

rohit21agrawal merged 12 commits into
devfrom
dev-ragrawal-packwarnings

Conversation

@rohit21agrawal

@rohit21agrawal rohit21agrawal commented Feb 8, 2018 •

Copy link
Copy Markdown
Contributor

Fixes: NuGet/Home#6529

Adds support for NoWarn, TreatWarningsAsErrors and WarningsAsErrors properties in Pack that were only supported by restore until now. These properties also apply to packing nuspec if specified via the Properties command line option.

Will work on migrator rules and validation once this PR goes in.

@rohit21agrawal rohit21agrawal changed the title add warning codes with nowarn support for pack [WIP] add warning codes with nowarn support for pack Feb 8, 2018
@rohit21agrawal rohit21agrawal changed the title [WIP] add warning codes with nowarn support for pack add warning codes with nowarn support for pack Feb 9, 2018
else
{
var logMessage = message as IRestoreLogMessage;
var logMessage = message as INuGetLogMessage;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@nkolev92

Copy link
Copy Markdown
Member
                    {

Does this need to be something else?
A more generic impl?


Refers to: src/NuGet.Core/NuGet.Build.Tasks/Common/MSBuildLogger.cs:69 in 60826d9. [](commit_id = 60826d9, deletion_comment = False)

var logMessage = message as INuGetLogMessage;

if (logMessage == null)
{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line below, GH is not allowing me to comment no parts that weren't edited.

If the message is null, then a RestoreLogMessage is created. Should be a more generic one?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the only reason I let it stay is because I don't know why it would be null, but I was scared about breaking an existing code path. For packaging scenarios, I can guarantee it will never be null.

@nkolev92 nkolev92 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mishra14 mishra14 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small comments. Overall looks good! 🚀

IncludeSymbols = includeSymbols;
}
public bool IncludeSymbols { get; set; }
public bool IncludeSymbols { get; set; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: space


IConsole console = Logger as IConsole;
if (console != null && console.Verbosity == Verbosity.Detailed)
Path.GetFileName(TargetPath)), NuGetLogCode.NU5011));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can keep a variable at top that is used as the error code. It will be more manageable.

using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell.Interop;
using NuGet.Commands;
using NuGet.Common;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't look like this is being used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is, related to the refactoring

using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NuGet.Commands;
using NuGet.Common;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it used? I dont see any other change in the class.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

being used

using System.Collections.Generic;
using System.Text;
using NuGet.Commands;
using NuGet.Common;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here. Is this used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep

foreach (var file in builder.GetFiles())
{
string name = Path.GetFileName(file);
string dirName = Path.GetFileName(Path.GetDirectoryName(file));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var in the above 2 files?

{
public IEnumerable<PackLogMessage> Validate(PackageArchiveReader builder)
{
foreach (var file in builder.GetFiles())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can replace the whole forloop as a linq query -

var initPs1Files = builder.GetFiles()
      .Where(f => Path.GetFileName(file).Equals("init.ps1", StringComparison.OrdinalIgnoreCase))
      .Where(f => Directory.GetParent(path).Name.Equals(PackagingConstants.Folders.Tools, StringComparison.OrdinalIgnoreCase))
      .ForEach(f => yield return CreatePackageIssue(f));

{
string path = file.Path;
string directory = Path.GetDirectoryName(path);
var directory = Path.GetDirectoryName(file);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Directory.GetParent(path).Name would be more accurate, but it may not make a difference since lib it at the top level in the structure.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Directory.GetParent does actual disk I/O, so would be an expensive call here for doing just a string operation.

else
{
string name = Path.GetFileNameWithoutExtension(path);
string name = Path.GetFileNameWithoutExtension(file);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var?

using System.Text;
using System.Xml.Linq;
using NuGet.Commands;
using NuGet.Common;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.

@rohit21agrawal
rohit21agrawal force-pushed the dev-ragrawal-packwarnings branch from 7c7ec3d to 19c864a Compare February 12, 2018 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants