Skip to main content

Extension Methods

  • October 25, 2018
  • 8 replies
  • 0 views

 Are extension methods still recognized in the latest visual cobol for .net?  I have a very simple ext method I am trying out and it does not seem to be recognized.  I keep getting the error Undefined Error Contact Tech Support.  I have a static extensions class like this.  

class-id Extensions static.

 

Method-id CountWords(str as string) returning result as binary-long extension static.
    declare #words as string occurs any = str::Split(' ')
    set result to size of #words
end method.
End class.

 

 

Then my calling method is in another class like this.

Method-id SomeMethod()

declare a as string = "Mary"
declare b as binary-long = a::CountWords

End method.

 

Intellisense does not recognize CountWords as an extension and I get the error noted above.


#VisualCOBOL

8 replies

Chris Glazier
Forum|alt.badge.img+2

 Are extension methods still recognized in the latest visual cobol for .net?  I have a very simple ext method I am trying out and it does not seem to be recognized.  I keep getting the error Undefined Error Contact Tech Support.  I have a static extensions class like this.  

class-id Extensions static.

 

Method-id CountWords(str as string) returning result as binary-long extension static.
    declare #words as string occurs any = str::Split(' ')
    set result to size of #words
end method.
End class.

 

 

Then my calling method is in another class like this.

Method-id SomeMethod()

declare a as string = "Mary"
declare b as binary-long = a::CountWords

End method.

 

Intellisense does not recognize CountWords as an extension and I get the error noted above.


#VisualCOBOL
I just copied your example into a new project and it works fine.
I am using Visual COBOL V4.0 Patch Update 3 for Visual Studio 2017.

What version are you using?

  • October 25, 2018

 Are extension methods still recognized in the latest visual cobol for .net?  I have a very simple ext method I am trying out and it does not seem to be recognized.  I keep getting the error Undefined Error Contact Tech Support.  I have a static extensions class like this.  

class-id Extensions static.

 

Method-id CountWords(str as string) returning result as binary-long extension static.
    declare #words as string occurs any = str::Split(' ')
    set result to size of #words
end method.
End class.

 

 

Then my calling method is in another class like this.

Method-id SomeMethod()

declare a as string = "Mary"
declare b as binary-long = a::CountWords

End method.

 

Intellisense does not recognize CountWords as an extension and I get the error noted above.


#VisualCOBOL
Micro Focus Visual COBOL 4.0 Version 4.0.00243.

  • October 25, 2018

 Are extension methods still recognized in the latest visual cobol for .net?  I have a very simple ext method I am trying out and it does not seem to be recognized.  I keep getting the error Undefined Error Contact Tech Support.  I have a static extensions class like this.  

class-id Extensions static.

 

Method-id CountWords(str as string) returning result as binary-long extension static.
    declare #words as string occurs any = str::Split(' ')
    set result to size of #words
end method.
End class.

 

 

Then my calling method is in another class like this.

Method-id SomeMethod()

declare a as string = "Mary"
declare b as binary-long = a::CountWords

End method.

 

Intellisense does not recognize CountWords as an extension and I get the error noted above.


#VisualCOBOL
Visual Studio 2017

Chris Glazier
Forum|alt.badge.img+2

 Are extension methods still recognized in the latest visual cobol for .net?  I have a very simple ext method I am trying out and it does not seem to be recognized.  I keep getting the error Undefined Error Contact Tech Support.  I have a static extensions class like this.  

class-id Extensions static.

 

Method-id CountWords(str as string) returning result as binary-long extension static.
    declare #words as string occurs any = str::Split(' ')
    set result to size of #words
end method.
End class.

 

 

Then my calling method is in another class like this.

Method-id SomeMethod()

declare a as string = "Mary"
declare b as binary-long = a::CountWords

End method.

 

Intellisense does not recognize CountWords as an extension and I get the error noted above.


#VisualCOBOL
That is the same version I am using.
I just created a new managed console application and copied the following into the default program.
Does this work for you or do you get the same error?

program-id. Program1 as "testextensions.Program1".

data division.
working-storage section.

procedure division.
declare a as string = "Mary"
declare b as binary-long = a::CountWords

goback.

end program Program1.

class-id Extensions static.
Method-id CountWords(str as string) returning result as binary-long extension static.
declare #words as string occurs any = str::Split(' ')
set result to size of #words
end method.
End class.

  • October 25, 2018

 Are extension methods still recognized in the latest visual cobol for .net?  I have a very simple ext method I am trying out and it does not seem to be recognized.  I keep getting the error Undefined Error Contact Tech Support.  I have a static extensions class like this.  

class-id Extensions static.

 

Method-id CountWords(str as string) returning result as binary-long extension static.
    declare #words as string occurs any = str::Split(' ')
    set result to size of #words
end method.
End class.

 

 

Then my calling method is in another class like this.

Method-id SomeMethod()

declare a as string = "Mary"
declare b as binary-long = a::CountWords

End method.

 

Intellisense does not recognize CountWords as an extension and I get the error noted above.


#VisualCOBOL
I will test that and see. Currently I am developing a managed windows form application and trying to use extension methods per my previous post.

  • October 25, 2018

 Are extension methods still recognized in the latest visual cobol for .net?  I have a very simple ext method I am trying out and it does not seem to be recognized.  I keep getting the error Undefined Error Contact Tech Support.  I have a static extensions class like this.  

class-id Extensions static.

 

Method-id CountWords(str as string) returning result as binary-long extension static.
    declare #words as string occurs any = str::Split(' ')
    set result to size of #words
end method.
End class.

 

 

Then my calling method is in another class like this.

Method-id SomeMethod()

declare a as string = "Mary"
declare b as binary-long = a::CountWords

End method.

 

Intellisense does not recognize CountWords as an extension and I get the error noted above.


#VisualCOBOL
That worked in a console application, but is still not working in my managed windows form application. I found some old code I developed using Visual Studio 2015 Visual Cobol and a windows form application where the extension methods worked and were recognized.

Chris Glazier
Forum|alt.badge.img+2

 Are extension methods still recognized in the latest visual cobol for .net?  I have a very simple ext method I am trying out and it does not seem to be recognized.  I keep getting the error Undefined Error Contact Tech Support.  I have a static extensions class like this.  

class-id Extensions static.

 

Method-id CountWords(str as string) returning result as binary-long extension static.
    declare #words as string occurs any = str::Split(' ')
    set result to size of #words
end method.
End class.

 

 

Then my calling method is in another class like this.

Method-id SomeMethod()

declare a as string = "Mary"
declare b as binary-long = a::CountWords

End method.

 

Intellisense does not recognize CountWords as an extension and I get the error noted above.


#VisualCOBOL
It would probably be best for you to open up a support incident with Customer Support and I could take a look at what you are doing. You could put my name in the description and that way it will be routed to me.

  • October 25, 2018

 Are extension methods still recognized in the latest visual cobol for .net?  I have a very simple ext method I am trying out and it does not seem to be recognized.  I keep getting the error Undefined Error Contact Tech Support.  I have a static extensions class like this.  

class-id Extensions static.

 

Method-id CountWords(str as string) returning result as binary-long extension static.
    declare #words as string occurs any = str::Split(' ')
    set result to size of #words
end method.
End class.

 

 

Then my calling method is in another class like this.

Method-id SomeMethod()

declare a as string = "Mary"
declare b as binary-long = a::CountWords

End method.

 

Intellisense does not recognize CountWords as an extension and I get the error noted above.


#VisualCOBOL
OK. Thanks Chris. I will do that shortly.