Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added null-value checks for collections and attributes. #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pcleckler
Copy link

@pcleckler pcleckler commented Jun 20, 2018

Could not get this to work in my VB.NET project until I added these checks. And apologies if this pull request generated work (forgive a newbie). Changes to NuGetUpgraderPackage.cs are the only necessary changes to the master branch of the head fork.

Copy link
Contributor

@robertmclaws robertmclaws left a comment

Choose a reason for hiding this comment

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

Hey, thanks so much for this contribution. I have some comments inline, and if we can get these adjustments made, we can roll it out to users very quickly.

Again, thanks so much!

@@ -90,6 +90,7 @@
<Generator>VsixManifestGenerator</Generator>
<LastGenOutput>source.extension.resx</LastGenOutput>
</None>
<None Include="VersionKeeper.config" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this from the project.

@@ -192,6 +193,7 @@
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this from the project.

@@ -242,6 +244,12 @@
</Target>
<Import Project="..\packages\Microsoft.VSSDK.BuildTools.15.1.192\build\Microsoft.VSSDK.BuildTools.targets" Condition="'$(VisualStudioVersion)' != '14.0' And Exists('..\packages\Microsoft.VSSDK.BuildTools.15.1.192\build\Microsoft.VSSDK.BuildTools.targets')" />
<Import Project="..\packages\Microsoft.VisualStudio.Sdk.BuildTasks.14.0.14.0.215\build\Microsoft.VisualStudio.Sdk.BuildTasks.14.0.targets" Condition="'$(VisualStudioVersion)' == '14.0' And Exists('..\packages\Microsoft.VisualStudio.Sdk.BuildTasks.14.0.14.0.215\build\Microsoft.VisualStudio.Sdk.BuildTasks.14.0.targets')" />
<PropertyGroup>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this section from the project.

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this file from the project.

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this file from the project.

<DisplayName>NuGet PackageReference Upgrader</DisplayName>
<Description xml:space="preserve">A VS2017 Extension that helps legacy apps migrate off of packages.config. </Description>
<MoreInfo>https://github.com/pcleckler/PackageReferenceUpgrader</MoreInfo>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this from the project. I will identify your contribution elsewhere.

@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="bae2a4ae-be17-4f34-be32-f7f103918589" Version="1.0.0" Language="en-US" Publisher="Robert McLaws" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Please undo this change.

@@ -175,16 +175,19 @@ private void UpgradePackagesConfig()
new XAttribute("Version", row.Attribute("version").Value)));

//RWM: Remove the old Standard Reference.
oldReferences.Where(c => c.Attribute("Include").Value.Split(new Char[] { ',' })[0].ToLower() == row.Attribute("id").Value.ToLower()).ToList()
if (oldReferences != null) oldReferences.Where(c => c.Attribute("Include") != null).Where(c => c.Attribute("Include").Value.Split(new Char[] { ',' })[0].ToLower() == row.Attribute("id").Value.ToLower()).ToList()
Copy link
Contributor

Choose a reason for hiding this comment

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

Were there exceptions happening here? Because of the way LINQ works, I assumed that oldReferences would be a blank collection 100% of the time.

Two observations:

  1. There is only one situation where you should EVER do an if statement without braces: when you're checking parameters to short-circuit a function. (if (someParameter == null) return;), If you go outside of that rule, you risk creating the exact same issue that affected OpenSSL.
  2. This is great, and I really appreciate it. Wouldn't this be easier by just using a null conditional operator (oldReferences?.Where(...))?

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.

2 participants