public void SetBaseTypeConstraint([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type? baseTypeConstraint)
{
- m_type.CheckContext(baseTypeConstraint);
+ AssemblyBuilder.CheckContext(baseTypeConstraint);
m_type.SetParent(baseTypeConstraint);
}
public void SetInterfaceConstraints(params Type[]? interfaceConstraints)
{
- m_type.CheckContext(interfaceConstraints);
+ AssemblyBuilder.CheckContext(interfaceConstraints);
m_type.SetInterfaces(interfaceConstraints);
}
#region Internal Members
- internal void CheckContext(params Type[]?[]? typess)
- {
- m_module.CheckContext(typess);
- }
-
- internal void CheckContext(params Type?[]? types)
- {
- m_module.CheckContext(types);
- }
-
internal void CreateMethodBodyHelper(ILGenerator il)
{
// Sets the IL of the method. An ILGenerator is passed as an argument and the method
public void SetParameters(params Type[] parameterTypes)
{
- CheckContext(parameterTypes);
+ AssemblyBuilder.CheckContext(parameterTypes);
SetSignature(null, null, null, parameterTypes, null, null);
}
public void SetReturnType(Type? returnType)
{
- CheckContext(returnType);
+ AssemblyBuilder.CheckContext(returnType);
SetSignature(returnType, null, null, null, null, null);
}
if (m_tkMethod.Token != 0)
return;
- CheckContext(returnType);
- CheckContext(returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes);
- CheckContext(parameterTypeRequiredCustomModifiers);
- CheckContext(parameterTypeOptionalCustomModifiers);
+ AssemblyBuilder.CheckContext(returnType);
+ AssemblyBuilder.CheckContext(returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes);
+ AssemblyBuilder.CheckContext(parameterTypeRequiredCustomModifiers);
+ AssemblyBuilder.CheckContext(parameterTypeOptionalCustomModifiers);
ThrowIfGeneric();
return SymbolType.FormCompoundType(strFormat, baseType, 0);
}
- internal void CheckContext(params Type[]?[]? typess)
- {
- AssemblyBuilder.CheckContext(typess);
- }
-
- internal void CheckContext(params Type?[]? types)
- {
- AssemblyBuilder.CheckContext(types);
- }
-
[DllImport(RuntimeHelpers.QCall, CharSet = CharSet.Unicode)]
private static extern int GetTypeRef(QCallModule module, string strFullName, QCallModule refedModule, string? strRefedModuleFileName, int tkResolution);
return sig;
}
- private MethodBase GetGenericMethodBaseDefinition(MethodBase methodBase)
+ private static MethodBase GetGenericMethodBaseDefinition(MethodBase methodBase)
{
// methodInfo = G<Foo>.M<Bar> ==> methDef = G<T>.M<S>
MethodInfo? masmi = methodBase as MethodInfo;
{
lock (SyncRoot)
{
- CheckContext(parent);
+ AssemblyBuilder.CheckContext(parent);
return DefineTypeNoLock(name, attr, parent, null, PackingSize.Unspecified, TypeBuilder.UnspecifiedTypeSize);
}
// Nested enum types can be defined manually using ModuleBuilder.DefineType.
public EnumBuilder DefineEnum(string name, TypeAttributes visibility, Type underlyingType)
{
- CheckContext(underlyingType);
+ AssemblyBuilder.CheckContext(underlyingType);
lock (SyncRoot)
{
EnumBuilder enumBuilder = DefineEnumNoLock(name, visibility, underlyingType);
throw new ArgumentException(SR.Argument_GlobalFunctionHasToBeStatic);
}
- CheckContext(returnType);
- CheckContext(parameterTypes);
+ AssemblyBuilder.CheckContext(returnType);
+ AssemblyBuilder.CheckContext(parameterTypes);
return _moduleData._globalTypeBuilder.DefinePInvokeMethod(name, dllName, entryName, attributes, callingConvention, returnType, parameterTypes, nativeCallConv, nativeCharSet);
}
throw new ArgumentException(SR.Argument_GlobalFunctionHasToBeStatic);
}
- CheckContext(returnType);
- CheckContext(requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers, parameterTypes);
- CheckContext(requiredParameterTypeCustomModifiers);
- CheckContext(optionalParameterTypeCustomModifiers);
+ AssemblyBuilder.CheckContext(returnType);
+ AssemblyBuilder.CheckContext(requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers, parameterTypes);
+ AssemblyBuilder.CheckContext(requiredParameterTypeCustomModifiers);
+ AssemblyBuilder.CheckContext(optionalParameterTypeCustomModifiers);
return _moduleData._globalTypeBuilder.DefineMethod(name, attributes, callingConvention,
returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers,
throw new ArgumentNullException(nameof(type));
}
- CheckContext(type);
+ AssemblyBuilder.CheckContext(type);
// Return a token for the class relative to the Module. Tokens
// are used to indentify objects when the objects are used in IL
throw new ArgumentException(SR.Argument_HasToBeArrayClass);
}
- CheckContext(returnType, arrayClass);
- CheckContext(parameterTypes);
+ AssemblyBuilder.CheckContext(returnType, arrayClass);
+ AssemblyBuilder.CheckContext(parameterTypes);
// Return a token for the MethodInfo for a method on an Array. This is primarily
// used to get the LoadElementAddress method.
public MethodInfo GetArrayMethod(Type arrayClass, string methodName, CallingConventions callingConvention,
Type? returnType, Type[]? parameterTypes)
{
- CheckContext(returnType, arrayClass);
- CheckContext(parameterTypes);
+ AssemblyBuilder.CheckContext(returnType, arrayClass);
+ AssemblyBuilder.CheckContext(parameterTypes);
// GetArrayMethod is useful when you have an array of a type whose definition has not been completed and
// you want to access methods defined on Array. For example, you might define a type and want to define a
public override Type MakeGenericType(params Type[] typeArguments)
{
- CheckContext(typeArguments);
+ AssemblyBuilder.CheckContext(typeArguments);
return TypeBuilderInstantiation.MakeGenericType(this, typeArguments);
}
if (name.Length == 0)
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
- CheckContext(returnType);
- CheckContext(returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes);
- CheckContext(parameterTypeRequiredCustomModifiers);
- CheckContext(parameterTypeOptionalCustomModifiers);
+ AssemblyBuilder.CheckContext(returnType);
+ AssemblyBuilder.CheckContext(returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes);
+ AssemblyBuilder.CheckContext(parameterTypeRequiredCustomModifiers);
+ AssemblyBuilder.CheckContext(parameterTypeOptionalCustomModifiers);
if (parameterTypes != null)
{
Type[]? parameterTypes, Type[][]? parameterTypeRequiredCustomModifiers, Type[][]? parameterTypeOptionalCustomModifiers,
CallingConvention nativeCallConv, CharSet nativeCharSet)
{
- CheckContext(returnType);
- CheckContext(returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes);
- CheckContext(parameterTypeRequiredCustomModifiers);
- CheckContext(parameterTypeOptionalCustomModifiers);
+ AssemblyBuilder.CheckContext(returnType);
+ AssemblyBuilder.CheckContext(returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes);
+ AssemblyBuilder.CheckContext(parameterTypeRequiredCustomModifiers);
+ AssemblyBuilder.CheckContext(parameterTypeOptionalCustomModifiers);
lock (SyncRoot)
{
private ConstructorBuilder DefineConstructorNoLock(MethodAttributes attributes, CallingConventions callingConvention,
Type[]? parameterTypes, Type[][]? requiredCustomModifiers, Type[][]? optionalCustomModifiers)
{
- CheckContext(parameterTypes);
- CheckContext(requiredCustomModifiers);
- CheckContext(optionalCustomModifiers);
+ AssemblyBuilder.CheckContext(parameterTypes);
+ AssemblyBuilder.CheckContext(requiredCustomModifiers);
+ AssemblyBuilder.CheckContext(optionalCustomModifiers);
ThrowIfCreated();
lock (SyncRoot)
{
// Why do we only call CheckContext here? Why don't we call it in the other overloads?
- CheckContext(parent);
- CheckContext(interfaces);
+ AssemblyBuilder.CheckContext(parent);
+ AssemblyBuilder.CheckContext(interfaces);
return DefineNestedTypeNoLock(name, attr, parent, interfaces, PackingSize.Unspecified, UnspecifiedTypeSize);
}
Type[]? optionalCustomModifiers, FieldAttributes attributes)
{
ThrowIfCreated();
- CheckContext(type);
- CheckContext(requiredCustomModifiers);
+ AssemblyBuilder.CheckContext(type);
+ AssemblyBuilder.CheckContext(requiredCustomModifiers);
if (m_enumUnderlyingType == null && IsEnum)
{
if (name.Length == 0)
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
- CheckContext(returnType);
- CheckContext(returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes);
- CheckContext(parameterTypeRequiredCustomModifiers);
- CheckContext(parameterTypeOptionalCustomModifiers);
+ AssemblyBuilder.CheckContext(returnType);
+ AssemblyBuilder.CheckContext(returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes);
+ AssemblyBuilder.CheckContext(parameterTypeRequiredCustomModifiers);
+ AssemblyBuilder.CheckContext(parameterTypeOptionalCustomModifiers);
SignatureHelper sigHelper;
byte[] sigBytes;
int tkType;
EventToken evToken;
- CheckContext(eventtype);
+ AssemblyBuilder.CheckContext(eventtype);
ThrowIfCreated();
}
}
- internal void CheckContext(params Type[]?[]? typess)
- {
- m_module.CheckContext(typess);
- }
- internal void CheckContext(params Type?[]? types)
- {
- m_module.CheckContext(types);
- }
-
private TypeInfo? CreateTypeNoLock()
{
if (IsCreated())
if (parent != null)
{
- CheckContext(parent);
+ AssemblyBuilder.CheckContext(parent);
if (parent.IsInterface)
throw new ArgumentException(SR.Argument_CannotSetParentToInterface);
throw new ArgumentNullException(nameof(interfaceType));
}
- CheckContext(interfaceType);
+ AssemblyBuilder.CheckContext(interfaceType);
ThrowIfCreated();
return segment._slots[i].Item!;
}
- private IEnumerator<T> Enumerate(ConcurrentQueueSegment<T> head, int headHead, ConcurrentQueueSegment<T> tail, int tailTail)
+ private static IEnumerator<T> Enumerate(ConcurrentQueueSegment<T> head, int headHead, ConcurrentQueueSegment<T> tail, int tailTail)
{
Debug.Assert(head._preservedForObservation);
Debug.Assert(head._frozenForEnqueues);
catch { } // If we fail during last chance logging, well, we have to give up....
}
- private EventSourceSettings ValidateSettings(EventSourceSettings settings)
+ private static EventSourceSettings ValidateSettings(EventSourceSettings settings)
{
const EventSourceSettings evtFormatMask = EventSourceSettings.EtwManifestEventFormat |
EventSourceSettings.EtwSelfDescribingEventFormat;
}
}
- private void LogOnEventWritten(EventWrittenEventArgs eventData)
+ private static void LogOnEventWritten(EventWrittenEventArgs eventData)
{
string payload = "";
if (eventData.Payload != null)
{
- try{
+ try
+ {
payload = Serialize(eventData.PayloadNames, eventData.Payload, eventData.Message);
}
catch (Exception ex)
return "en-US";
}
- private bool SystemSupportsTaiwaneseCalendar() => GlobalizationMode.UseNls ?
+ private static bool SystemSupportsTaiwaneseCalendar() => GlobalizationMode.UseNls ?
NlsSystemSupportsTaiwaneseCalendar() :
IcuSystemSupportsTaiwaneseCalendar();
}
}
}
- private int InvariantGetSortKey(ReadOnlySpan<char> source, Span<byte> destination, CompareOptions options)
+ private static int InvariantGetSortKey(ReadOnlySpan<char> source, Span<byte> destination, CompareOptions options)
{
Debug.Assert(GlobalizationMode.Invariant);
Debug.Assert((options & ValidCompareMaskOffFlags) == 0);
return source.Length * sizeof(char);
}
- private int InvariantGetSortKeyLength(ReadOnlySpan<char> source, CompareOptions options)
+ private static int InvariantGetSortKeyLength(ReadOnlySpan<char> source, CompareOptions options)
{
Debug.Assert(GlobalizationMode.Invariant);
Debug.Assert((options & ValidCompareMaskOffFlags) == 0);
}
}
- private unsafe string NlsGetAsciiCore(string unicodeString, char* unicode, int count, uint flags, char* output, int outputLength)
+ private static unsafe string NlsGetAsciiCore(string unicodeString, char* unicode, int count, uint flags, char* output, int outputLength)
{
Debug.Assert(!GlobalizationMode.Invariant);
Debug.Assert(GlobalizationMode.UseNls);
}
}
- private unsafe string NlsGetUnicodeCore(string asciiString, char* ascii, int count, uint flags, char* output, int outputLength)
+ private static unsafe string NlsGetUnicodeCore(string asciiString, char* ascii, int count, uint flags, char* output, int outputLength)
{
Debug.Assert(!GlobalizationMode.Invariant);
Debug.Assert(GlobalizationMode.UseNls);
internal override CalendarId ID => CalendarId.PERSIAN;
- private long GetAbsoluteDatePersian(int year, int month, int day)
+ private static long GetAbsoluteDatePersian(int year, int month, int day)
{
if (year < 1 || year > MaxCalendarYear || month < 1 || month > 12)
{
/// In order to get the exact UmAlQura year, we compare the exact absolute date for UmAlQuraYear and (UmAlQuraYear + 1).
/// From here, we can get the correct UmAlQura year.
/// </summary>
- private int GetDatePart(DateTime time, int part)
+ private static int GetDatePart(DateTime time, int part)
{
long ticks = time.Ticks;
CheckTicksRange(ticks);
Unsafe.Add(ref g._a, 3) == Unsafe.Add(ref _a, 3);
}
- private int GetResult(uint me, uint them) => me < them ? -1 : 1;
+ private static int GetResult(uint me, uint them) => me < them ? -1 : 1;
public int CompareTo(object? value)
{
return asyncResult; // return it
}
- private void RunReadWriteTaskWhenReady(Task asyncWaiter, ReadWriteTask readWriteTask)
+ private static void RunReadWriteTaskWhenReady(Task asyncWaiter, ReadWriteTask readWriteTask)
{
Debug.Assert(readWriteTask != null);
Debug.Assert(asyncWaiter != null);
{
Debug.Assert(t.IsCompletedSuccessfully, "The semaphore wait should always complete successfully.");
var rwt = (ReadWriteTask)state!;
- Debug.Assert(rwt._stream != null);
- rwt._stream.RunReadWriteTask(rwt); // RunReadWriteTask(readWriteTask);
+ Debug.Assert(rwt._stream != null, "Validates that this code isn't run a second time.");
+ RunReadWriteTask(rwt); // RunReadWriteTask(readWriteTask);
}, readWriteTask, default, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default);
}
}
- private void RunReadWriteTask(ReadWriteTask readWriteTask)
+ private static void RunReadWriteTask(ReadWriteTask readWriteTask)
{
Debug.Assert(readWriteTask != null);
}
}
- private async Task FinishWriteAsync(Task writeTask, byte[] localBuffer)
+ private static async Task FinishWriteAsync(Task writeTask, byte[] localBuffer)
{
try
{
public override int Remaining => 0;
[DoesNotReturn]
- private void Throw(byte[] bytesUnknown, int index)
+ private static void Throw(byte[] bytesUnknown, int index)
{
bytesUnknown ??= Array.Empty<byte>();
// private helper methods
[DoesNotReturn]
- internal void ThrowLastBytesRecursive(byte[] bytesUnknown)
+ internal static void ThrowLastBytesRecursive(byte[] bytesUnknown)
{
bytesUnknown ??= Array.Empty<byte>();
}
// private helper methods
- private char TryBestFit(char cUnknown)
+ private static char TryBestFit(char cUnknown)
{
// Need to figure out our best fit character, low is beginning of array, high is 1 AFTER end of array
int lowBound = 0;
return (int)(chars - charStart);
}
- private uint GetSurrogate(char cHigh, char cLow)
+ private static uint GetSurrogate(char cHigh, char cLow)
{
return (((uint)cHigh - 0xD800) * 0x400) + ((uint)cLow - 0xDC00) + 0x10000;
}
- private char GetHighSurrogate(uint iChar)
+ private static char GetHighSurrogate(uint iChar)
{
return (char)((iChar - 0x10000) / 0x400 + 0xD800);
}
- private char GetLowSurrogate(uint iChar)
+ private static char GetLowSurrogate(uint iChar)
{
return (char)((iChar - 0x10000) % 0x400 + 0xDC00);
}
return FilterTasksFromWorkItems(ThreadPool.GetQueuedWorkItems());
}
- private IEnumerable<Task> FilterTasksFromWorkItems(IEnumerable<object> tpwItems)
+ private static IEnumerable<Task> FilterTasksFromWorkItems(IEnumerable<object> tpwItems)
{
foreach (object tpwi in tpwItems)
{
EnsureThreadRequested();
}
- internal bool LocalFindAndPop(object callback)
+ internal static bool LocalFindAndPop(object callback)
{
ThreadPoolWorkQueueThreadLocals? tl = ThreadPoolWorkQueueThreadLocals.threadLocals;
return tl != null && tl.workStealingQueue.LocalFindAndPop(callback);
return callback;
}
- public long LocalCount
+ public static long LocalCount
{
get
{
internal static bool TryPopCustomWorkItem(object workItem)
{
Debug.Assert(null != workItem);
- return s_workQueue.LocalFindAndPop(workItem);
+ return ThreadPoolWorkQueue.LocalFindAndPop(workItem);
}
// Get all workitems. Called by TaskScheduler in its debugger hooks.
get
{
ThreadPoolWorkQueue workQueue = s_workQueue;
- return workQueue.LocalCount + workQueue.GlobalCount + PendingUnmanagedWorkItemCount;
+ return ThreadPoolWorkQueue.LocalCount + workQueue.GlobalCount + PendingUnmanagedWorkItemCount;
}
}
}
/// <summary>
/// Gets the offset that should be used to calculate DST end times from a UTC time.
/// </summary>
- private TimeSpan GetDaylightSavingsEndOffsetFromUtc(TimeSpan baseUtcOffset, AdjustmentRule rule)
+ private static TimeSpan GetDaylightSavingsEndOffsetFromUtc(TimeSpan baseUtcOffset, AdjustmentRule rule)
{
// NOTE: even NoDaylightTransitions rules use this logic since DST ends w.r.t. the current rule
return baseUtcOffset + rule.BaseUtcOffsetDelta + rule.DaylightDelta; /* FUTURE: + rule.StandardDelta; */
startTime = daylightTime.Start - dstStartOffset;
}
- TimeSpan dstEndOffset = zone.GetDaylightSavingsEndOffsetFromUtc(utc, rule);
+ TimeSpan dstEndOffset = GetDaylightSavingsEndOffsetFromUtc(utc, rule);
DateTime endTime;
if (rule.IsEndDateMarkerForEndOfYear() && daylightTime.End.Year < DateTime.MaxValue.Year)
{