diff options
| author | Danny Milosavljevic <dannym@friendly-machines.com> | 2026-04-08 17:06:24 +0200 |
|---|---|---|
| committer | Danny Milosavljevic <dannym@friendly-machines.com> | 2026-07-17 01:41:57 +0200 |
| commit | d71affea0c59266b8fc75377c3e6d32878a29b56 (patch) | |
| tree | 6ae944e7d71a8b7e6b938ec4ed7fd7658e01a9d8 /gnu | |
| parent | ce5aae4199f0cbd08b6460f568fcbcdef58d9160 (diff) | |
gnu: Add roslyn@3.0.0.
* gnu/packages/patches/roslyn-3.0.0-bootstrap-with-csc-2.8.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add reference to it.
* gnu/packages/dotnet.scm (roslyn-3.0): New variable.
Change-Id: I385b29abff8c0b4672125786b948aafdd69cb014
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/local.mk | 1 | ||||
| -rw-r--r-- | gnu/packages/dotnet.scm | 174 | ||||
| -rw-r--r-- | gnu/packages/patches/roslyn-3.0.0-bootstrap-with-csc-2.8.patch | 321 |
3 files changed, 496 insertions, 0 deletions
diff --git a/gnu/local.mk b/gnu/local.mk index aca3d6cbef6..0046d700f4c 100644 --- a/gnu/local.mk +++ b/gnu/local.mk | |||
| @@ -2427,6 +2427,7 @@ dist_patch_DATA = \ | |||
| 2427 | %D%/packages/patches/roslyn-2.0.0-bootstrap-with-mono.patch \ | 2427 | %D%/packages/patches/roslyn-2.0.0-bootstrap-with-mono.patch \ |
| 2428 | %D%/packages/patches/roslyn-2.3.0-default-literal-for-csc-2.0.patch \ | 2428 | %D%/packages/patches/roslyn-2.3.0-default-literal-for-csc-2.0.patch \ |
| 2429 | %D%/packages/patches/roslyn-2.8.2-csharp-7.2-for-csc-2.3.patch \ | 2429 | %D%/packages/patches/roslyn-2.8.2-csharp-7.2-for-csc-2.3.patch \ |
| 2430 | %D%/packages/patches/roslyn-3.0.0-bootstrap-with-csc-2.8.patch \ | ||
| 2430 | %D%/packages/patches/rottlog-direntry.patch \ | 2431 | %D%/packages/patches/rottlog-direntry.patch \ |
| 2431 | %D%/packages/patches/ruby-actionpack-remove-browser-tests.patch \ | 2432 | %D%/packages/patches/ruby-actionpack-remove-browser-tests.patch \ |
| 2432 | %D%/packages/patches/ruby-activesupport-fix-deprecation-warning.patch \ | 2433 | %D%/packages/patches/ruby-activesupport-fix-deprecation-warning.patch \ |
diff --git a/gnu/packages/dotnet.scm b/gnu/packages/dotnet.scm index 2564dc2f33f..b914d29fe60 100644 --- a/gnu/packages/dotnet.scm +++ b/gnu/packages/dotnet.scm | |||
| @@ -2783,6 +2783,180 @@ namespace Microsoft.DiaSymReader | |||
| 2783 | "This package provides the Roslyn C# compiler (@command{csc}), built | 2783 | "This package provides the Roslyn C# compiler (@command{csc}), built |
| 2784 | from source using @code{roslyn-2.3} as the bootstrap compiler. It produces | 2784 | from source using @code{roslyn-2.3} as the bootstrap compiler. It produces |
| 2785 | a C# 7.2 compiler."))) | 2785 | a C# 7.2 compiler."))) |
| 2786 | |||
| 2787 | ;;; | ||
| 2788 | ;;; roslyn-3.0: inherits roslyn-2.8, built with csc 2.8 | ||
| 2789 | ;;; | ||
| 2790 | |||
| 2791 | (define-public roslyn-3.0 | ||
| 2792 | (package | ||
| 2793 | (inherit roslyn-2.8) | ||
| 2794 | (version "3.0.0") | ||
| 2795 | (source | ||
| 2796 | (origin | ||
| 2797 | (method git-fetch) | ||
| 2798 | (uri (git-reference | ||
| 2799 | (url "https://github.com/dotnet/roslyn") | ||
| 2800 | (commit (string-append "version-" version)))) | ||
| 2801 | (file-name (git-file-name "roslyn" version)) | ||
| 2802 | (sha256 | ||
| 2803 | (base32 | ||
| 2804 | "17x9bapqaaapa7jsb2sz9pm20swgj40naxlgci4nc9xh7brahcqw")) | ||
| 2805 | (patches | ||
| 2806 | (search-patches "roslyn-3.0.0-bootstrap-with-csc-2.8.patch")))) | ||
| 2807 | (native-inputs (list roslyn-2.8)) | ||
| 2808 | (arguments | ||
| 2809 | (substitute-keyword-arguments (package-arguments roslyn-2.8) | ||
| 2810 | ((#:phases phases '()) | ||
| 2811 | #~(modify-phases #$phases | ||
| 2812 | ;; No compiler-compat or mono-compat fixes needed for 3.0; | ||
| 2813 | ;; the patch handles ReadOnlySpan and other changes. | ||
| 2814 | ;; KeyValuePair helper was removed in 3.0. | ||
| 2815 | (replace 'fix-compiler-compat | ||
| 2816 | (lambda _ #t)) | ||
| 2817 | (replace 'fix-mono-compat | ||
| 2818 | (lambda _ | ||
| 2819 | ;; Only CodePagesEncodingProvider remains. | ||
| 2820 | (substitute* "src/Compilers/Core/Portable/EncodedStringText.cs" | ||
| 2821 | (("if \\(CodePagesEncodingProvider\\.Instance != null\\)") | ||
| 2822 | "if (false)") | ||
| 2823 | (("Encoding\\.RegisterProvider\\(CodePagesEncodingProvider\\.Instance\\);") | ||
| 2824 | "// not available in Mono")))) | ||
| 2825 | |||
| 2826 | ;; 3.0 has more files with PathUtilities ambiguity. | ||
| 2827 | (add-after 'fix-srm-inline 'fix-srm-inline-3.0 | ||
| 2828 | (lambda _ | ||
| 2829 | (substitute* (list | ||
| 2830 | "src/Compilers/Core/Portable/StrongName/DesktopStrongNameProvider.cs" | ||
| 2831 | "src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerFileReference.cs") | ||
| 2832 | (("\\bPathUtilities\\.") | ||
| 2833 | "Roslyn.Utilities.PathUtilities.")))) | ||
| 2834 | |||
| 2835 | ;; 3.0 has no stale files from 2.x. Only DiaSymReader COM | ||
| 2836 | ;; files need stubbing (inherited from create-diasymreader-stubs). | ||
| 2837 | ;; Rename file with trailing space in its name. | ||
| 2838 | (replace 'remove-stale-files | ||
| 2839 | (lambda _ | ||
| 2840 | (rename-file | ||
| 2841 | "src/Compilers/Core/Portable/Operations/IConstructorBodyOperation .cs" | ||
| 2842 | "src/Compilers/Core/Portable/Operations/IConstructorBodyOperation.cs") | ||
| 2843 | (for-each | ||
| 2844 | (lambda (f) (when (file-exists? f) (delete-file f))) | ||
| 2845 | '("src/Compilers/Core/Portable/DiaSymReader/Utilities/IUnsafeComStream.cs" | ||
| 2846 | "src/Compilers/Core/Portable/DiaSymReader/Utilities/ComMemoryStream.cs")))) | ||
| 2847 | |||
| 2848 | ;; csc.rsp: C# 7.3 langversion, NET472 define (was NET46 in 2.8). | ||
| 2849 | (replace 'create-csc-rsp | ||
| 2850 | (lambda _ | ||
| 2851 | (call-with-output-file "csc.rsp" | ||
| 2852 | (lambda (port) | ||
| 2853 | (display "-langversion:7.3\n-d:NET472\n" port))))) | ||
| 2854 | |||
| 2855 | ;; Point at roslyn-2.8's csc. | ||
| 2856 | (replace 'create-csc-wrapper | ||
| 2857 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 2858 | (mkdir-p "bootstrap-bin") | ||
| 2859 | (call-with-output-file "bootstrap-bin/csc" | ||
| 2860 | (lambda (port) | ||
| 2861 | (format port "#!~a~%exec mono ~a \"$@\"~%" | ||
| 2862 | (which "bash") | ||
| 2863 | (string-append (assoc-ref inputs "roslyn") "/lib/roslyn/csc.exe")))) | ||
| 2864 | (chmod "bootstrap-bin/csc" #o755) | ||
| 2865 | (setenv "PATH" | ||
| 2866 | (string-append (getcwd) "/bootstrap-bin:" | ||
| 2867 | (getenv "PATH"))))) | ||
| 2868 | |||
| 2869 | ;; 3.0 csc.exe needs additional shared files. | ||
| 2870 | (replace 'compile | ||
| 2871 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 2872 | (let* ((sci-dll | ||
| 2873 | (search-input-file | ||
| 2874 | inputs "/lib/mono/4.5/System.Collections.Immutable.dll")) | ||
| 2875 | (srm-dir | ||
| 2876 | (if (file-exists? "srm-src-patched") | ||
| 2877 | "srm-src-patched" | ||
| 2878 | #$%srm-source-dir)) | ||
| 2879 | (srm-source-files | ||
| 2880 | (filter | ||
| 2881 | (lambda (f) | ||
| 2882 | (not (or (string-contains f "netstandard") | ||
| 2883 | (string-contains f "netcoreapp") | ||
| 2884 | (string-contains f "AssemblyInfo") | ||
| 2885 | (string-suffix? "/SR.cs" f)))) | ||
| 2886 | (find-files srm-dir "\\.cs$"))) | ||
| 2887 | (deps-dir | ||
| 2888 | (if (file-exists? "src/Dependencies/CodeAnalysis.Metadata") | ||
| 2889 | "src/Dependencies/CodeAnalysis.Metadata" | ||
| 2890 | "src/Dependencies/CodeAnalysis.Debugging"))) | ||
| 2891 | |||
| 2892 | ;; 1. Microsoft.CodeAnalysis.dll | ||
| 2893 | (apply invoke "csc" "@csc.rsp" "-target:library" "-unsafe" | ||
| 2894 | "-out:Microsoft.CodeAnalysis.dll" | ||
| 2895 | (string-append | ||
| 2896 | "-resource:Microsoft.CodeAnalysis.CodeAnalysisResources.resources" | ||
| 2897 | ",Microsoft.CodeAnalysis.CodeAnalysisResources.resources") | ||
| 2898 | "-r:System.dll" "-r:System.Core.dll" | ||
| 2899 | "-r:System.Xml.dll" "-r:System.Xml.Linq.dll" | ||
| 2900 | "-r:System.Numerics.dll" "-r:System.IO.Compression.dll" | ||
| 2901 | "-r:System.Security.dll" | ||
| 2902 | "-r:System.Runtime.Serialization.dll" | ||
| 2903 | (string-append "-r:" sci-dll) | ||
| 2904 | "-d:COMPILERCORE" "-d:SRM" | ||
| 2905 | "bootstrap-sr.cs" "bootstrap-ivt.cs" | ||
| 2906 | "src/Compilers/Shared/CoreClrShim.cs" | ||
| 2907 | "src/Compilers/Shared/DesktopShim.cs" | ||
| 2908 | (append | ||
| 2909 | (find-files "src/Compilers/Core/Portable" "\\.cs$") | ||
| 2910 | (find-files "src/Compilers/Core/AnalyzerDriver" "\\.cs$") | ||
| 2911 | (find-files deps-dir "\\.cs$") | ||
| 2912 | (find-files "src/Dependencies/PooledObjects" "\\.cs$") | ||
| 2913 | srm-source-files)) | ||
| 2914 | |||
| 2915 | ;; 2. Microsoft.CodeAnalysis.CSharp.dll | ||
| 2916 | (apply invoke "csc" "@csc.rsp" "-target:library" "-unsafe" | ||
| 2917 | "-out:Microsoft.CodeAnalysis.CSharp.dll" | ||
| 2918 | (string-append | ||
| 2919 | "-resource:Microsoft.CodeAnalysis.CSharp.CSharpResources.resources" | ||
| 2920 | ",Microsoft.CodeAnalysis.CSharp.CSharpResources.resources") | ||
| 2921 | "-r:System.dll" "-r:System.Core.dll" | ||
| 2922 | "-r:System.Xml.dll" "-r:System.Xml.Linq.dll" | ||
| 2923 | "-r:System.Numerics.dll" "-r:System.IO.Compression.dll" | ||
| 2924 | (string-append "-r:" sci-dll) | ||
| 2925 | "-r:Microsoft.CodeAnalysis.dll" | ||
| 2926 | "bootstrap-csharp-ivt.cs" | ||
| 2927 | "src/Compilers/CSharp/CSharpAnalyzerDriver/CSharpDeclarationComputer.cs" | ||
| 2928 | (append | ||
| 2929 | (find-files "src/Compilers/CSharp/Portable" "\\.cs$") | ||
| 2930 | (if (file-exists? "generated") | ||
| 2931 | (find-files "generated" "\\.cs$") | ||
| 2932 | '()))) | ||
| 2933 | |||
| 2934 | ;; 3. csc.exe - 3.0 added RuntimeHostInfo and NamedPipeUtil. | ||
| 2935 | (invoke "csc" "@csc.rsp" "-out:csc.exe" | ||
| 2936 | "-r:System.dll" "-r:System.Core.dll" | ||
| 2937 | (string-append "-r:" sci-dll) | ||
| 2938 | "-r:Microsoft.CodeAnalysis.dll" | ||
| 2939 | "-r:Microsoft.CodeAnalysis.CSharp.dll" | ||
| 2940 | "src/Compilers/CSharp/csc/Program.cs" | ||
| 2941 | "src/Compilers/Shared/Csc.cs" | ||
| 2942 | "src/Compilers/Shared/BuildClient.cs" | ||
| 2943 | "src/Compilers/Shared/BuildServerConnection.cs" | ||
| 2944 | "src/Compilers/Shared/DesktopBuildClient.cs" | ||
| 2945 | "src/Compilers/Shared/DesktopAnalyzerAssemblyLoader.cs" | ||
| 2946 | "src/Compilers/Shared/ExitingTraceListener.cs" | ||
| 2947 | "src/Compilers/Shared/CoreClrShim.cs" | ||
| 2948 | "src/Compilers/Shared/DesktopShim.cs" | ||
| 2949 | "src/Compilers/Shared/RuntimeHostInfo.cs" | ||
| 2950 | "src/Compilers/Shared/NamedPipeUtil.cs" | ||
| 2951 | "src/Compilers/Core/CommandLine/BuildProtocol.cs" | ||
| 2952 | "src/Compilers/Core/CommandLine/NativeMethods.cs" | ||
| 2953 | "src/Compilers/Core/CommandLine/ConsoleUtil.cs" | ||
| 2954 | "src/Compilers/Core/CommandLine/CompilerServerLogger.cs")))))))) | ||
| 2955 | (synopsis "C# 8.0 compiler bootstrapped from source") | ||
| 2956 | (description | ||
| 2957 | "This package provides the Roslyn C# compiler (@command{csc}), built | ||
| 2958 | from source using @code{roslyn-2.8} as the bootstrap compiler. It produces | ||
| 2959 | a C# 8.0 compiler."))) | ||
| 2786 | ;; too new version: 15.9.21.664 | 2960 | ;; too new version: 15.9.21.664 |
| 2787 | ;; too old (no support for mono) version: 14.0 | 2961 | ;; too old (no support for mono) version: 14.0 |
| 2788 | (define-public msbuild | 2962 | (define-public msbuild |
diff --git a/gnu/packages/patches/roslyn-3.0.0-bootstrap-with-csc-2.8.patch b/gnu/packages/patches/roslyn-3.0.0-bootstrap-with-csc-2.8.patch new file mode 100644 index 00000000000..dac5687aaf8 --- /dev/null +++ b/gnu/packages/patches/roslyn-3.0.0-bootstrap-with-csc-2.8.patch | |||
| @@ -0,0 +1,321 @@ | |||
| 1 | Author: Danny Milosavljevic <dannym@friendly-machines.com> | ||
| 2 | Date: 2026-04-08 | ||
| 3 | Subject: Avoid ReadOnlySpan since mono runtime doesn't have it. Avoid CodePagesEncodingProvider. | ||
| 4 | |||
| 5 | diff -ruN '--exclude=*.resx' '--exclude=*.xlf' '--exclude=*.xml' '--exclude=*.rsp' '--exclude=srm-src-patched' '--exclude=*.resources' '--exclude=bootstrap-*' '--exclude=*.dll' '--exclude=*.exe' '--exclude=srm-strings.cs' '--exclude=generated' a/src/Compilers/Core/Portable/Collections/ImmutableArrayExtensions.cs b/src/Compilers/Core/Portable/Collections/ImmutableArrayExtensions.cs | ||
| 6 | --- a/src/Compilers/Core/Portable/Collections/ImmutableArrayExtensions.cs 2019-03-20 01:30:13.000000000 +0000 | ||
| 7 | +++ b/src/Compilers/Core/Portable/Collections/ImmutableArrayExtensions.cs 2026-04-08 04:40:30.652729285 +0000 | ||
| 8 | @@ -508,9 +508,9 @@ | ||
| 9 | // TODO(https://github.com/dotnet/corefx/issues/34126): Remove when System.Collections.Immutable | ||
| 10 | // provides a Span API | ||
| 11 | internal static T[] DangerousGetUnderlyingArray<T>(this ImmutableArray<T> array) | ||
| 12 | - => Unsafe.As<ImmutableArray<T>, ImmutableArrayProxy<T>>(ref array).MutableArray; | ||
| 13 | + => array.ToArray(); | ||
| 14 | |||
| 15 | - internal static ReadOnlySpan<T> AsSpan<T>(this ImmutableArray<T> array) | ||
| 16 | + internal static T[] AsSpan<T>(this ImmutableArray<T> array) | ||
| 17 | => array.DangerousGetUnderlyingArray(); | ||
| 18 | |||
| 19 | internal static Dictionary<K, ImmutableArray<T>> ToDictionary<K, T>(this ImmutableArray<T> items, Func<T, K> keySelector, IEqualityComparer<K> comparer = null) | ||
| 20 | diff -ruN '--exclude=*.resx' '--exclude=*.xlf' '--exclude=*.xml' '--exclude=*.rsp' '--exclude=srm-src-patched' '--exclude=*.resources' '--exclude=bootstrap-*' '--exclude=*.dll' '--exclude=*.exe' '--exclude=srm-strings.cs' '--exclude=generated' a/src/Compilers/Core/Portable/DiaSymReader/Writer/SymUnmanagedWriter.cs b/src/Compilers/Core/Portable/DiaSymReader/Writer/SymUnmanagedWriter.cs | ||
| 21 | --- a/src/Compilers/Core/Portable/DiaSymReader/Writer/SymUnmanagedWriter.cs 2019-03-20 01:30:13.000000000 +0000 | ||
| 22 | +++ b/src/Compilers/Core/Portable/DiaSymReader/Writer/SymUnmanagedWriter.cs 2026-04-08 04:40:30.662352748 +0000 | ||
| 23 | @@ -44,7 +44,7 @@ | ||
| 24 | /// <exception cref="ObjectDisposedException">Object has been disposed.</exception> | ||
| 25 | /// <exception cref="InvalidOperationException">Writes are not allowed to the underlying stream.</exception> | ||
| 26 | /// <exception cref="SymUnmanagedWriterException">Error occurred while writing PDB data.</exception> | ||
| 27 | - public abstract int DefineDocument(string name, Guid language, Guid vendor, Guid type, Guid algorithmId, ReadOnlySpan<byte> checksum, ReadOnlySpan<byte> source); | ||
| 28 | + public abstract int DefineDocument(string name, Guid language, Guid vendor, Guid type, Guid algorithmId, byte[] checksum, byte[] source); | ||
| 29 | |||
| 30 | /// <summary> | ||
| 31 | /// Defines sequence points. | ||
| 32 | @@ -127,8 +127,8 @@ | ||
| 33 | int moveNextMethodToken, | ||
| 34 | int kickoffMethodToken, | ||
| 35 | int catchHandlerOffset, | ||
| 36 | - ReadOnlySpan<int> yieldOffsets, | ||
| 37 | - ReadOnlySpan<int> resumeOffsets); | ||
| 38 | + int[] yieldOffsets, | ||
| 39 | + int[] resumeOffsets); | ||
| 40 | |||
| 41 | /// <summary> | ||
| 42 | /// Associates custom debug information blob with the current method. | ||
| 43 | diff -ruN '--exclude=*.resx' '--exclude=*.xlf' '--exclude=*.xml' '--exclude=*.rsp' '--exclude=srm-src-patched' '--exclude=*.resources' '--exclude=bootstrap-*' '--exclude=*.dll' '--exclude=*.exe' '--exclude=srm-strings.cs' '--exclude=generated' a/src/Compilers/Core/Portable/DiaSymReader/Writer/SymUnmanagedWriterImpl.cs b/src/Compilers/Core/Portable/DiaSymReader/Writer/SymUnmanagedWriterImpl.cs | ||
| 44 | --- a/src/Compilers/Core/Portable/DiaSymReader/Writer/SymUnmanagedWriterImpl.cs 2019-03-20 01:30:13.000000000 +0000 | ||
| 45 | +++ b/src/Compilers/Core/Portable/DiaSymReader/Writer/SymUnmanagedWriterImpl.cs 2026-04-08 04:41:40.581693982 +0000 | ||
| 46 | @@ -137,7 +137,7 @@ | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | - public override int DefineDocument(string name, Guid language, Guid vendor, Guid type, Guid algorithmId, ReadOnlySpan<byte> checksum, ReadOnlySpan<byte> source) | ||
| 51 | + public override int DefineDocument(string name, Guid language, Guid vendor, Guid type, Guid algorithmId, byte[] checksum, byte[] source) | ||
| 52 | { | ||
| 53 | if (name == null) | ||
| 54 | { | ||
| 55 | @@ -468,8 +468,8 @@ | ||
| 56 | int moveNextMethodToken, | ||
| 57 | int kickoffMethodToken, | ||
| 58 | int catchHandlerOffset, | ||
| 59 | - ReadOnlySpan<int> yieldOffsets, | ||
| 60 | - ReadOnlySpan<int> resumeOffsets) | ||
| 61 | + int[] yieldOffsets, | ||
| 62 | + int[] resumeOffsets) | ||
| 63 | { | ||
| 64 | if (yieldOffsets == null) throw new ArgumentNullException(nameof(yieldOffsets)); | ||
| 65 | if (resumeOffsets == null) throw new ArgumentNullException(nameof(resumeOffsets)); | ||
| 66 | diff -ruN '--exclude=*.resx' '--exclude=*.xlf' '--exclude=*.xml' '--exclude=*.rsp' '--exclude=srm-src-patched' '--exclude=*.resources' '--exclude=bootstrap-*' '--exclude=*.dll' '--exclude=*.exe' '--exclude=srm-strings.cs' '--exclude=generated' a/src/Compilers/Core/Portable/InternalUtilities/Hash.cs b/src/Compilers/Core/Portable/InternalUtilities/Hash.cs | ||
| 67 | --- a/src/Compilers/Core/Portable/InternalUtilities/Hash.cs 2019-03-20 01:30:13.000000000 +0000 | ||
| 68 | +++ b/src/Compilers/Core/Portable/InternalUtilities/Hash.cs 2026-04-08 04:40:30.590942249 +0000 | ||
| 69 | @@ -180,7 +180,7 @@ | ||
| 70 | /// <param name="data">The sequence of bytes that are likely to be ASCII text.</param> | ||
| 71 | /// <param name="isAscii">True if the sequence contains only characters in the ASCII range.</param> | ||
| 72 | /// <returns>The FNV-1a hash of <paramref name="data"/></returns> | ||
| 73 | - internal static int GetFNVHashCode(ReadOnlySpan<byte> data, out bool isAscii) | ||
| 74 | + internal static int GetFNVHashCode(byte[] data, out bool isAscii) | ||
| 75 | { | ||
| 76 | int hashCode = Hash.FnvOffsetBias; | ||
| 77 | |||
| 78 | diff -ruN '--exclude=*.resx' '--exclude=*.xlf' '--exclude=*.xml' '--exclude=*.rsp' '--exclude=srm-src-patched' '--exclude=*.resources' '--exclude=bootstrap-*' '--exclude=*.dll' '--exclude=*.exe' '--exclude=srm-strings.cs' '--exclude=generated' a/src/Compilers/Core/Portable/InternalUtilities/LittleEndianReader.cs b/src/Compilers/Core/Portable/InternalUtilities/LittleEndianReader.cs | ||
| 79 | --- a/src/Compilers/Core/Portable/InternalUtilities/LittleEndianReader.cs 2019-03-20 01:30:13.000000000 +0000 | ||
| 80 | +++ b/src/Compilers/Core/Portable/InternalUtilities/LittleEndianReader.cs 2026-04-08 04:42:30.135720458 +0000 | ||
| 81 | @@ -1,62 +1,59 @@ | ||
| 82 | -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
| 83 | - | ||
| 84 | +// Bootstrap: rewritten to avoid ReadOnlySpan (csc 2.8 can't use its indexer). | ||
| 85 | using System; | ||
| 86 | -using Roslyn.Utilities; | ||
| 87 | -using static System.Buffers.Binary.BinaryPrimitives; | ||
| 88 | |||
| 89 | -namespace Microsoft.CodeAnalysis | ||
| 90 | +namespace Roslyn.Utilities | ||
| 91 | { | ||
| 92 | - /// <summary> | ||
| 93 | - /// A Span-compatible version of <see cref="System.IO.BinaryReader"/>. | ||
| 94 | - /// </summary> | ||
| 95 | - internal ref struct LittleEndianReader | ||
| 96 | + internal struct LittleEndianReader | ||
| 97 | { | ||
| 98 | - private ReadOnlySpan<byte> _span; | ||
| 99 | + private readonly byte[] _data; | ||
| 100 | + private int _offset; | ||
| 101 | |||
| 102 | - public LittleEndianReader(ReadOnlySpan<byte> span) | ||
| 103 | + public LittleEndianReader(byte[] data) | ||
| 104 | { | ||
| 105 | - _span = span; | ||
| 106 | + _data = data; | ||
| 107 | + _offset = 0; | ||
| 108 | } | ||
| 109 | |||
| 110 | internal uint ReadUInt32() | ||
| 111 | { | ||
| 112 | - var result = ReadUInt32LittleEndian(_span); | ||
| 113 | - _span = _span.Slice(sizeof(uint)); | ||
| 114 | + var result = (uint)(_data[_offset] | _data[_offset+1] << 8 | | ||
| 115 | + _data[_offset+2] << 16 | _data[_offset+3] << 24); | ||
| 116 | + _offset += sizeof(uint); | ||
| 117 | return result; | ||
| 118 | } | ||
| 119 | |||
| 120 | internal byte ReadByte() | ||
| 121 | { | ||
| 122 | - var result = _span[0]; | ||
| 123 | - _span = _span.Slice(sizeof(byte)); | ||
| 124 | - return result; | ||
| 125 | + return _data[_offset++]; | ||
| 126 | } | ||
| 127 | |||
| 128 | internal ushort ReadUInt16() | ||
| 129 | { | ||
| 130 | - var result = ReadUInt16LittleEndian(_span); | ||
| 131 | - _span = _span.Slice(sizeof(ushort)); | ||
| 132 | + var result = (ushort)(_data[_offset] | _data[_offset+1] << 8); | ||
| 133 | + _offset += sizeof(ushort); | ||
| 134 | return result; | ||
| 135 | } | ||
| 136 | |||
| 137 | - internal ReadOnlySpan<byte> ReadBytes(int byteCount) | ||
| 138 | + internal byte[] ReadBytes(int byteCount) | ||
| 139 | { | ||
| 140 | - var result = _span.Slice(0, byteCount); | ||
| 141 | - _span = _span.Slice(byteCount); | ||
| 142 | + var result = new byte[byteCount]; | ||
| 143 | + Array.Copy(_data, _offset, result, 0, byteCount); | ||
| 144 | + _offset += byteCount; | ||
| 145 | return result; | ||
| 146 | } | ||
| 147 | |||
| 148 | internal int ReadInt32() | ||
| 149 | { | ||
| 150 | - var result = ReadInt32LittleEndian(_span); | ||
| 151 | - _span = _span.Slice(sizeof(int)); | ||
| 152 | + var result = _data[_offset] | _data[_offset+1] << 8 | | ||
| 153 | + _data[_offset+2] << 16 | _data[_offset+3] << 24; | ||
| 154 | + _offset += sizeof(int); | ||
| 155 | return result; | ||
| 156 | } | ||
| 157 | |||
| 158 | - internal byte[] ReadReversed(int byteCount) | ||
| 159 | + internal byte[] ReadReversed(int count) | ||
| 160 | { | ||
| 161 | - var result = ReadBytes(byteCount).ToArray(); | ||
| 162 | - result.ReverseContents(); | ||
| 163 | + var result = ReadBytes(count); | ||
| 164 | + Array.Reverse(result); | ||
| 165 | return result; | ||
| 166 | } | ||
| 167 | } | ||
| 168 | diff -ruN '--exclude=*.resx' '--exclude=*.xlf' '--exclude=*.xml' '--exclude=*.rsp' '--exclude=srm-src-patched' '--exclude=*.resources' '--exclude=bootstrap-*' '--exclude=*.dll' '--exclude=*.exe' '--exclude=srm-strings.cs' '--exclude=generated' a/src/Compilers/Core/Portable/InternalUtilities/StringTable.cs b/src/Compilers/Core/Portable/InternalUtilities/StringTable.cs | ||
| 169 | --- a/src/Compilers/Core/Portable/InternalUtilities/StringTable.cs 2019-03-20 01:30:13.000000000 +0000 | ||
| 170 | +++ b/src/Compilers/Core/Portable/InternalUtilities/StringTable.cs 2026-04-08 04:45:58.668140916 +0000 | ||
| 171 | @@ -109,7 +109,7 @@ | ||
| 172 | |||
| 173 | internal string Add(char[] chars, int start, int len) | ||
| 174 | { | ||
| 175 | - var span = chars.AsSpan(start, len); | ||
| 176 | + var span = new string(chars, start, len).ToCharArray(); | ||
| 177 | var hashCode = Hash.GetFNVHashCode(chars, start, len); | ||
| 178 | |||
| 179 | // capture array to avoid extra range checks | ||
| 180 | @@ -295,7 +295,7 @@ | ||
| 181 | |||
| 182 | if (e != null) | ||
| 183 | { | ||
| 184 | - if (hash == hashCode && TextEquals(e, chars.AsSpan(start, len))) | ||
| 185 | + if (hash == hashCode && TextEquals(e, new string(chars, start, len).ToCharArray())) | ||
| 186 | { | ||
| 187 | break; | ||
| 188 | } | ||
| 189 | @@ -350,7 +350,7 @@ | ||
| 190 | return e; | ||
| 191 | } | ||
| 192 | |||
| 193 | - private static string FindSharedEntryASCII(int hashCode, ReadOnlySpan<byte> asciiChars) | ||
| 194 | + private static string FindSharedEntryASCII(int hashCode, byte[] asciiChars) | ||
| 195 | { | ||
| 196 | var arr = s_sharedTable; | ||
| 197 | int idx = SharedIdxFromHash(hashCode); | ||
| 198 | @@ -581,7 +581,7 @@ | ||
| 199 | return text; | ||
| 200 | } | ||
| 201 | |||
| 202 | - internal static string AddSharedUTF8(ReadOnlySpan<byte> bytes) | ||
| 203 | + internal static string AddSharedUTF8(byte[] bytes) | ||
| 204 | { | ||
| 205 | bool isAscii; | ||
| 206 | int hashCode = Hash.GetFNVHashCode(bytes, out isAscii); | ||
| 207 | @@ -598,13 +598,13 @@ | ||
| 208 | return AddSharedSlow(hashCode, bytes, isAscii); | ||
| 209 | } | ||
| 210 | |||
| 211 | - private static string AddSharedSlow(int hashCode, ReadOnlySpan<byte> utf8Bytes, bool isAscii) | ||
| 212 | + private static string AddSharedSlow(int hashCode, byte[] utf8Bytes, bool isAscii) | ||
| 213 | { | ||
| 214 | string text; | ||
| 215 | |||
| 216 | unsafe | ||
| 217 | { | ||
| 218 | - fixed (byte* bytes = &utf8Bytes.GetPinnableReference()) | ||
| 219 | + fixed (byte* bytes = utf8Bytes) | ||
| 220 | { | ||
| 221 | text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length); | ||
| 222 | } | ||
| 223 | @@ -711,7 +711,7 @@ | ||
| 224 | return true; | ||
| 225 | } | ||
| 226 | |||
| 227 | - internal static bool TextEqualsASCII(string text, ReadOnlySpan<byte> ascii) | ||
| 228 | + internal static bool TextEqualsASCII(string text, byte[] ascii) | ||
| 229 | { | ||
| 230 | #if DEBUG | ||
| 231 | for (var i = 0; i < ascii.Length; i++) | ||
| 232 | @@ -736,7 +736,7 @@ | ||
| 233 | return true; | ||
| 234 | } | ||
| 235 | |||
| 236 | - internal static bool TextEquals(string array, ReadOnlySpan<char> text) | ||
| 237 | - => text.Equals(array.AsSpan(), StringComparison.Ordinal); | ||
| 238 | + internal static bool TextEquals(string array, char[] text) | ||
| 239 | + => string.Equals(new string(text), array, StringComparison.Ordinal); | ||
| 240 | } | ||
| 241 | } | ||
| 242 | diff -ruN '--exclude=*.resx' '--exclude=*.xlf' '--exclude=*.xml' '--exclude=*.rsp' '--exclude=srm-src-patched' '--exclude=*.resources' '--exclude=bootstrap-*' '--exclude=*.dll' '--exclude=*.exe' '--exclude=srm-strings.cs' '--exclude=generated' a/src/Compilers/Core/Portable/InternalUtilities/TextKeyedCache.cs b/src/Compilers/Core/Portable/InternalUtilities/TextKeyedCache.cs | ||
| 243 | --- a/src/Compilers/Core/Portable/InternalUtilities/TextKeyedCache.cs 2019-03-20 01:30:13.000000000 +0000 | ||
| 244 | +++ b/src/Compilers/Core/Portable/InternalUtilities/TextKeyedCache.cs 2026-04-08 04:43:25.581261044 +0000 | ||
| 245 | @@ -118,7 +118,7 @@ | ||
| 246 | |||
| 247 | if (text != null && localSlot.HashCode == hashCode) | ||
| 248 | { | ||
| 249 | - if (StringTable.TextEquals(text, chars.AsSpan(start, len))) | ||
| 250 | + if (StringTable.TextEquals(text, new string(chars, start, len).ToCharArray())) | ||
| 251 | { | ||
| 252 | return localSlot.Item; | ||
| 253 | } | ||
| 254 | @@ -155,7 +155,7 @@ | ||
| 255 | |||
| 256 | if (e != null) | ||
| 257 | { | ||
| 258 | - if (hash == hashCode && StringTable.TextEquals(e.Text, chars.AsSpan(start, len))) | ||
| 259 | + if (hash == hashCode && StringTable.TextEquals(e.Text, new string(chars, start, len).ToCharArray())) | ||
| 260 | { | ||
| 261 | break; | ||
| 262 | } | ||
| 263 | diff -ruN '--exclude=*.resx' '--exclude=*.xlf' '--exclude=*.xml' '--exclude=*.rsp' '--exclude=srm-src-patched' '--exclude=*.resources' '--exclude=bootstrap-*' '--exclude=*.dll' '--exclude=*.exe' '--exclude=srm-strings.cs' '--exclude=generated' a/src/Compilers/Core/Portable/MetadataReader/PEModule.cs b/src/Compilers/Core/Portable/MetadataReader/PEModule.cs | ||
| 264 | --- a/src/Compilers/Core/Portable/MetadataReader/PEModule.cs 2019-03-20 01:30:13.000000000 +0000 | ||
| 265 | +++ b/src/Compilers/Core/Portable/MetadataReader/PEModule.cs 2026-04-08 04:40:42.540150457 +0000 | ||
| 266 | @@ -3151,7 +3151,7 @@ | ||
| 267 | |||
| 268 | public unsafe override string GetString(byte* bytes, int byteCount) | ||
| 269 | { | ||
| 270 | - return StringTable.AddSharedUTF8(new ReadOnlySpan<byte>(bytes, byteCount)); | ||
| 271 | + var arr = new byte[byteCount]; System.Runtime.InteropServices.Marshal.Copy((System.IntPtr)bytes, arr, 0, byteCount); return StringTable.AddSharedUTF8(arr); | ||
| 272 | } | ||
| 273 | } | ||
| 274 | |||
| 275 | diff -ruN '--exclude=*.resx' '--exclude=*.xlf' '--exclude=*.xml' '--exclude=*.rsp' '--exclude=srm-src-patched' '--exclude=*.resources' '--exclude=bootstrap-*' '--exclude=*.dll' '--exclude=*.exe' '--exclude=srm-strings.cs' '--exclude=generated' a/src/Compilers/Core/Portable/NativePdbWriter/PdbWriter.cs b/src/Compilers/Core/Portable/NativePdbWriter/PdbWriter.cs | ||
| 276 | --- a/src/Compilers/Core/Portable/NativePdbWriter/PdbWriter.cs 2019-03-20 01:30:13.000000000 +0000 | ||
| 277 | +++ b/src/Compilers/Core/Portable/NativePdbWriter/PdbWriter.cs 2026-04-08 04:40:30.630288586 +0000 | ||
| 278 | @@ -573,8 +573,8 @@ | ||
| 279 | } | ||
| 280 | |||
| 281 | Guid algorithmId; | ||
| 282 | - ReadOnlySpan<byte> checksum; | ||
| 283 | - ReadOnlySpan<byte> embeddedSource; | ||
| 284 | + byte[] checksum; | ||
| 285 | + byte[] embeddedSource; | ||
| 286 | |||
| 287 | DebugSourceInfo info = document.GetSourceInfo(); | ||
| 288 | if (!info.Checksum.IsDefault) | ||
| 289 | diff -ruN '--exclude=*.resx' '--exclude=*.xlf' '--exclude=*.xml' '--exclude=*.rsp' '--exclude=srm-src-patched' '--exclude=*.resources' '--exclude=bootstrap-*' '--exclude=*.dll' '--exclude=*.exe' '--exclude=srm-strings.cs' '--exclude=generated' a/src/Compilers/Core/Portable/StrongName/CryptoBlobParser.cs b/src/Compilers/Core/Portable/StrongName/CryptoBlobParser.cs | ||
| 290 | --- a/src/Compilers/Core/Portable/StrongName/CryptoBlobParser.cs 2019-03-20 01:30:13.000000000 +0000 | ||
| 291 | +++ b/src/Compilers/Core/Portable/StrongName/CryptoBlobParser.cs 2026-04-08 04:41:40.581488708 +0000 | ||
| 292 | @@ -153,7 +153,7 @@ | ||
| 293 | uint magic, | ||
| 294 | uint bitLen, | ||
| 295 | uint pubExp, | ||
| 296 | - ReadOnlySpan<byte> pubKeyData) | ||
| 297 | + byte[] pubKeyData) | ||
| 298 | { | ||
| 299 | var w = new BlobWriter(3 * sizeof(uint) + s_offsetToKeyData + pubKeyData.Length); | ||
| 300 | w.WriteUInt32(AlgorithmId.RsaSign); | ||
| 301 | @@ -250,7 +250,7 @@ | ||
| 302 | /// Helper for RsaCryptoServiceProvider.ExportParameters() | ||
| 303 | /// Copied from https://github.com/dotnet/corefx/blob/5fe5f9aae7b2987adc7082f90712b265bee5eefc/src/System.Security.Cryptography.Csp/src/System/Security/Cryptography/CapiHelper.Shared.cs | ||
| 304 | /// </summary> | ||
| 305 | - internal static RSAParameters ToRSAParameters(this ReadOnlySpan<byte> cspBlob, bool includePrivateParameters) | ||
| 306 | + internal static RSAParameters ToRSAParameters(this byte[] cspBlob, bool includePrivateParameters) | ||
| 307 | { | ||
| 308 | var br = new LittleEndianReader(cspBlob); | ||
| 309 | |||
| 310 | diff -ruN '--exclude=*.resx' '--exclude=*.xlf' '--exclude=*.xml' '--exclude=*.rsp' '--exclude=srm-src-patched' '--exclude=*.resources' '--exclude=bootstrap-*' '--exclude=*.dll' '--exclude=*.exe' '--exclude=srm-strings.cs' '--exclude=generated' a/src/Compilers/Shared/DesktopBuildClient.cs b/src/Compilers/Shared/DesktopBuildClient.cs | ||
| 311 | --- a/src/Compilers/Shared/DesktopBuildClient.cs 2019-03-20 01:30:13.000000000 +0000 | ||
| 312 | +++ b/src/Compilers/Shared/DesktopBuildClient.cs 2026-04-08 04:48:35.412540299 +0000 | ||
| 313 | @@ -33,7 +33,7 @@ | ||
| 314 | { | ||
| 315 | // Register encodings for console | ||
| 316 | // https://github.com/dotnet/roslyn/issues/10785 | ||
| 317 | - System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); | ||
| 318 | + // CodePagesEncodingProvider not available in Mono | ||
| 319 | } | ||
| 320 | |||
| 321 | var client = new DesktopBuildClient(language, compileFunc, analyzerAssemblyLoader); | ||
