Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Visual Studio doesn't detect invalid parameter type errors?

Visual Studio doesn't detect invalid parameter type errors?

Scheduled Pinned Locked Moved C#
visual-studiocsharpgraphicshelptutorial
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    Xargo
    wrote on last edited by
    #1

    I've been working with Visual Studio as hobbyist for a few years, but I only discovered this today. The way I found out was by moving some methods to another class. One of the methods used a Point class (of the System.Drawing namespace), but I didn't add a using-directive for that namespace. Then when I wanted to pass an instance of the Point class to that method from another class (which did have the directive to System.Drawing), it told me I was passing the wrong type. That's when I discovered I forgot the using-directive to System.Drawing in the codefile of the method that also used the Point class. However, Visual Studio never warned me for that. Although the type I defined for that parameter was completely non-existing, it didn't mark it. Even if I said the parameter should be of type "sldhfsdf", which didn't exist at all (no directive to a potential namespace could have solved that), it still didn't mention anything, and acted as if it was an existing type. I could even use the parameter in the method, and it would propose it in the IntelliSense list. Only I try to compile, it does return an error. To clarify, here's an example that seems to be alright to Visual Studio's error checking.

    public class Test
    {
    public void MyMethod(abcabc var1)
    {
    var1 = null;
    }
    }

    While writing this piece of code, Visual Studio won't tell me this is wrong. The only way to find out is by compiling, or calling the method somewhere so it would tell me I'm either passing an unexisting or invalid variable. Both Visual Studio 2008 and 2005 seem to do this. Could anyone explain me why this is the case?

    R 1 Reply Last reply
    0
    • X Xargo

      I've been working with Visual Studio as hobbyist for a few years, but I only discovered this today. The way I found out was by moving some methods to another class. One of the methods used a Point class (of the System.Drawing namespace), but I didn't add a using-directive for that namespace. Then when I wanted to pass an instance of the Point class to that method from another class (which did have the directive to System.Drawing), it told me I was passing the wrong type. That's when I discovered I forgot the using-directive to System.Drawing in the codefile of the method that also used the Point class. However, Visual Studio never warned me for that. Although the type I defined for that parameter was completely non-existing, it didn't mark it. Even if I said the parameter should be of type "sldhfsdf", which didn't exist at all (no directive to a potential namespace could have solved that), it still didn't mention anything, and acted as if it was an existing type. I could even use the parameter in the method, and it would propose it in the IntelliSense list. Only I try to compile, it does return an error. To clarify, here's an example that seems to be alright to Visual Studio's error checking.

      public class Test
      {
      public void MyMethod(abcabc var1)
      {
      var1 = null;
      }
      }

      While writing this piece of code, Visual Studio won't tell me this is wrong. The only way to find out is by compiling, or calling the method somewhere so it would tell me I'm either passing an unexisting or invalid variable. Both Visual Studio 2008 and 2005 seem to do this. Could anyone explain me why this is the case?

      R Offline
      R Offline
      realJSOP
      wrote on last edited by
      #2

      I think you have to tell intellisense to check parameters.

      .45 ACP - because shooting twice is just silly
      -----
      "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
      -----
      "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

      X 1 Reply Last reply
      0
      • R realJSOP

        I think you have to tell intellisense to check parameters.

        .45 ACP - because shooting twice is just silly
        -----
        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
        -----
        "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

        X Offline
        X Offline
        Xargo
        wrote on last edited by
        #3

        How do I do this? I've been searching for it on the internet, but can't find it. The Intellisense options seem rather limited.

        R 1 Reply Last reply
        0
        • X Xargo

          How do I do this? I've been searching for it on the internet, but can't find it. The Intellisense options seem rather limited.

          R Offline
          R Offline
          realJSOP
          wrote on last edited by
          #4

          Hmmm, I coulda sworn this was possible. I think this is just part of VS2008. I'll check 2010 when I get home and see if they've fixed it.

          .45 ACP - because shooting twice is just silly
          -----
          "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
          -----
          "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

          X 1 Reply Last reply
          0
          • R realJSOP

            Hmmm, I coulda sworn this was possible. I think this is just part of VS2008. I'll check 2010 when I get home and see if they've fixed it.

            .45 ACP - because shooting twice is just silly
            -----
            "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
            -----
            "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

            X Offline
            X Offline
            Xargo
            wrote on last edited by
            #5

            Anyone still has an idea? This seems rather weird...

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups