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

Fix retrieving of trusted platform assemblies #987

Merged
merged 3 commits into from Nov 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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