DXCore APIs related to the programming languages specification
Every programming language has its own language specification. There are numerous rules for each language that vary between programming languages. DXCore supports several programming languages and provides APIs to determine specific rules for them. These APIs are available primarly through the DXCore Language service. Let’s review the most important methods and properties of this service, comparing the CSharp (C#) and Visual Basic (VB) programming languages.
Language keywords
- IsKeyword(String) – returns true if the specified string is a legal keyword for the active language.
C#: returns true for the following words: ‘abstract’, ‘as’, ‘base’, ‘bool’, ‘break’, ‘catch’, ‘class’, ‘delegate’, ‘double’, ‘if’, ‘for’, ‘new’, ‘return’, ‘private’, ‘struct’, ‘typeof’, ‘var’, ‘void’, etc.
VB: returns true for the following words: ‘AddressOf’, ‘AndAlso’, ‘As’, ‘Boolean’, ‘ByRef’, ‘CDate’, ‘CInt’, ‘Class’, ‘Dim’, ‘ElseIf’, ‘End’, ‘For’, ‘Function’, ‘Me’, ‘Property’, ‘Shared’, ‘Sub’, ‘WithEvents’, etc.
- GetIdentifierFromKeyword(String) – returns an identifier from the keyword for the active language. If the passed-in string is not a keyword, then the method does not process it.
C#: returns the ‘@class’ string if the ‘class’ string is passed
VB: returns the ‘[Class]’ string if the ‘Class’ string is passed
- RemoveKeywordEscapeCharactersFromIdentifier(String) – removes the keyword escape characters (like ‘@’ in C#, or ‘[]‘ inVB) from an identifier name.
C#: returns the ‘class’ string if the ‘@class’ string is passed
VB: returns the ‘Class’ string if the ‘[Class]’ string is passed
- GetVisibility(MemberVisibility, String) – returns a language specific ‘visibility’ keyword name.
C#: returns the following values: ‘private’, ‘public’, ‘internal’, ‘protected’ or ‘protected internal’.
VB: returns the following values: ‘Private’, ‘Public’, ‘Friend’, ‘Protected’, ‘Protected Friend’, etc
Language built-in types
- IsBuiltInType(String) – returns true if the given type name is a language built-in type name.
C#: returns true for the following words: ‘bool’, ‘int’, ‘object’, ‘double’, ‘float’, etc.
VB: returns true for the following words: ‘Boolean’, ‘Integer’, ‘Object’, ‘Double’, ‘Single’, etc.
- GetSimpleTypeName(String) – returns a simple type name for the given full type name.
C#: returns the ‘bool’ string if the ‘System.Boolean’ string is passed
VB: returns the ‘Boolean’ string if the ‘System.Boolean’ string is passed
- GetFullTypeName(String) – returns a full type name for the given built-in type.
C#: returns the ‘System.Int32’ string if the ‘int’ string is passed
VB: returns the ‘System.Int32’ string if the ‘Integer’ string is passed
Language statements and code elements
- GetContinueStatement – returns a continue statement for the given language, if supported.
C#: returns ‘continue’
VB: returns ‘Continue’
- GetImportsStatement(String) – returns a properly-formatted Imports statement (VB) or using directive (C#) for the specified namespace.
C#: returns the ‘using System;’ string if the ‘System’ string is passed
VB: returns the ‘Imports System’ string if the ‘System’ string is passed
- GetNullCheck(String) – returns a language specific check for null.
C#: returns the ‘value == null’ string if the ‘value’ string is passed
VB: returns the ‘value IsNot Nothing’ string if the ‘value’ string is passed
- GetNullReferenceExpression(String) – returns a null reference expression for the given language
C#: returns the ‘null’ string
VB: returns the ‘nothing’ string
- GetRegionHeader(String) – returns a properly formatted region directive header with the passed-in caption.
C#: returns the ‘#region Caption’ string if the ‘Caption’ string is passed
VB: returns the ‘#Region “Caption”‘ string if the ‘Caption’ string is passed
- GetRegionFooter – returns a properly formatted region directive footer.
C#: returns the ‘#endregion’ string
VB: returns the ‘#End Region’ string
Language primitives (numbers and strings)
- IsNumber(String) – returns true if the specified string is a legal number for the active language.
C#: returns true for the following string: ‘100M’
VB: returns true for the following string: ‘100f’
- GetHexadecimalValuePresentation – returns a hexadecimal value.
C#: returns the ‘0xFF’ string if the ‘255’ string is passed
VB: returns the ‘HFF’ string if the ‘255’ string is passed
Language declaration rules
- IsCaseSensitive – returns true if the active file contains a case-sensitive language.
C#: returns true
VB: returns false
- DeclaresTypeBeforeName – returns true if the current language declares the type before the name in variable or parameter declarations.
C#: returns true
VB: returns false
- StatementTerminator – gets the statement terminator for the active language.
C#: returns the ‘;’ character
VB: returns the CRLF character
—– Products: DXCore Versions: 11.1 and up VS IDEs: any Updated: Aug/30/2011 ID: D110