0

I created an extension method in VB.NET in Visual Studio 2013 but it will not show up in Intellisense.

Imports System.Security.Claims
Imports System.Runtime.CompilerServices
Imports Connect.Common.Portable

Namespace Authorization

Public Module ClaimsPrincipalExtensions

    <Extension()>
    Public Function CurrentFirmNumber(ByVal principal As ClaimsPrincipal) As Integer
        Dim c As Claim = principal.FindFirst(AuthorizationClaimTypes.LOGGED_IN_FIRM_NUMBER)
        If (c IsNot Nothing) Then
            Dim firmNumber As Integer = 0
            If (Integer.TryParse(c.Value, firmNumber)) Then
                Return firmNumber
            End If
        End If

        Return 0
    End Function

End Module

End Namespace

I have tried everything I could find on StackOverflow and other sites to solve this to no avail, including everything mentioned here.

In my calling code I include the right namespace, and the compiler and runtime are perfectly happy if I call this extension. That is, the code runs fine and correctly calls the extension method. It is simply intellisense that doesn't show it to me.

However, if I try to reference the method directly using the full namespace, as opposed to from the extended object, it shows up in intellisense.

Any ideas?

UPDATE:

So, it gets weirder. I had a colleague open up the same source and he gets intellisense.

As well, original extensions that used to work for me now have the same intellisense problem. However, if I start typing out the extension name intellisense does see it once it becomes a unique name.

For example, If I type "CurrentPrincipal.Current.C" Intellisense suggests "Claims", but not "CurrentFirmNumber", as that is part of the type. However, if I add a "u" it then suggests "CurrentFirmNumber", which is my extension.

Community
  • 1
  • 1
ChrisC
  • 1,161
  • 12
  • 26
  • if the consumer of this is in different assembly, just for hack of it, do rebuild, first in your extension project and then do rebuild in your consumer project. – T.S. May 22 '15 at 16:00
  • @T.S. thanks, but I tried this, as well as various other permissions of cleaning abuilding (clean/build, rebuild, close VS then rebuild, etc.). Still not working. – ChrisC May 22 '15 at 16:09
  • @Fabio I already am. I should have pointed out that I can also call it directly without specifying the full namespace, indicationg that the namespace is being imported correctly. – ChrisC May 22 '15 at 16:23
  • Try to remove your module with extension method outside of `Authorization` namespace – Fabio May 22 '15 at 16:24
  • @Fabio I removed the namespace so it defaults to the project root namespace, the IDE noticed that it had moved so it complained about it, and when I fixed the import it recognized it again, but still no intellisense. In other words, no impact – ChrisC May 22 '15 at 16:27
  • Ok, then did you tried to close VisualStudio and reopen again – Fabio May 22 '15 at 16:38
  • @Fabio as I mentioned, that link I reference has all of these types of things to try and I have done them all, including shutting down and restarting VIsual Studio – ChrisC May 22 '15 at 16:53
  • FYI I cannot duplicate using VS2012 – Ňɏssa Pøngjǣrdenlarp May 22 '15 at 16:58
  • Added some more info. It just keeps getting weirder – ChrisC May 22 '15 at 17:16
  • @Plutonix I'm not surprised. I have been using Extensions for years quite happily in VB and C# in VS2012 and prior versions. – ChrisC May 22 '15 at 17:17
  • Try adding the extension as reference in your solution explorer – alybaba726 May 22 '15 at 17:37
  • @alybaba726 I'm not sure what you mean. Do you mean add the assembly containing the extensions as a reference? If so, I did that first thing. All of the weird things I mention above relied on that fact. Like I said, the compiler is happy, and the code runs fine, so the reference is fine too. it is only an intellisense issue – ChrisC May 22 '15 at 18:13

0 Answers0