Antlr4.Build.Tasks.Antlr4ClassGenerationTask.CreateBuildTaskWrapper C# (CSharp) Method

CreateBuildTaskWrapper() private method

private CreateBuildTaskWrapper ( ) : AntlrClassGenerationTaskInternal
return AntlrClassGenerationTaskInternal
        private AntlrClassGenerationTaskInternal CreateBuildTaskWrapper()
        {
            AntlrClassGenerationTaskInternal wrapper = new AntlrClassGenerationTaskInternal();

            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)
            {
                Directory.CreateDirectory(OutputPath);

                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.ToolPath = ToolPath;
            wrapper.SourceCodeFiles = sourceCodeFiles;
            wrapper.TargetLanguage = TargetLanguage;
            wrapper.TargetFrameworkVersion = TargetFrameworkVersion;
            wrapper.OutputPath = OutputPath;
            wrapper.Encoding = Encoding;
            wrapper.LanguageSourceExtensions = LanguageSourceExtensions;
            wrapper.TargetNamespace = TargetNamespace;
            wrapper.GenerateListener = GenerateListener;
            wrapper.GenerateVisitor = GenerateVisitor;
            wrapper.ForceAtn = ForceAtn;
            wrapper.AbstractGrammar = AbstractGrammar;
            wrapper.JavaVendor = JavaVendor;
            wrapper.JavaInstallation = JavaInstallation;
            wrapper.JavaExecutable = JavaExecutable;
            return wrapper;
        }