-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/8.0-staging' into merge/release/8.0-to-release/…
…8.0-staging
- Loading branch information
Showing
121 changed files
with
7,369 additions
and
648 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,9 +86,9 @@ jobs: | |
# Linux musl arm32 | ||
- ${{ if eq(parameters.platform, 'linux_musl_arm') }}: | ||
- ${{ if eq(variables['System.TeamProject'], 'public') }}: | ||
- (Alpine.315.Arm32.Open)[email protected]/dotnet-buildtools/prereqs:alpine-3.15-helix-arm32v7 | ||
- (Alpine.315.Arm32.Open)[email protected]/dotnet-buildtools/prereqs:alpine-3.15-helix-arm32v7-20230807201723-7ea784e | ||
- ${{ if eq(variables['System.TeamProject'], 'internal') }}: | ||
- (Alpine.315.Arm32)[email protected]/dotnet-buildtools/prereqs:alpine-3.15-helix-arm32v7 | ||
- (Alpine.315.Arm32)[email protected]/dotnet-buildtools/prereqs:alpine-3.15-helix-arm32v7-20230807201723-7ea784e | ||
|
||
# Linux musl arm64 | ||
- ${{ if eq(parameters.platform, 'linux_musl_arm64') }}: | ||
|
59 changes: 59 additions & 0 deletions
59
src/libraries/Common/src/SourceGenerators/CSharpSyntaxUtilities.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Globalization; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CSharp; | ||
|
||
namespace SourceGenerators; | ||
|
||
internal static class CSharpSyntaxUtilities | ||
{ | ||
// Standard format for double and single on non-inbox frameworks to ensure value is round-trippable. | ||
public const string DoubleFormatString = "G17"; | ||
public const string SingleFormatString = "G9"; | ||
|
||
// Format a literal in C# format -- works around https://github.com/dotnet/roslyn/issues/58705 | ||
public static string FormatLiteral(object? value, TypeRef type) | ||
{ | ||
if (value == null) | ||
{ | ||
return $"default({type.FullyQualifiedName})"; | ||
} | ||
|
||
switch (value) | ||
{ | ||
case string @string: | ||
return SymbolDisplay.FormatLiteral(@string, quote: true); ; | ||
case char @char: | ||
return SymbolDisplay.FormatLiteral(@char, quote: true); | ||
case double.NegativeInfinity: | ||
return "double.NegativeInfinity"; | ||
case double.PositiveInfinity: | ||
return "double.PositiveInfinity"; | ||
case double.NaN: | ||
return "double.NaN"; | ||
case double @double: | ||
return $"{@double.ToString(DoubleFormatString, CultureInfo.InvariantCulture)}D"; | ||
case float.NegativeInfinity: | ||
return "float.NegativeInfinity"; | ||
case float.PositiveInfinity: | ||
return "float.PositiveInfinity"; | ||
case float.NaN: | ||
return "float.NaN"; | ||
case float @float: | ||
return $"{@float.ToString(SingleFormatString, CultureInfo.InvariantCulture)}F"; | ||
case decimal @decimal: | ||
// we do not need to specify a format string for decimal as it's default is round-trippable on all frameworks. | ||
return $"{@decimal.ToString(CultureInfo.InvariantCulture)}M"; | ||
case bool @bool: | ||
return @bool ? "true" : "false"; | ||
default: | ||
// Assume this is a number. | ||
return FormatNumber(); | ||
} | ||
|
||
string FormatNumber() => $"({type.FullyQualifiedName})({Convert.ToString(value, CultureInfo.InvariantCulture)})"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.