Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal partial record ArrayValue
public static MultiValue Create(MultiValue size, TypeDesc elementType)
{
MultiValue result = MultiValueLattice.Top;
foreach (var sizeValue in size.AsEnumerable ())
foreach (var sizeValue in size.AsEnumerable())
{
result = MultiValueLattice.Meet(result, new MultiValue(new ArrayValue(sizeValue, elementType)));
}
Expand Down Expand Up @@ -92,7 +92,7 @@ public override SingleValue DeepCopy()
// Since it's possible to store a reference to array as one of its own elements
// simple deep copy could lead to endless recursion.
// So instead we simply disallow arrays as element values completely - and treat that case as "too complex to analyze".
foreach (SingleValue v in kvp.Value.Value.AsEnumerable ())
foreach (SingleValue v in kvp.Value.Value.AsEnumerable())
{
System.Diagnostics.Debug.Assert(v is not ArrayValue);
}
Expand Down Expand Up @@ -123,7 +123,7 @@ public override string ToString()
result.Append(element.Key);
result.Append(",(");
bool firstValue = true;
foreach (var v in element.Value.Value.AsEnumerable ())
foreach (var v in element.Value.Value.AsEnumerable())
{
if (firstValue)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,15 @@ referencedMethod.OwningType is MetadataType generatedType &&
/// Attempts to reverse the process of the compiler's alpha renaming. So if the original code was
/// something like this:
/// <code>
/// void M&lt;T&gt; () {
/// Action a = () => { Console.WriteLine (typeof (T)); };
/// void M&lt;T&gt;() {
/// Action a = () => { Console.WriteLine(typeof(T)); };
/// }
/// </code>
/// The compiler will generate a nested class like this:
/// <code>
/// class &lt;&gt;c__DisplayClass0&lt;T&gt; {
/// public void &lt;M&gt;b__0 () {
/// Console.WriteLine (typeof (T));
/// public void &lt;M&gt;b__0() {
/// Console.WriteLine(typeof(T));
/// }
/// }
/// </code>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public HandleCallAction(
_requireDynamicallyAccessedMembersAction = new(reflectionMarker, diagnosticContext, reason);
}

private partial bool TryHandleIntrinsic (
private partial bool TryHandleIntrinsic(
MethodProxy calledMethod,
MultiValue instanceValue,
IReadOnlyList<MultiValue> argumentValues,
Expand Down Expand Up @@ -221,7 +221,7 @@ private partial bool TryHandleIntrinsic (
//
// System.Array
//
// CreateInstance (Type, Int32)
// CreateInstance(Type, Int32)
//
case IntrinsicId.Array_CreateInstance:
{
Expand All @@ -234,7 +234,7 @@ private partial bool TryHandleIntrinsic (
//
// System.Enum
//
// static GetValues (Type)
// static GetValues(Type)
//
case IntrinsicId.Enum_GetValues:
{
Expand All @@ -243,7 +243,7 @@ private partial bool TryHandleIntrinsic (
// type instead).
//
// At least until we have shared enum code, this needs extra handling to get it right.
foreach (var value in argumentValues[0].AsEnumerable ())
foreach (var value in argumentValues[0].AsEnumerable())
{
if (value is SystemTypeValue systemTypeValue
&& !systemTypeValue.RepresentedType.Type.IsGenericDefinition
Expand All @@ -263,10 +263,10 @@ private partial bool TryHandleIntrinsic (
//
// System.Runtime.InteropServices.Marshal
//
// static SizeOf (Type)
// static PtrToStructure (IntPtr, Type)
// static DestroyStructure (IntPtr, Type)
// static OffsetOf (Type, string)
// static SizeOf(Type)
// static PtrToStructure(IntPtr, Type)
// static DestroyStructure(IntPtr, Type)
// static OffsetOf(Type, string)
//
case IntrinsicId.Marshal_SizeOf:
case IntrinsicId.Marshal_PtrToStructure:
Expand All @@ -278,7 +278,7 @@ private partial bool TryHandleIntrinsic (
? 0 : 1;

// We need the data to do struct marshalling.
foreach (var value in argumentValues[paramIndex].AsEnumerable ())
foreach (var value in argumentValues[paramIndex].AsEnumerable())
{
if (value is SystemTypeValue systemTypeValue
&& !systemTypeValue.RepresentedType.Type.IsGenericDefinition
Expand All @@ -304,12 +304,12 @@ private partial bool TryHandleIntrinsic (
//
// System.Runtime.InteropServices.Marshal
//
// static GetDelegateForFunctionPointer (IntPtr, Type)
// static GetDelegateForFunctionPointer(IntPtr, Type)
//
case IntrinsicId.Marshal_GetDelegateForFunctionPointer:
{
// We need the data to do delegate marshalling.
foreach (var value in argumentValues[1].AsEnumerable ())
foreach (var value in argumentValues[1].AsEnumerable())
{
if (value is SystemTypeValue systemTypeValue
&& !systemTypeValue.RepresentedType.Type.IsGenericDefinition
Expand All @@ -329,11 +329,11 @@ private partial bool TryHandleIntrinsic (
//
// System.Delegate
//
// get_Method ()
// get_Method()
//
// System.Reflection.RuntimeReflectionExtensions
//
// GetMethodInfo (System.Delegate)
// GetMethodInfo(System.Delegate)
//
case IntrinsicId.RuntimeReflectionExtensions_GetMethodInfo:
case IntrinsicId.Delegate_get_Method:
Expand Down Expand Up @@ -373,12 +373,12 @@ private partial bool TryHandleIntrinsic (
//
case IntrinsicId.Object_GetType:
{
if (instanceValue.IsEmpty ()) {
AddReturnValue (MultiValueLattice.Top);
if (instanceValue.IsEmpty()) {
AddReturnValue(MultiValueLattice.Top);
break;
}

foreach (var valueNode in instanceValue.AsEnumerable ())
foreach (var valueNode in instanceValue.AsEnumerable())
{
// Note that valueNode can be statically typed in IL as some generic argument type.
// For example:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public HoistedLocalKey(FieldDesc field)

public override int GetHashCode() => Field.GetHashCode();

public static bool operator ==(HoistedLocalKey left, HoistedLocalKey right) => left.Equals (right);
public static bool operator ==(HoistedLocalKey left, HoistedLocalKey right) => left.Equals(right);
public static bool operator !=(HoistedLocalKey left, HoistedLocalKey right) => !(left == right);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public void TrackMethod(MethodIL methodBody)
methodBody = GetInstantiatedMethodIL(methodBody);

// Work around the fact that ValueSet is readonly
Debug.Assert (!MethodBodies.IsUnknown ());
var methodsList = new List<MethodBodyValue>(MethodBodies.GetKnownValues ());
Debug.Assert(!MethodBodies.IsUnknown());
var methodsList = new List<MethodBodyValue>(MethodBodies.GetKnownValues());
methodsList.Add(new MethodBodyValue(methodBody));

// For state machine methods, also scan the state machine members.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private static void ValidateNoReferenceToReference(ValueBasicBlockPair?[] locals
continue;

MultiValue localValue = localVariable.Value.Value;
foreach (var val in localValue.AsEnumerable ())
foreach (var val in localValue.AsEnumerable())
{
if (val is LocalVariableReferenceValue localReference && localReference.ReferencedType.IsByRefOrPointer())
{
Expand Down Expand Up @@ -306,8 +306,8 @@ public virtual void InterproceduralScan(MethodIL startingMethodBody)

// Flow state through all methods encountered so far, as long as there
// are changes discovered in the hoisted local state on entry to any method.
Debug.Assert (!oldInterproceduralState.MethodBodies.IsUnknown ());
foreach (var methodBodyValue in oldInterproceduralState.MethodBodies.GetKnownValues ())
Debug.Assert(!oldInterproceduralState.MethodBodies.IsUnknown());
foreach (var methodBodyValue in oldInterproceduralState.MethodBodies.GetKnownValues())
Scan(methodBodyValue.MethodBody, ref interproceduralState);
}

Expand All @@ -319,14 +319,14 @@ public virtual void InterproceduralScan(MethodIL startingMethodBody)
var calleeMethods = compilerGeneratedCallees.OfType<MethodDesc>();
// https://github.com/dotnet/linker/issues/2845
// Disabled asserts due to a bug
// Debug.Assert (interproceduralState.Count == 1 + calleeMethods.Count ());
// Debug.Assert(interproceduralState.Count == 1 + calleeMethods.Count());
// foreach (var method in calleeMethods)
// Debug.Assert (interproceduralState.Any (kvp => kvp.Key.Method == method));
// Debug.Assert(interproceduralState.Any(kvp => kvp.Key.Method == method));
}
else
{
Debug.Assert (!interproceduralState.MethodBodies.IsUnknown ());
Debug.Assert(interproceduralState.MethodBodies.GetKnownValues ().Count() == 1);
Debug.Assert(!interproceduralState.MethodBodies.IsUnknown());
Debug.Assert(interproceduralState.MethodBodies.GetKnownValues().Count() == 1);
}
#endif
}
Expand Down Expand Up @@ -1020,7 +1020,7 @@ private void ScanIndirectStore(
/// <exception cref="LinkerFatalErrorException">Throws if <paramref name="target"/> is not a valid target for an indirect store.</exception>
protected void StoreInReference(MultiValue target, MultiValue source, MethodIL method, int offset, ValueBasicBlockPair?[] locals, int curBasicBlock, ref InterproceduralState ipState, int? parameterIndex)
{
foreach (var value in target.AsEnumerable ())
foreach (var value in target.AsEnumerable())
{
switch (value)
{
Expand Down Expand Up @@ -1139,7 +1139,7 @@ private void ScanStfld(
return;
}

foreach (var value in HandleGetField(methodBody, offset, field).AsEnumerable ())
foreach (var value in HandleGetField(methodBody, offset, field).AsEnumerable())
{
// GetFieldValue may return different node types, in which case they can't be stored to.
// At least not yet.
Expand Down Expand Up @@ -1187,7 +1187,7 @@ internal MultiValue DereferenceValue(
ref InterproceduralState interproceduralState)
{
MultiValue dereferencedValue = MultiValueLattice.Top;
foreach (var value in maybeReferenceValue.AsEnumerable ())
foreach (var value in maybeReferenceValue.AsEnumerable())
{
switch (value)
{
Expand Down Expand Up @@ -1299,7 +1299,7 @@ private void HandleCall(

foreach (var param in methodArguments)
{
foreach (var v in param.AsEnumerable ())
foreach (var v in param.AsEnumerable())
{
if (v is ArrayValue arr)
{
Expand Down Expand Up @@ -1344,7 +1344,7 @@ private void ScanStelem(
StackSlot indexToStoreAt = PopUnknown(currentStack, 1, methodBody, offset);
StackSlot arrayToStoreIn = PopUnknown(currentStack, 1, methodBody, offset);
int? indexToStoreAtInt = indexToStoreAt.Value.AsConstInt();
foreach (var array in arrayToStoreIn.Value.AsEnumerable ())
foreach (var array in arrayToStoreIn.Value.AsEnumerable())
{
if (array is ArrayValue arrValue)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public void MarkAndProduceDiagnostics(ReflectionMarker reflectionMarker, Logger
logger.ShouldSuppressAnalysisWarningsForRequires(Origin.MemberDefinition, DiagnosticUtilities.RequiresAssemblyFilesAttribute),
logger);

foreach (var sourceValue in Source.AsEnumerable ())
foreach (var sourceValue in Source.AsEnumerable())
{
foreach (var targetValue in Target.AsEnumerable ())
foreach (var targetValue in Target.AsEnumerable())
{
if (targetValue is not ValueWithDynamicallyAccessedMembers targetWithDynamicallyAccessedMembers)
throw new NotImplementedException();
Expand Down
Loading
Loading