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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/ClassExplorer/ClassExplorer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
<ResXGenerator_NullForgivingOperators>true</ResXGenerator_NullForgivingOperators>
<!-- Some AssemblyName properties are depreciated, we don't actually depend on them though. -->
<NoWarn>$(NoWarn);SYSLIB0037</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
18 changes: 12 additions & 6 deletions src/ClassExplorer/ReflectionCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,19 @@ public static string[] GetUsingNamespacesFromTLS()

if (GetExecutionContextFromTLSMethod is null) return null;

PropertyInfo? getEngineSessionState = ExecutionContextType?.GetProperty("EngineSessionState", flags);
MethodInfo? getEngineSessionState = ExecutionContextType
?.GetProperty("EngineSessionState", flags)
?.GetGetMethod(nonPublic: true);
if (getEngineSessionState is null) return null;

PropertyInfo? currentScope = getEngineSessionState.GetReturnType()?.GetProperty("CurrentScope", flags);
MethodInfo? currentScope = getEngineSessionState?.ReturnType
?.GetProperty("CurrentScope", flags)
?.GetGetMethod(nonPublic: true);
if (currentScope is null) return null;

PropertyInfo? typeRes = currentScope.GetReturnType()?.GetProperty("TypeResolutionState", flags);
MethodInfo? typeRes = currentScope?.ReturnType
?.GetProperty("TypeResolutionState", flags)
?.GetGetMethod(nonPublic: true);
if (typeRes is null) return null;

FieldInfo? namespaces = typeRes.GetReturnType()?.GetField("namespaces", flags);
Expand All @@ -56,9 +62,9 @@ public static string[] GetUsingNamespacesFromTLS()
Expression.Call(
Expression.Call(
Expression.Call(GetExecutionContextFromTLSMethod),
getEngineSessionState.GetGetMethod(nonPublic: true)),
currentScope.GetGetMethod(nonPublic: true)),
typeRes.GetGetMethod(nonPublic: true)),
getEngineSessionState!),
currentScope!),
typeRes),
namespaces),
"GetUsingNamespacesDynamically",
[])
Expand Down
4 changes: 4 additions & 0 deletions src/ClassExplorer/SignatureWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1815,6 +1815,9 @@ public SignatureWriter Member(PropertyInfo property)
Modifiers(modifiersMethod);
}

Poly.Assert(name is not null);
Poly.Assert(propertyParameter is not null);

TypeInfo(propertyParameter).Space();
if (isExplicitImplementation)
{
Expand Down Expand Up @@ -1885,6 +1888,7 @@ public SignatureWriter Member(EventInfo eventInfo)
eventParameter = removeMethod!.GetParameters().FirstOrDefault();
}

Poly.Assert(eventParameter is not null);
Modifiers(modifiersMethod).Keyword("event").Space().TypeInfo(eventParameter).Space();
MemberName(eventInfo.Name).Space();
OpenCurly().Space();
Expand Down
2 changes: 1 addition & 1 deletion src/ClassExplorer/Signatures/FullMethodSignature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public override bool IsMatch(MemberInfo subject)

if (subject is ConstructorInfo ctor)
{
if (!ReturnType.IsMatch(ctor.ReflectedType))
if (ctor.ReflectedType is null || !ReturnType.IsMatch(ctor.ReflectedType))
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ClassExplorer/TypeSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected override void InitializeOtherFilters(List<Filter<Type>> filters, Signa
{
filters.AddFilter(
StringMatcher.CreateRegex(_options.FullName),
static (type, matcher) => matcher.IsMatch(type.FullName));
static (type, matcher) => matcher.IsMatch(type.FullName ?? ""));
}
else
{
Expand Down
Loading