Skip to content

Commit

Permalink
minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-englert committed Aug 15, 2024
1 parent 7ca77ff commit e61e6bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 3 additions & 3 deletions NuGetMonitor.Model/Services/ProjectService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,15 @@ private static IEnumerable<ProjectItemInTargetFramework> GetPackageReferenceItem
var version = projectItem.GetVersion() ?? projectItem.GetVersionOverride();
var project = projectItemInTargetFramework.Project;

if (version is null && project.CentralVersionMap.TryGetValue(id, out versionSource))
if (version is null && project.CentralVersionMap.TryGetValue(id, out var mappedVersion))
{
versionSource = mappedVersion;
version = versionSource.GetVersion();
}

// ! versionSource is checked above.
return version is null
? null
: new PackageReferenceEntry(id, version, versionSource!, projectItemInTargetFramework, projectItem.GetMetadataValue("Justification"), projectItem.GetIsPrivateAsset());
: new PackageReferenceEntry(id, version, versionSource, projectItemInTargetFramework, projectItem.GetMetadataValue("Justification"), projectItem.GetIsPrivateAsset());
}

internal static bool IsTrue(this ProjectProperty? property)
Expand Down
11 changes: 10 additions & 1 deletion src/ViewModels/PackageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public PackageViewModel(IGrouping<PackageReference, PackageReferenceEntry> items
public ICommand UpdateCommand => new DelegateCommand(() => IsUpdateAvailable, () => { NuGetMonitorViewModel.Update(this); });

// ! ProjectUrl is checked in CanExecute
public ICommand OpenProjectUrlCommand => new DelegateCommand(() => PackageInfo?.ProjectUrl != null, () => Process.Start(PackageInfo!.ProjectUrl.AbsoluteUri));
public ICommand OpenProjectUrlCommand => new DelegateCommand(() => PackageInfo?.ProjectUrl != null, OpenProjectUrl);

public PackageInfo? PackageInfo { get; private set; }

Expand Down Expand Up @@ -108,4 +108,13 @@ private async void OnPackageReferenceChanged()
// session cancelled
}
}

private void OpenProjectUrl()
{
var projectUrl = PackageInfo?.ProjectUrl;
if (projectUrl == null)
return;

Process.Start(projectUrl.AbsoluteUri);
}
}

0 comments on commit e61e6bd

Please sign in to comment.