From 9062afbfb721776615875a8cc357ceba49734f8e Mon Sep 17 00:00:00 2001 From: NeVeSpl Date: Fri, 22 Dec 2023 14:46:00 +0100 Subject: [PATCH] BenMorris/NetArchTest#137 - NRE when constant field has null value --- sources/NetArchTest/Dependencies/TypeCheckingContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/NetArchTest/Dependencies/TypeCheckingContext.cs b/sources/NetArchTest/Dependencies/TypeCheckingContext.cs index e3e4798..1afa979 100644 --- a/sources/NetArchTest/Dependencies/TypeCheckingContext.cs +++ b/sources/NetArchTest/Dependencies/TypeCheckingContext.cs @@ -105,7 +105,7 @@ private void CheckFields(TypeDefinition typeToCheck) { CheckCustomAttributes(field); CheckTypeReference(field.FieldType); - if (_serachForDependencyInFieldConstant && field.HasConstant && field.FieldType.FullName == typeof(string).FullName) + if (_serachForDependencyInFieldConstant && field.HasConstant && field.FieldType.FullName == typeof(string).FullName && field.Constant != null) { _result.CheckType(field.Constant.ToString()); }