Skip to content

Commit

Permalink
feat: drop vs2019 support, add vs2022 support, fix aspnetcore/runtime…
Browse files Browse the repository at this point in the history
… sources search

Fixes: #13
  • Loading branch information
vchirikov committed Aug 22, 2021
1 parent e340760 commit 5604590
Show file tree
Hide file tree
Showing 11 changed files with 472 additions and 670 deletions.
8 changes: 0 additions & 8 deletions package.json

This file was deleted.

24 changes: 15 additions & 9 deletions src/GoToDnSpy/EnvDteExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal static class EnvDteExtensions
public static T FindByNameOrDefault<T>(this Properties properties, string name)
{
if (properties == null || string.IsNullOrEmpty(name))
return default;
return default!;

ThreadHelper.ThrowIfNotOnUIThread();

Expand All @@ -22,10 +22,10 @@ public static T FindByNameOrDefault<T>(this Properties properties, string name)

return (T) property.Value;
}
return default;
return default!;
}

public static ProjectItem FindByNameOrDefault(this ProjectItems collection, string name, bool recursive = false)
public static ProjectItem? FindByNameOrDefault(this ProjectItems collection, string name, bool recursive = false)
{
if (collection == null)
return null;
Expand All @@ -49,11 +49,11 @@ public static ProjectItem FindByNameOrDefault(this ProjectItems collection, stri
return null;
}

public static EnvDTE.ProjectItem FindProjectItemByNameOrDefault(this Project project, string name, bool recursive) // directory tree recursive find of files
public static ProjectItem? FindProjectItemByNameOrDefault(this Project project, string name, bool recursive) // directory tree recursive find of files
{
ThreadHelper.ThrowIfNotOnUIThread();
// if it's real project we can use find
if (project.Kind != EnvDTE.Constants.vsProjectKindSolutionItems)
if (project.Kind != Constants.vsProjectKindSolutionItems)
{
if (project.ProjectItems?.Count > 0)
return project.ProjectItems.FindByNameOrDefault(name, recursive);
Expand All @@ -76,11 +76,17 @@ public static EnvDTE.ProjectItem FindProjectItemByNameOrDefault(this Project pro
/// <summary>
/// Workaround from https://github.com/dotnet/project-system/issues/669
/// </summary>
private static string GetProjectPropertyNetCoreWorkaround(this Project project, string name)
private static string? GetProjectPropertyNetCoreWorkaround(this Project project, string name)
{
var unconfiguredProject = project.AsUnconfiguredProject();
if (unconfiguredProject == null)
return null;
var configuredProject = unconfiguredProject.GetSuggestedConfiguredProjectAsync().ConfigureAwait(false).GetAwaiter().GetResult();
var properties = configuredProject.Services.ProjectPropertiesProvider.GetCommonProperties();
if (configuredProject == null)
return null;
var properties = configuredProject.Services.ProjectPropertiesProvider?.GetCommonProperties();
if (properties == null)
return null;
return properties.GetEvaluatedPropertyValueAsync(name).ConfigureAwait(false).GetAwaiter().GetResult();
}

Expand All @@ -90,7 +96,7 @@ private static string GetProjectPropertyNetCoreWorkaround(this Project project,
/// <param name="project">EnvDTE proj</param>
/// <param name="name">The property name.</param>
/// <returns>string or null</returns>
public static string GetPropertyOrDefault(this Project project, string name)
public static string? GetPropertyOrDefault(this Project project, string name)
{
ThreadHelper.ThrowIfNotOnUIThread();
return (project.Properties.FindByNameOrDefault<string>(name)
Expand All @@ -106,7 +112,7 @@ public static string GetPropertyOrDefault(this Project project, string name)
/// </summary>
/// <param name="project">The project.</param>
/// <returns>output filepath</returns>
public static string GetOutputFilename(this Project project)
public static string? GetOutputFilename(this Project project)
{
ThreadHelper.ThrowIfNotOnUIThread();
return (project.Properties.FindByNameOrDefault<string>("OutputFileName") ?? project.GetProjectPropertyNetCoreWorkaround("TargetFileName"))?.Trim();
Expand Down
6 changes: 3 additions & 3 deletions src/GoToDnSpy/GACHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private static Dictionary<string, string> ReadGacAssemblyNames(string gacRoot)

foreach (var assemblyFile in Directory.EnumerateFiles(path, "*.dll", SearchOption.AllDirectories))
{
AssemblyName assemblyName = null;
AssemblyName? assemblyName = null;
try
{
assemblyName = AssemblyName.GetAssemblyName(assemblyFile);
Expand All @@ -57,9 +57,9 @@ private static Dictionary<string, string> ReadGacAssemblyNames(string gacRoot)
/// Search assemblyName in GAC folders.
/// First search in net framework 4, when search in gac net framework 2
/// </summary>
/// <param name="assemblyName">Assembly name for search</param>
/// <param name="assemblyFullName">Assembly name for search</param>
/// <returns>path to assembly or <c>null</c></returns>
public static string FindAssemblyInGac(string assemblyFullName)
public static string? FindAssemblyInGac(string assemblyFullName)
{
if (_gacNetframework4.Value.TryGetValue(assemblyFullName, out var result))
return result;
Expand Down
Loading

0 comments on commit 5604590

Please sign in to comment.