Skip to content

Commit 407ba6b

Browse files
Fix a few build warnings (#56)
1 parent e28a62e commit 407ba6b

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
lines changed

src/ClassExplorer/ClassExplorer.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
88
<Nullable>enable</Nullable>
99
<ResXGenerator_NullForgivingOperators>true</ResXGenerator_NullForgivingOperators>
10+
<!-- Some AssemblyName properties are depreciated, we don't actually depend on them though. -->
11+
<NoWarn>$(NoWarn);SYSLIB0037</NoWarn>
1012
</PropertyGroup>
1113

1214
<ItemGroup>

src/ClassExplorer/ReflectionCache.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,19 @@ public static string[] GetUsingNamespacesFromTLS()
3737

3838
if (GetExecutionContextFromTLSMethod is null) return null;
3939

40-
PropertyInfo? getEngineSessionState = ExecutionContextType?.GetProperty("EngineSessionState", flags);
40+
MethodInfo? getEngineSessionState = ExecutionContextType
41+
?.GetProperty("EngineSessionState", flags)
42+
?.GetGetMethod(nonPublic: true);
4143
if (getEngineSessionState is null) return null;
4244

43-
PropertyInfo? currentScope = getEngineSessionState.GetReturnType()?.GetProperty("CurrentScope", flags);
45+
MethodInfo? currentScope = getEngineSessionState?.ReturnType
46+
?.GetProperty("CurrentScope", flags)
47+
?.GetGetMethod(nonPublic: true);
4448
if (currentScope is null) return null;
4549

46-
PropertyInfo? typeRes = currentScope.GetReturnType()?.GetProperty("TypeResolutionState", flags);
50+
MethodInfo? typeRes = currentScope?.ReturnType
51+
?.GetProperty("TypeResolutionState", flags)
52+
?.GetGetMethod(nonPublic: true);
4753
if (typeRes is null) return null;
4854

4955
FieldInfo? namespaces = typeRes.GetReturnType()?.GetField("namespaces", flags);
@@ -56,9 +62,9 @@ public static string[] GetUsingNamespacesFromTLS()
5662
Expression.Call(
5763
Expression.Call(
5864
Expression.Call(GetExecutionContextFromTLSMethod),
59-
getEngineSessionState.GetGetMethod(nonPublic: true)),
60-
currentScope.GetGetMethod(nonPublic: true)),
61-
typeRes.GetGetMethod(nonPublic: true)),
65+
getEngineSessionState!),
66+
currentScope!),
67+
typeRes),
6268
namespaces),
6369
"GetUsingNamespacesDynamically",
6470
[])

src/ClassExplorer/SignatureWriter.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,6 +1815,9 @@ public SignatureWriter Member(PropertyInfo property)
18151815
Modifiers(modifiersMethod);
18161816
}
18171817

1818+
Poly.Assert(name is not null);
1819+
Poly.Assert(propertyParameter is not null);
1820+
18181821
TypeInfo(propertyParameter).Space();
18191822
if (isExplicitImplementation)
18201823
{
@@ -1885,6 +1888,7 @@ public SignatureWriter Member(EventInfo eventInfo)
18851888
eventParameter = removeMethod!.GetParameters().FirstOrDefault();
18861889
}
18871890

1891+
Poly.Assert(eventParameter is not null);
18881892
Modifiers(modifiersMethod).Keyword("event").Space().TypeInfo(eventParameter).Space();
18891893
MemberName(eventInfo.Name).Space();
18901894
OpenCurly().Space();

src/ClassExplorer/Signatures/FullMethodSignature.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public override bool IsMatch(MemberInfo subject)
1818

1919
if (subject is ConstructorInfo ctor)
2020
{
21-
if (!ReturnType.IsMatch(ctor.ReflectedType))
21+
if (ctor.ReflectedType is null || !ReturnType.IsMatch(ctor.ReflectedType))
2222
{
2323
return false;
2424
}

src/ClassExplorer/TypeSearch.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ protected override void InitializeOtherFilters(List<Filter<Type>> filters, Signa
142142
{
143143
filters.AddFilter(
144144
StringMatcher.CreateRegex(_options.FullName),
145-
static (type, matcher) => matcher.IsMatch(type.FullName));
145+
static (type, matcher) => matcher.IsMatch(type.FullName ?? ""));
146146
}
147147
else
148148
{

0 commit comments

Comments
 (0)