diff --git a/ChangeLog.md b/ChangeLog.md index 7e7ec8cb8d..8914c8f2df 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 retrieving of trusted platform assemblies - separator differs by OS ([#987](https://github.com/josefpihrt/roslynator/pull/987). ## [4.1.2] - 2022-10-31 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)); }