none
How to make intellisense aware of my custom lib? RRS feed

  • Question

  • I would like to make my custom library, which will translate the Small Basic Turtle command to my language, so that it would be easier to teach my children making first steps into programming world. I made a cs file and translated it to dll by using the csc compiler. When I start Small Basic, it works nice. New commands also appear in the intellisense window, but there is no description for them, of course. I built an XML file with descriptions and put it into the lib folder. But still there is no description in the intellisense. I also tried to install some DLLs from this forum and also here i experence the same thing - the lib works, but the help doesn't. What am i missing?

    Next (as i am a beginner in c programmig) i would also like to ask how to make translations of turtle properties. (I managed to make only translations of turtle methods, which is very simple).

    • Edited by AZalar Thursday, May 6, 2010 5:23 AM
    Wednesday, May 5, 2010 1:12 PM

Answers

  • I have a range of simple extensions in C# and C++ on my SkyDrive.  This is a simple C++ extension to get the system colours by name using Properties I wrote for my kids.  There is also a speech and music (C#, requires DirectX runtime or SDK to build), music file play time (C++), serial port (C#), spawn processes (C#).

    EDIT

    Simple C# property set & get syntax code:

    using System;
    using Microsoft.SmallBasic.Library;
    namespace SBTest
    {
        [SmallBasicType]
        public static class TestProperty
        {
            static Primitive my_Property;

            /// <summary>
            /// Simple property test.
            /// </summary>
            public static Primitive PropertyName
            {
                get
                {
                    return my_Property;
                }
                set
                {
                    my_Property = value;
                }
            }
        }
    }

    SmallBasic Code:

    TestProperty. PropertyName = "Hello"
    TextWindow.WriteLine(TestProperty.
    PropertyName )

    • Marked as answer by AZalar Monday, May 10, 2010 5:42 AM
    Friday, May 7, 2010 6:12 PM
    Moderator

