未验证 提交 d1c0fa82 编写于 作者: A Aaron Robinson 提交者: GitHub

Roslyn update response (#43056)

* Update function pointer syntax usage to official.

* Fix warnings with new Roslyn
Co-authored-by: NJan Kotas <jkotas@microsoft.com>
上级 850788e9
......@@ -30,6 +30,7 @@
release, increase this number by one.
-->
<NETStandardPatchVersion>0</NETStandardPatchVersion>
<MicrosoftNetCompilersToolsetVersion>3.8.0-4.20503.2</MicrosoftNetCompilersToolsetVersion>
</PropertyGroup>
<!--
Servicing build settings for Setup/Installer packages. Instructions:
......
......@@ -159,8 +159,8 @@ private static unsafe IntPtr CreateUnmanagedInstance()
void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * numCallbacks);
callbacks[0] = (delegate* <IntPtr, char*, int, int>)&getIntConfigValue;
callbacks[1] = (delegate* <IntPtr, char*, char*, int, int>)&getStringConfigValue;
callbacks[0] = (delegate* unmanaged<IntPtr, char*, int, int>)&getIntConfigValue;
callbacks[1] = (delegate* unmanaged<IntPtr, char*, char*, int, int>)&getStringConfigValue;
IntPtr instance = Marshal.AllocCoTaskMem(sizeof(IntPtr));
*(IntPtr*)instance = (IntPtr)callbacks;
......
......@@ -333,7 +333,7 @@ static IntPtr GetUnmanagedCallbacks()
int index = 0;
foreach (FunctionDecl decl in functionData)
{
tr.Write($" callbacks[{index}] = (delegate* <IntPtr, IntPtr*");
tr.Write($" callbacks[{index}] = (delegate* unmanaged<IntPtr, IntPtr*");
foreach (Parameter param in decl.Parameters)
{
tr.Write($", {param.Type.UnmanagedTypeName}");
......
......@@ -41,7 +41,7 @@ public static void RetryOnIOError(Action func)
public static void RetryOnWin32Error(Action func)
{
bool IsKnownIrrecoverableError(int hresult)
static bool IsKnownIrrecoverableError(int hresult)
{
// Error codes are defined in winerror.h
// The error code is stored in the lowest 16 bits of the HResult
......
......@@ -47,7 +47,7 @@ public static bool TryGetDefaultValue(ParameterInfo parameter, out object? defau
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2067:UnrecognizedReflectionPattern",
Justification = "CreateInstance is only called on a ValueType, which will always have a default constructor.")]
object? CreateValueType(Type t) => Activator.CreateInstance(t);
static object? CreateValueType(Type t) => Activator.CreateInstance(t);
// Handle nullable enums
if (defaultValue != null &&
......
......@@ -16,7 +16,7 @@ internal static partial class Globalization
internal static extern unsafe ResultCode GetCalendarInfo(string localeName, CalendarId calendarId, CalendarDataType calendarDataType, char* result, int resultCapacity);
[DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_EnumCalendarInfo")]
internal static extern unsafe bool EnumCalendarInfo(delegate* <char*, IntPtr, void> callback, string localeName, CalendarId calendarId, CalendarDataType calendarDataType, IntPtr context);
internal static extern unsafe bool EnumCalendarInfo(delegate* unmanaged<char*, IntPtr, void> callback, string localeName, CalendarId calendarId, CalendarDataType calendarDataType, IntPtr context);
[DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLatestJapaneseEra")]
internal static extern int GetLatestJapaneseEra();
......
......@@ -122,10 +122,10 @@ internal static unsafe partial class Kernel32
internal static extern int GetLocaleInfoEx(string lpLocaleName, uint LCType, void* lpLCData, int cchData);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
internal static extern bool EnumSystemLocalesEx(delegate* <char*, uint, void*, BOOL> lpLocaleEnumProcEx, uint dwFlags, void* lParam, IntPtr reserved);
internal static extern bool EnumSystemLocalesEx(delegate* unmanaged<char*, uint, void*, BOOL> lpLocaleEnumProcEx, uint dwFlags, void* lParam, IntPtr reserved);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
internal static extern bool EnumTimeFormatsEx(delegate* <char*, void*, BOOL> lpTimeFmtEnumProcEx, string lpLocaleName, uint dwFlags, void* lParam);
internal static extern bool EnumTimeFormatsEx(delegate* unmanaged<char*, void*, BOOL> lpTimeFmtEnumProcEx, string lpLocaleName, uint dwFlags, void* lParam);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
internal static extern int GetCalendarInfoEx(string? lpLocaleName, uint Calendar, IntPtr lpReserved, uint CalType, IntPtr lpCalData, int cchData, out int lpValue);
......@@ -140,7 +140,7 @@ internal static unsafe partial class Kernel32
internal static extern int GetGeoInfo(int location, int geoType, char* lpGeoData, int cchData, int LangId);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
internal static extern bool EnumCalendarInfoExEx(delegate* <char*, uint, IntPtr, void*, BOOL> pCalInfoEnumProcExEx, string lpLocaleName, uint Calendar, string? lpReserved, uint CalType, void* lParam);
internal static extern bool EnumCalendarInfoExEx(delegate* unmanaged<char*, uint, IntPtr, void*, BOOL> pCalInfoEnumProcExEx, string lpLocaleName, uint Calendar, string? lpReserved, uint CalType, void* lParam);
[StructLayout(LayoutKind.Sequential)]
internal struct NlsVersionInfoEx
......
......@@ -128,12 +128,12 @@ public static Encoding OutputEncoding
if (s_out != null && !s_isOutTextWriterRedirected)
{
s_out.Flush();
Volatile.Write(ref s_out, null);
Volatile.Write(ref s_out, null!);
}
if (s_error != null && !s_isErrorTextWriterRedirected)
{
s_error.Flush();
Volatile.Write(ref s_error, null);
Volatile.Write(ref s_error, null!);
}
Volatile.Write(ref s_outputEncoding, (Encoding)value.Clone());
......
......@@ -331,7 +331,7 @@ internal static string GetUntruncatedProcessName(ref Interop.procfs.ParsedStat s
}
}
string? GetUntruncatedNameFromArg(Span<byte> arg, string prefix)
static string? GetUntruncatedNameFromArg(Span<byte> arg, string prefix)
{
// Strip directory names from arg.
int nameStart = arg.LastIndexOf((byte)'/') + 1;
......
......@@ -144,7 +144,7 @@ public static partial class AsnDecoder
const byte SuffixState = 2;
byte state = HmsState;
byte? GetNextState(byte octet)
static byte? GetNextState(byte octet)
{
if (octet == 'Z' || octet == '-' || octet == '+')
{
......
......@@ -473,7 +473,7 @@ internal void Start(CancellationToken cancellationToken)
this._context = ExecutionContext.Capture();
ParsedEvent ParseEvent(byte* nativeEventPath)
static ParsedEvent ParseEvent(byte* nativeEventPath)
{
int byteCount = 0;
Debug.Assert(nativeEventPath != null);
......
......@@ -25,7 +25,7 @@ public static ValueTask<int> ReadAsync(this Stream stream, Memory<byte> buffer,
byte[] sharedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length);
return FinishReadAsync(stream.ReadAsync(sharedBuffer, 0, buffer.Length, cancellationToken), sharedBuffer, buffer);
async ValueTask<int> FinishReadAsync(Task<int> readTask, byte[] localBuffer, Memory<byte> localDestination)
static async ValueTask<int> FinishReadAsync(Task<int> readTask, byte[] localBuffer, Memory<byte> localDestination)
{
try
{
......
......@@ -101,7 +101,7 @@ internal ValueTask ConnectAsync(EndPoint remoteEP, CancellationToken cancellatio
return WaitForConnectWithCancellation(saea, connectTask, cancellationToken);
}
async ValueTask WaitForConnectWithCancellation(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
static async ValueTask WaitForConnectWithCancellation(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
{
Debug.Assert(cancellationToken.CanBeCanceled);
try
......
......@@ -920,7 +920,7 @@ public static unsafe SocketError Poll(SafeSocketHandle handle, int microseconds,
public static unsafe SocketError Select(IList? checkRead, IList? checkWrite, IList? checkError, int microseconds)
{
const int StackThreshold = 64; // arbitrary limit to avoid too much space on stack
bool ShouldStackAlloc(IList? list, ref IntPtr[]? lease, out Span<IntPtr> span)
static bool ShouldStackAlloc(IList? list, ref IntPtr[]? lease, out Span<IntPtr> span)
{
int count;
if (list == null || (count = list.Count) == 0)
......
......@@ -33,7 +33,7 @@ internal static ValueTask<int> ReadAsync(this Stream stream, Memory<byte> destin
byte[] buffer = ArrayPool<byte>.Shared.Rent(destination.Length);
return new ValueTask<int>(FinishReadAsync(stream.ReadAsync(buffer, 0, destination.Length, cancellationToken), buffer, destination));
async Task<int> FinishReadAsync(Task<int> readTask, byte[] localBuffer, Memory<byte> localDestination)
static async Task<int> FinishReadAsync(Task<int> readTask, byte[] localBuffer, Memory<byte> localDestination)
{
try
{
......@@ -61,7 +61,7 @@ internal static ValueTask WriteAsync(this Stream stream, ReadOnlyMemory<byte> so
source.Span.CopyTo(buffer);
return new ValueTask(FinishWriteAsync(stream.WriteAsync(buffer, 0, source.Length, cancellationToken), buffer));
async Task FinishWriteAsync(Task writeTask, byte[] localBuffer)
static async Task FinishWriteAsync(Task writeTask, byte[] localBuffer)
{
try
{
......
......@@ -665,7 +665,7 @@ private static string IteratorToString(XPathNodeIterator it)
}
else
{
return XmlConvert.ToXPathString(argument);
return XmlConvert.ToXPathString(argument)!;
}
}
......
......@@ -136,7 +136,7 @@ static OidLookup()
private static void InitializeLookupDictionaries()
{
void AddEntry(string oid, string primaryFriendlyName, string[]? additionalFriendlyNames = null)
static void AddEntry(string oid, string primaryFriendlyName, string[]? additionalFriendlyNames = null)
{
s_oidToFriendlyName.Add(oid, primaryFriendlyName);
s_friendlyNameToOid.Add(primaryFriendlyName, oid);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册