Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8723079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:32:46+00:00 2026-06-13T07:32:46+00:00

I have a simple property inside one of my ASP.NET MVC Controller classes. I’ve

  • 0

I have a simple property inside one of my ASP.NET MVC Controller classes.

enter image description here

I’ve seen this many times before, so understand what the message means, but usually it makes perfect sense. This, however, doesn’t. To get to the underlined statement, User would have to NOT be null, so the check for User.Identity is fine.

The Identity property is part of the IPrincipal interface, and returns an object that inherits IIdentity.

To inherit this interface, or any interface for that matter, this property must be a reference type, and therefore can potentially be null, right?

So why is my beloved ReSharper moaning?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:32:46+00:00Added an answer on June 13, 2026 at 7:32 am

    You said you are using the GenericPrinciple as the implementation of IPrincipal. For this class, the Identity property can indeed never be null. It is easy to see if you look at the source code (e.g. using JetBrains dotPeek).

    You can thank ReSharper’s code annotations for the .NET framework class libraries for this.

    In my ReSharper 6.1 annotations, there is this single code annotation related to this (in file ExternalAnnotations\mscorlib\mscorlib.4.0.0.0.Nullness.Generated.xml):

      <member name="M:System.Security.Principal.GenericPrincipal.#ctor(System.Security.Principal.IIdentity,System.String[])">
        <parameter name="identity">
          <attribute ctor="M:JetBrains.Annotations.NotNullAttribute.#ctor" />
        </parameter>
      </member>
    

    This is just for the constructor though, I haven’t found one for the Identity property. So either you are using a ReSharper version that has annotation for that property too or ReSharper is doing some additional analysis.

    In any case, it is ReSharper being clever (and right!).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have standard ASP.NET 4 application. Inside this application there are also few razor
I have written two simple Java classes (one of them containing main(), and the
I have a ASP.NET MVC 2.0 application using Entity Framework. All my views use
On my app delegate class I have a simple property @property (strong, nonatomic) LoginAppDelegate
I have a simple Windows Form that hosts property controls at runtime. When the
I have a simple MVVM application. It contains a property, which I will change
I have following simple class: @interface Article: NSObject { NSString *title; } @property (copy,
I have the following simple class definition: //mycommon.h @interface CurrentPath : NSObject @property (nonatomic,
I have some very simple XML: <properties> <property> <name>BobFish</name> <explaination>Bob is a fish.</explaination> </property>
In an Asp.net MVC application I'd like to encapsulate the ugly wrapper code (just

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.