Skip to content

Commit

Permalink
Fix retrieving of trusted platform assemblies (#987)
Browse files Browse the repository at this point in the history
  • Loading branch information
josefpihrt committed Nov 12, 2022
1 parent ff8aaca commit f30b281
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fix ([RCS1080](https://github.com/JosefPihrt/Roslynator/blob/main/docs/analyzers/RCS1080.md)) when collection is derived from `List<T>` ([#986](https://github.com/josefpihrt/roslynator/pull/986).
- Fix retrieving of trusted platform assemblies - separator differs by OS ([#987](https://github.com/josefpihrt/roslynator/pull/987).

## [4.1.2] - 2022-10-31

Expand Down
3 changes: 2 additions & 1 deletion src/CommandLine/RuntimeMetadataReference.cs
Expand Up @@ -7,6 +7,7 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using Microsoft.CodeAnalysis;

namespace Roslynator
Expand All @@ -30,7 +31,7 @@ static ImmutableArray<string> CreateTrustedPlatformAssemblies()
// works only for .NET Core, it returns null for .NET Framework
return AppContext.GetData("TRUSTED_PLATFORM_ASSEMBLIES")?
.ToString()
.Split(';')
.Split(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ';' : ':')
.ToImmutableArray()
?? ImmutableArray<string>.Empty;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Tests/TestConsole/Program.cs
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
Expand Down Expand Up @@ -35,7 +36,7 @@ void M()
IEnumerable<PortableExecutableReference> metadataReferences = AppContext
.GetData("TRUSTED_PLATFORM_ASSEMBLIES")
.ToString()
.Split(';')
.Split(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ';' : ':')
.Select(f => MetadataReference.CreateFromFile(f));

Project project = workspace.CurrentSolution
Expand Down
3 changes: 2 additions & 1 deletion src/Tests/Testing.Common/RuntimeMetadataReference.cs
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using Microsoft.CodeAnalysis;

Expand All @@ -30,7 +31,7 @@ internal static class RuntimeMetadataReference
return AppContext
.GetData("TRUSTED_PLATFORM_ASSEMBLIES")
.ToString()
.Split(';')
.Split(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ';' : ':')
.ToImmutableDictionary(f => Path.GetFileName(f));
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Tools/CodeGeneration/CSharp/RuntimeMetadataReference.cs
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Collections.Immutable;
using System.IO;
using System.Runtime.InteropServices;
using Microsoft.CodeAnalysis;

namespace Roslynator.CodeGeneration.CSharp
Expand All @@ -18,7 +19,7 @@ internal static class RuntimeMetadataReference
return AppContext
.GetData("TRUSTED_PLATFORM_ASSEMBLIES")
.ToString()
.Split(';')
.Split(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ';' : ':')
.ToImmutableDictionary(f => Path.GetFileName(f));
}

Expand Down

0 comments on commit f30b281

Please sign in to comment.