Main function of the library is parsing/reading of Oracle TNS names files. The library also aids in resolving TNS names files on the local machine.
A console application is provided that lists all available TNS names files and their TNS name entries. It uses Costura.Fody in the build process to embed all dll files inside the exe. This makes for a neat standalone / single file program.
Binaries for the library are provided as a NuGet package. The console application can be found under releases.
Prerequisite for compilation is Visual Studio extension ANTLR Language Support.
The library will catch syntax errors, but there are only a few symantic checks:
- Port numbers is ensured to be integer in range 1 to 65535.
- A TNS name must have at least one database address.
- All properties are ensured to have a value (TnsName, ServiceName, Protocol, Host, Port etc.).
/* NOTE
* differentiation between TnsNamesFileInfo (file not opened) and
* TnsNamesFile (file opened and information extracted)
*/
// get TnsNamesFileInfo for files
var rootFilesInfos = TnsNames.ResolveRootTnsNamesFiles();
// open files and recursivly open IFile entries
var allFiles = TnsNames.OpenTnsNamesFiles(rootFilesInfos, ignoreErrors: true, followIFileEntries: true);
// enumerate files and TNS name entries
foreach (var tnsNamesFile in allFiles)
{
foreach (var tnsName in tnsNamesFile.TnsNames)
{
// process TNS name entry
}
}
foreach (var tnsName in allFiles.EnumerateTnsNames())
{
// process TNS name entry
}
The TnsNames project include files from obj\ folder. This being unusal is a trick to get ReSharper working correctly in conjunction with ANTLR and the autogenerated parser code.
- ANTLR 4
- GitHub repository
- NuGet package erl.Oracle.TnsNames
- ANTLR.org
- Oracle TNS names documentation
- Costura.Fody on GitHub and NuGet
- Visual Studio extension ANTLR Language Support