Possible false positive? -> [Possible 'null' assignment to an entity marked with 'Value cannot be null' attribute]
The Message pops up at line 21 at the typeof command. Since the result typeof cannot be null I thinkt it's an false positive.
Am I right or is there some "better" way to solve this.
using System;
using System.IO;
using System.Reflection;
namespace Typemock.TeamFoundation.Build.Workflow.Activities
{
internal class TestClass
{
private Testclass2 InternalVersionResolver { get; set; }
private AppDomain AppDomain { get; set; }
public TestClass()
{
var executingAssemblyLocation = Assembly.GetExecutingAssembly().Location;
var appDomainSetup = new AppDomainSetup
{ApplicationBase = Path.GetDirectoryName(executingAssemblyLocation)};
AppDomain domain = AppDomain.CreateDomain("TypemockVersionResolverAppDomain", AppDomain.CurrentDomain.Evidence, appDomainSetup);
try
{
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
InternalVersionResolver = (Testclass2)domain.CreateInstanceAndUnwrap(AssemblyName.GetAssemblyName(executingAssemblyLocation).FullName, typeof(Testclass2).FullName);
}
finally
{
AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
}
AppDomain = domain;
}
Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
throw new NotImplementedException();
}
internal class Testclass2 : MarshalByRefObject
{
}
}
}
Please sign in to leave a comment.
Hello Michael,
Here ReSharper complains not about the typeof(Testclass2) being null, but
rather about typeof(Testclass2).FullName. According to documentation, this
property can return null:
"The fully qualified name of the Type, including the namespace of the Type
but not the assembly; or null if the current instance represents a generic
type parameter, an array type, pointer type, or byref type based on a type
parameter, or a generic type that is not a generic type definition but contains
unresolved type parameters."
, so this is a correct warning from ReSharper.
Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"