From 68edc2d67739186d0bfffbae0d2bcb2a0cba9b4e Mon Sep 17 00:00:00 2001 From: Josef Pihrt Date: Sat, 12 Nov 2022 14:58:34 +0100 Subject: [PATCH 1/3] Fix fetching of trusted platform assemblies --- src/CommandLine/RuntimeMetadataReference.cs | 3 ++- src/Tests/TestConsole/Program.cs | 3 ++- src/Tests/Testing.Common/RuntimeMetadataReference.cs | 3 ++- src/Tools/CodeGeneration/CSharp/RuntimeMetadataReference.cs | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/CommandLine/RuntimeMetadataReference.cs b/src/CommandLine/RuntimeMetadataReference.cs index 9474d0a12a..3b41c49169 100644 --- a/src/CommandLine/RuntimeMetadataReference.cs +++ b/src/CommandLine/RuntimeMetadataReference.cs @@ -7,6 +7,7 @@ using System.IO; using System.Linq; using System.Reflection; +using System.Runtime.InteropServices; using Microsoft.CodeAnalysis; namespace Roslynator @@ -30,7 +31,7 @@ static ImmutableArray 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.Empty; } diff --git a/src/Tests/TestConsole/Program.cs b/src/Tests/TestConsole/Program.cs index 9759dae662..f6428d7cb7 100644 --- a/src/Tests/TestConsole/Program.cs +++ b/src/Tests/TestConsole/Program.cs @@ -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; @@ -35,7 +36,7 @@ void M() IEnumerable metadataReferences = AppContext .GetData("TRUSTED_PLATFORM_ASSEMBLIES") .ToString() - .Split(';') + .Split(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ';' : ':') .Select(f => MetadataReference.CreateFromFile(f)); Project project = workspace.CurrentSolution diff --git a/src/Tests/Testing.Common/RuntimeMetadataReference.cs b/src/Tests/Testing.Common/RuntimeMetadataReference.cs index 411e255c10..b768b79f6c 100644 --- a/src/Tests/Testing.Common/RuntimeMetadataReference.cs +++ b/src/Tests/Testing.Common/RuntimeMetadataReference.cs @@ -4,6 +4,7 @@ using System.Collections.Immutable; using System.IO; using System.Linq; +using System.Runtime.InteropServices; using System.Threading; using Microsoft.CodeAnalysis; @@ -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)); } } diff --git a/src/Tools/CodeGeneration/CSharp/RuntimeMetadataReference.cs b/src/Tools/CodeGeneration/CSharp/RuntimeMetadataReference.cs index 5c6db0f968..4a0ea2c858 100644 --- a/src/Tools/CodeGeneration/CSharp/RuntimeMetadataReference.cs +++ b/src/Tools/CodeGeneration/CSharp/RuntimeMetadataReference.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Immutable; using System.IO; +using System.Runtime.InteropServices; using Microsoft.CodeAnalysis; namespace Roslynator.CodeGeneration.CSharp @@ -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)); } From 969ad93dbf7728ceecb1fc42112b9cc2a73e5633 Mon Sep 17 00:00:00 2001 From: Josef Pihrt Date: Sat, 12 Nov 2022 14:59:47 +0100 Subject: [PATCH 2/3] Update changelog --- ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.md b/ChangeLog.md index 7e7ec8cb8d..dcba126af8 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -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` ([#986](https://github.com/josefpihrt/roslynator/pull/986). +- Fix fetching of trusted platform assemblies - separator differs by OS ([#987](https://github.com/josefpihrt/roslynator/pull/987). ## [4.1.2] - 2022-10-31 From f810c539df36f016921dbdedf00b3e60755bef3a Mon Sep 17 00:00:00 2001 From: Josef Pihrt Date: Sat, 12 Nov 2022 17:50:52 +0100 Subject: [PATCH 3/3] changelog --- ChangeLog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index dcba126af8..8914c8f2df 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -14,7 +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` ([#986](https://github.com/josefpihrt/roslynator/pull/986). -- Fix fetching of trusted platform assemblies - separator differs by OS ([#987](https://github.com/josefpihrt/roslynator/pull/987). +- Fix retrieving of trusted platform assemblies - separator differs by OS ([#987](https://github.com/josefpihrt/roslynator/pull/987). ## [4.1.2] - 2022-10-31