Fields Summary |
---|
private static final org.apache.tools.ant.util.FileUtils | FILE_UTILS |
private File | sourceFilesource file (mandatory) |
private File | destFiledest file (mandatory) |
private boolean | progressBarprogress bar switch |
private String | encodingwhat is our encoding |
private boolean | bytes/bytes flag for byte markup |
private boolean | linenumbersline numbers? /linenum |
private boolean | rawExceptionHandling/raweh flag for raw exception handling |
private boolean | showSourceshow the source; /source |
private boolean | quoteallnames/quoteallnames to quote all names |
private boolean | header/header for header information |
private boolean | assemblerwhen false, sets the /noil attribute
to suppress assembly info |
private boolean | metadatainclude metadata
/tokens |
private String | visibilitywhat visibility do we want. |
private String | itemspecific item to disassemble |
private String | executableoverride for the executable |
private File | resourceDirname of the directory for resources to be created. We cannot control
their names, but we can say where they get created. If not set, the
directory of the dest file is used |
Methods Summary |
---|
public void | execute()do the work
log("This task is deprecated and will be removed in a future version\n"
+ "of Ant. It is now part of the .NET Antlib:\n"
+ "http://ant.apache.org/antlibs/dotnet/index.html",
Project.MSG_WARN);
validate();
if (!isDisassemblyNeeded()) {
return;
}
NetCommand command = new NetCommand(this, "ildasm", executable);
command.setFailOnError(true);
//fill in args
command.addArgument("/text");
command.addArgument("/out=" + destFile.toString());
if (!progressBar) {
command.addArgument("/nobar");
}
if (linenumbers) {
command.addArgument("/linenum");
}
if (showSource) {
command.addArgument("/source");
}
if (quoteallnames) {
command.addArgument("/quoteallnames");
}
if (header) {
command.addArgument("/header");
}
if (!assembler) {
command.addArgument("/noil");
}
if (metadata) {
command.addArgument("/tokens");
}
command.addArgument("/item:", item);
if (rawExceptionHandling) {
command.addArgument("/raweh");
}
command.addArgument(EncodingTypes.getEncodingOption(encoding));
if (bytes) {
command.addArgument("/bytes");
}
command.addArgument("/vis:", visibility);
//add the source file
command.addArgument(sourceFile.getAbsolutePath());
//determine directory: resourceDir if set,
//the dir of the destFile if not
File execDir = resourceDir;
if (execDir == null) {
execDir = destFile.getParentFile();
}
command.setDirectory(execDir);
//now run
try {
command.runCommand();
} catch (BuildException e) {
//forcibly delete the output file in case of trouble
if (destFile.exists()) {
log("Deleting destination file as it may be corrupt");
destFile.delete();
}
//then rethrow the exception
throw e;
}
|
private boolean | isDisassemblyNeeded()Test for disassembly being needed; use existence and granularity
correct date stamps
if (!destFile.exists()) {
log("Destination file does not exist: a build is required",
Project.MSG_VERBOSE);
return true;
}
long sourceTime = sourceFile.lastModified();
long destTime = destFile.lastModified();
if (sourceTime > (destTime + FILE_UTILS.getFileTimestampGranularity())) {
log("Source file is newer than the dest file: a rebuild is required",
Project.MSG_VERBOSE);
return true;
} else {
log("The .il file is up to date", Project.MSG_VERBOSE);
return false;
}
|
public void | setAssembler(boolean assembler)enable (default) or disable assembly language in the output
this.assembler = assembler;
|
public void | setBytes(boolean bytes)enable or disable (default) the original bytes as comments
this.bytes = bytes;
|
public void | setDestFile(java.io.File destFile)the output file (required)
this.destFile = destFile;
|
public void | setEncoding(org.apache.tools.ant.taskdefs.optional.dotnet.Ildasm$EncodingTypes encoding)Select the output encoding: ascii, utf8 or unicode
this.encoding = encoding.getValue();
|
public void | setExecutable(java.lang.String executable)override the name of the executable (normally ildasm) or set
its full path. Do not set a relative path, as the ugly hacks
needed to create resource files in the dest directory
force us to change to this directory before running the application.
i.e use <property location> to create an absolute path from a
relative one before setting this value.
this.executable = executable;
|
public void | setHeader(boolean header)include header information; default false.
this.header = header;
|
public void | setItem(java.lang.String item)name a single item to decode; a class or a method
e.g item="Myclass::method" or item="namespace1::namespace2::Myclass:method(void(int32))
this.item = item;
|
public void | setLinenumbers(boolean linenumbers)include line number information; default=false
this.linenumbers = linenumbers;
|
public void | setMetadata(boolean metadata)include metadata information
this.metadata = metadata;
|
public void | setProgressBar(boolean progressBar)show a graphical progress bar in a window during the process; off by default
this.progressBar = progressBar;
|
public void | setQuoteallnames(boolean quoteallnames)quote all names.
this.quoteallnames = quoteallnames;
|
public void | setRawExceptionHandling(boolean rawExceptionHandling)enable raw exception handling (default = false)
this.rawExceptionHandling = rawExceptionHandling;
|
public void | setResourceDir(java.io.File resourceDir)Set the name of the directory for resources to be created. We cannot control
their names, but we can say where they get created. If not set, the
directory of the dest file is used
this.resourceDir = resourceDir;
|
public void | setShowSource(boolean showSource)include the source as comments (default=false)
this.showSource = showSource;
|
public void | setSourceFile(java.io.File sourceFile)the file to disassemble -required
this.sourceFile = sourceFile;
|
public void | setSrcFile(java.io.File sourceFile)alternate name for sourceFile
setSourceFile(sourceFile);
|
public void | setVisibility(java.lang.String visibility)This method sets the visibility options. It chooses one
or more of the following, with + signs to concatenate them:
pub : Public
pri : Private
fam : Family
asm : Assembly
faa : Family and Assembly
foa : Family or Assembly
psc : Private Scope
e.g. visibility="pub+pri".
Family means protected in C#;
this.visibility = visibility;
|
private void | validate()verify that source and dest are ok
if (sourceFile == null || !sourceFile.exists() || !sourceFile.isFile()) {
throw new BuildException("invalid source");
}
if (destFile == null || destFile.isDirectory()) {
throw new BuildException("invalid dest");
}
if (resourceDir != null
&& (!resourceDir.exists() || !resourceDir.isDirectory())) {
throw new BuildException("invalid resource directory");
}
|