Skip to content

Commit 9746e7f

Browse files
Fix of warnings.
1 parent 1fe7a9b commit 9746e7f

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

CSharpRepl.Services/Nuget/NugetHelper.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

55
using System;
6+
using System.Diagnostics.CodeAnalysis;
67
using System.IO;
78
using System.Reflection;
89
using System.Runtime.Versioning;
@@ -31,7 +32,7 @@ public static RuntimeGraph GetRuntimeGraph(Action<string>? error)
3132
return new RuntimeGraph();
3233
}
3334

34-
public static NuGetFramework GetCurrentFramework()
35+
public static bool TryGetCurrentFramework([NotNullWhen(true)] out NuGetFramework? result)
3536
{
3637
var assembly = Assembly.GetEntryAssembly();
3738
if (assembly is null ||
@@ -41,6 +42,13 @@ public static NuGetFramework GetCurrentFramework()
4142
}
4243

4344
var targetFrameworkAttribute = assembly.GetCustomAttribute<TargetFrameworkAttribute>();
44-
return NuGetFramework.Parse(targetFrameworkAttribute?.FrameworkName);
45+
if (targetFrameworkAttribute is null)
46+
{
47+
result = null;
48+
return false;
49+
}
50+
51+
result = NuGetFramework.Parse(targetFrameworkAttribute.FrameworkName);
52+
return true;
4553
}
4654
}

CSharpRepl.Services/Nuget/NugetPackageInstaller.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public async Task<ImmutableArray<PortableExecutableReference>> InstallAsync(
5757
}
5858

5959
var nuGetProject = CreateFolderProject(targetFramework, Path.Combine(Configuration.ApplicationDirectory, "packages"));
60+
var settings = ReadSettings();
6061
var sourceRepositoryProvider = new SourceRepositoryProvider(new PackageSourceProvider(settings), Repository.Provider.GetCoreV3());
6162
var packageManager = CreatePackageManager(settings, nuGetProject, sourceRepositoryProvider);
6263

CSharpRepl.Services/Roslyn/MetadataResolvers/AssemblyReferenceMetadataResolver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ private static bool TryGetAssemblyCfgPath(string? assemblyPath, string extension
134134
{
135135
foreach (var assemblyGroup in runtimeLib.RuntimeAssemblyGroups)
136136
{
137-
if (runtimeGraph.AreCompatible(RuntimeInformation.RuntimeIdentifier, assemblyGroup.Runtime))
137+
if (runtimeGraph.AreCompatible(RuntimeInformation.RuntimeIdentifier, assemblyGroup.Runtime ?? ""))
138138
{
139139
foreach (var runtimeFile in assemblyGroup.RuntimeFiles)
140140
{

0 commit comments

Comments
 (0)