All replies

  • XML help - Check you have no SmallBasicLibrary.dll or SmallBasicLibrary.xml in the lib directory - this has caused some issues.  Apart from that you could upload your dll and xml for others to check, but since you have issues with all extensions your files probably aren't the problem.  You could try a re-install, check you have .Net 3.5 SP1 (you probably have otherwise I doubt anything will would work).

    To get the Turtle to do anything more complex than just using the SmallBasic Turtle methods will be quite a bit more complex - look at Fremy's extension VB source as some examples of how you might start doing this.

    You can also use the free .Net decompiler "Reflector" to look at the SmallBasicLibrary.dll to get some more hints.

    You could quite easily generate sequences of Turtle commands to do things like draw a square, circle etc. and embed these in a set of extension commands, a bit like some SmallBasic subroutines compiled into an extension dll.

    Wednesday, May 5, 2010 7:17 PM
    Moderator
  • Thanks for the answer. I will follow your advice about the Turtle. The question that bothers me most is the one about intellisense. I checked that i have .Net 3.5 SP1, I also tried to reinstall Small Basic v0.8, but it didn't help. For example I am testing the ToneGenerator extension, I found on this forum. I put the DLL and XML in a newly created lib folder in the SB installation path. After starting SB, new commands can be used, they appear in the intellisense window, but there is no description of their usage. Any more hints on what I am doing wrong?

    Where can I get the Fremy's Extension VB source?

     

    Thursday, May 6, 2010 5:22 AM
  • AZalar,

    I checked the ToneGen extension and was surprised to find that it didn't work for me, just as you described.  I then rebuilt it in C# and it worked fine, so then looked at the different xml generated.  The difference is that the project name is ToneGen (ToneGen.dll and ToneGen.xml) and that in the xml it is ToneGen2 .

    The original ToneGen.xml downloaded has stuff like:

    <member name="T:ToneGen2 .ToneGenerator">

    My created xml has stuff like:

    <member name="T:ToneGen.ToneGenerator">

    As a final check I just modified the original (removing the 2 where necessary) and it worked.

    So the rule seems to be that the extension project name must be consistent throughout, ie. the generated files and the project namespace in the code, for example:

    namespace ToneGen

    FC (FremyCompany) source used to be on his SkyDrive , I checked and he seems to have deleted it - I guess you could ask him on his SkyDrive if he is still happy to share it?

    Thursday, May 6, 2010 6:32 PM
    Moderator
  • Thanks for the catch, I originally planned on rewriting it, but decided on just having the user recompile for each new version.  I guess I jumbled the different files together.  I fixed it now.
    Friday, May 7, 2010 1:53 AM
  • Thanks for the answer. ToneGen is now OK. But my own dll was still not showing in the intellisence. I was doublechecking all the names and it took me quite long to find the problem. At the end I figured out, that I was using some language specific characters in the summary section. After I have put the encoding="windows-1250" in the xml tag, it started working. So thank you again for helping me solve this issue.

    Does anybody know of any other CS source for SB, that includes Properties, not only Methods, so that I can see how it is built?

    Friday, May 7, 2010 6:29 AM
  • I have a range of simple extensions in C# and C++ on my SkyDrive.  This is a simple C++ extension to get the system colours by name using Properties I wrote for my kids.  There is also a speech and music (C#, requires DirectX runtime or SDK to build), music file play time (C++), serial port (C#), spawn processes (C#).

    EDIT

    Simple C# property set & get syntax code:

    using System;
    using Microsoft.SmallBasic.Library;
    namespace SBTest
    {
        [SmallBasicType]
        public static class TestProperty
        {
            static Primitive my_Property;

            /// <summary>
            /// Simple property test.
            /// </summary>
            public static Primitive PropertyName
            {
                get
                {
                    return my_Property;
                }
                set
                {
                    my_Property = value;
                }
            }
        }
    }

    SmallBasic Code:

    TestProperty. PropertyName = "Hello"
    TextWindow.WriteLine(TestProperty.
    PropertyName )

    • Marked as answer by AZalar Monday, May 10, 2010 5:42 AM
    Friday, May 7, 2010 6:12 PM
    Moderator
  • Thanks, litdev, this is exactly what I was looking for.
    Monday, May 10, 2010 5:41 AM
  • What is the Visual Basic version of the above.  What I am trying to do is build my own dll for small basic.

    I created the following ClassLibrary using Visual Studio Express 2010, but obvisily I am missing somethings.  Can you help?

    Public Class RWJ

      Public Function DemoAddition(ByVal _Add1 As Double, ByVal As Double) As Double

         Return( _Add1 + Add2)

      End Function 

    Class End

     

     

     

    Many thanks

    Bob

    Saturday, July 17, 2010 8:44 PM
  • Bob,

    VB2010 Express

    New Project=>Class Library

    Project=>Add Reference=>Browse=>(C:\Program Files\Microsoft\Small Basic\SmallBasicLibrary.dll)

    Save Project

    Solution Explorer=>Properties=>Compile=>Advanced Compile Options=>Target .Net 3.5 Framework

    Extension code:


    Imports System
    Imports Microsoft.SmallBasic.Library

    ''' <summary>
    ''' Simple property test.
    ''' </summary>
    <SmallBasicType()> Public Module TestProperty
        Public my_Property As Primitive
        ''' <summary>
        ''' A Property.
        ''' </summary>
        Public Property PropertyName As Primitive
            Get
                Return my_Property
            End Get
            Set(ByVal value As Primitive)
                my_Property = value
            End Set
        End Property

        ''' <summary>
        ''' Addition.
        ''' </summary>
        ''' <param name="Val1">
        ''' First number.
        ''' </param>
        ''' <param name="Val2">
        ''' Second number.
        ''' </param>
        '''<returns>
        ''' Sum.
        ''' </returns>
        Public Function DemoAddition(ByVal Val1 As Primitive, ByVal Val2 As Primitive) As Primitive
            Return (Val1 + Val2)
        End Function
    End Module

    Compile and copy dll + xml to lib

    SmallBasic Code:

    TestProperty.PropertyName = "AA"
    TextWindow.WriteLine(TestProperty.PropertyName)
    TextWindow.WriteLine(TestProperty.DemoAddition(1,2))

     

    • Proposed as answer by Robert W Jones Saturday, July 17, 2010 11:41 PM
    Saturday, July 17, 2010 9:28 PM
    Moderator
  • Wow, that explains a lot!  I noticed that if you don't have the lines begining ''' before the Function SmallBasic will not see it.  Is that right?

    Opens the doors to all sorts of possiblities and it is so easy todo!

    Many Thanks!

    Bob

    Saturday, July 17, 2010 11:41 PM
  • The ''' lines are the info for the xml intellisense, without them it should still work, but have no intellisense.

    Also note that the data types used must be type Primitive for input and return from functions - however these can be slow for some operations, so for complex calculations (not this one really) you may want to use native types internally, such as:

        Dim dVal1, dVal2, dRet As Double
        ''' <summary>
        ''' Addition.
        ''' </summary>
        ''' <param name="Val1">
        ''' First number.
        ''' </param>
        ''' <param name="Val2">
        ''' Second number.
        ''' </param>
        '''<returns>
        ''' Sum.
        ''' </returns>
        Public Function DemoAddition(ByVal Val1 As Primitive, ByVal Val2 As Primitive) As Primitive
            dVal1 = Val1
            dVal2 = Val2
            dRet = dVal1 + dVal2
            Return dRet
        End Function

    Sunday, July 18, 2010 9:24 AM
    Moderator
  • okay, many thanks.

    I noticed that in VS2010 Express if you type in the function first then goto the line above all you have to type is ''' and VS inserts  the XML code for you! You just have to fill in the blanks, so to speak!

    Again Many Thanks

    Bob 

    Sunday, July 18, 2010 11:29 PM
  • I created, as an experiment, a function where Val1 is passed byref.  It did not show in SmallBasic in Intellisense or compile.  If you change byref to byval it does appear.  I am guessing that if SmallBasic finds a bug in your function, the only indicator is that it will not appear in  intellisence and while not compile.

    Take this one step further, If a Module contains only one function that SmallBasic does not like, the Module while not appear or compile.

    Note Even though your DLL compiles error free, it does not mean the SMallBasic will like it!

    Bob  

    Monday, July 19, 2010 2:15 AM
  • Bob,

    All your observations seem right - the intellisense needs to be wholy correct.  I think you should always pass by byVal (the actual value) rather than byRef (a pointer), since in SmallBasic the arguments are always of type Primitive.  The same applies if you pass an array, which can infact be interpreted as a string of records setpared by ;

    a[1] = "Hello"
    a["X"] = 24
    TextWindow.WriteLine(a)

    Gives:

    1=Hello;X=24;

    Which could be interpreted as an array inside an extension.

    Monday, July 19, 2010 5:37 PM
    Moderator
  • Small Basic intellisense can't see is there bugs in your function, but it adds only those functions whose have right return and parameter types (Primitive). Because of structure of small basic it only allows actual values just like litdev wrote.

    Sorry My Bad English
    Wednesday, July 21, 2010 10:04 AM