Monday, January 3, 2011

The .NET Preprocessor - Part 3

NTSTATUS: STATUS_DOTNET_MACRO


Now let’s go through the config file that DOTNETPP expects. It’s an XML file, and doesn’t expect any special name, and I called mine dotnetpp.xml. Here are the settings:

<?xml version="1.0" encoding="utf-8" ?>

<Settings>

<Language>C#</Language>

<Extension>.cs</Extension>

<MacroFilePath>.\MyMacros.npp</MacroFilePath>

<SourceBasePath>C:\MyProject</SourceBasePath>

<RecurseSubDirectories>true</RecurseSubDirectories>

<RestoreMacrosInSource>false</RestoreMacrosInSource>

<CleanupOriginalSources>false</CleanupOriginalSources>

<ClenupExpandedSources>false</ClenupExpandedSources>

<Diagnostics>

<stdout>true</stdout>

<debug>true</debug>

</Diagnostics>

</Settings>

Following are the meanings of each setting item:

Language: [C#/VB]

Supports only ‘C#’ and ‘VB’ where it will look for files of their respective extensions.

Extension: source file extensions including the dot (.cs, .vb)

OK, so it doesn’t only specifically support only .NET languages like C#/VB.NET. It will parse files of any extension you specify here. And this setting will override the <Language> setting.

MacroFilePath: Full path to the macro file

No specific file name, but will expect .npp as an extension. Currently, this setting expects the full path to a file, but does not harp on the file name or extension. However, the next feature upgrade will allow you to put a path (directory) in this setting, and it will look for all .npp files to parse for marco definitions.

SourceBasePath: The base path of the source files which require macro expansion

Usually would either be the path of your solution, or project.

RecurseSubDirectories: [true/false]

Recurse the subdirectories of <SourceBasePath> in search of source files

RestoreMacrosInSource: [true/false]

Restore the macros in the source files after expansion. Refer to ‘The Catch’ in Part 2. As mentioned prior, might be a better way to NOT restore macros and have them ‘permanently’ expanded into actual source.

CleanupOriginalSources: [true/false]

Delete all saved copies of source files before the expansion

ClenupExpandedSources: [true/false]

Delete all copies of the expanded source files. They have the extension .nmx. There was some challenge in finding an extension that was not already used and had an associated application.

stdout: [true/false]

Output messages to stdout.

debug: [true/false]

Output messages to the Debugger. Can be viewed with DebugView from Sysinternals.

No comments:

Post a Comment