我有自定义工具和 IVsSingleFileGenerator 的实现。 如何跳过生成文件并保留当前版本的输出内容(防止重新生成)?
int IVsSingleFileGenerator.Generate(string wszInputFilePath, string bstrInputFileContents, string wszDefaultNamespace, IntPtr[] rgbOutputFileContents, out uint pcbOutput, IVsGeneratorProgress pGenerateProgress)
{
if(some_expression)
// Skip this file from generate and keep the current version
}
当我返回 pcbOutput = 0 时,输出文件被清除。
最佳答案
读取输出文件的现有内容。然后将它们塞回 pcbOutput
public int Generate(string wszInputFilePath, string bstrInputFileContents, string wszDefaultNamespace, IntPtr[] rgbOutputFileContents, out uint pcbOutput, IVsGeneratorProgress pGenerateProgress)
{
var originalFileName = GetOriginalFileName(wszInputFilePath);
SaveOutputContent(rgbOutputFileContents, out pcbOutput, system.IO.File.ReadAllText(originalFileName));
return VSConstants.S_OK;
}
您必须为 GetOriginalFileName 编写代码
关于c# - 如何跳过 IVsSingleFileGenerator 中的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22409931/