private AntlrClassGenerationTaskInternal CreateBuildTaskWrapper(AppDomain domain)
{
AntlrClassGenerationTaskInternal wrapper = (AntlrClassGenerationTaskInternal)domain.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, typeof(AntlrClassGenerationTaskInternal).FullName);
IList<string> sourceCodeFiles = null;
if (this.SourceCodeFiles != null)
{
sourceCodeFiles = new List<string>(SourceCodeFiles.Length);
foreach (ITaskItem taskItem in SourceCodeFiles)
sourceCodeFiles.Add(taskItem.ItemSpec);
}
if (this.TokensFiles != null && this.TokensFiles.Length > 0)
{
HashSet<string> copied = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
foreach (ITaskItem taskItem in TokensFiles)
{
string fileName = taskItem.ItemSpec;
if (!File.Exists(fileName))
{
Log.LogError("The tokens file '{0}' does not exist.", fileName);
continue;
}
string vocabName = Path.GetFileNameWithoutExtension(fileName);
if (!copied.Add(vocabName))
{
Log.LogWarning("The tokens file '{0}' conflicts with another tokens file in the same project.", fileName);
continue;
}
string target = Path.Combine(OutputPath, Path.GetFileName(fileName));
if (!Path.GetExtension(target).Equals(".tokens", StringComparison.OrdinalIgnoreCase))
{
Log.LogError("The destination for the tokens file '{0}' did not have the correct extension '.tokens'.", target);
continue;
}
File.Copy(fileName, target, true);
File.SetAttributes(target, File.GetAttributes(target) & ~FileAttributes.ReadOnly);
}
}
wrapper.AntlrToolPath = AntlrToolPath;
wrapper.SourceCodeFiles = sourceCodeFiles;
wrapper.LibPaths = LibPaths;
wrapper.Language = Language;
wrapper.OutputPath = OutputPath;
wrapper.RootNamespace = RootNamespace;
wrapper.GeneratedSourceExtension = GeneratedSourceExtension;
return wrapper;
}