Skip to content

Commit

Permalink
Roslyn update response (#43056)
Browse files Browse the repository at this point in the history
* Update function pointer syntax usage to official.

* Fix warnings with new Roslyn

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
  • Loading branch information
AaronRobinsonMSFT and jkotas committed Oct 6, 2020
1 parent 850788e commit d1c0fa8
Show file tree
Hide file tree
Showing 18 changed files with 192 additions and 191 deletions.
1 change: 1 addition & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
340 changes: 170 additions & 170 deletions src/coreclr/src/tools/Common/JitInterface/CorInfoBase.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/Common/src/Interop/Interop.Calendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ internal static extern bool IsNLSDefinedString(
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);
Expand All @@ -140,7 +140,7 @@ internal static extern bool IsNLSDefinedString(
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
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/System.Console/src/System/Console.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private static DateTimeOffset ParseGeneralizedTime(
const byte SuffixState = 2;
byte state = HmsState;

byte? GetNextState(byte octet)
static byte? GetNextState(byte octet)
{
if (octet == 'Z' || octet == '-' || octet == '+')
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ private unsafe void ProcessEvents(int numEvents,

this._context = ExecutionContext.Capture();

ParsedEvent ParseEvent(byte* nativeEventPath)
static ParsedEvent ParseEvent(byte* nativeEventPath)
{
int byteCount = 0;
Debug.Assert(nativeEventPath != null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ private static string IteratorToString(XPathNodeIterator it)
}
else
{
return XmlConvert.ToXPathString(argument);
return XmlConvert.ToXPathString(argument)!;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d1c0fa8

Please sign in to comment.