public virtual GeneratorInfo GetGeneratorInfo() { tracer.Trace("Discovering generator information...", "VsGeneratorInfoProvider"); GeneratorConfiguration generatorConfiguration = GenGeneratorConfig(); try { var generatorInfo = new GeneratorInfo { UsesPlugins = generatorConfiguration.UsesPlugins }; if (DetectFromConfig(generatorInfo, generatorConfiguration)) return generatorInfo; if (!DetectFromRuntimeReference(generatorInfo)) tracer.Trace("Unable to detect generator path", "VsGeneratorInfoProvider"); return generatorInfo; } catch (Exception exception) { tracer.Trace(exception.ToString(), "VsGeneratorInfoProvider"); return null; } }
private bool DetectFromConfig(GeneratorInfo generatorInfo, GeneratorConfiguration generatorConfiguration) { try { if (string.IsNullOrWhiteSpace(generatorConfiguration.GeneratorPath)) return false; var generatorFolder = Path.GetFullPath( Path.Combine(VsxHelper.GetProjectFolder(project), generatorConfiguration.GeneratorPath)); tracer.Trace("Generator is configured to be at " + generatorFolder, "VsGeneratorInfoProvider"); return DetectFromFolder(generatorInfo, generatorFolder); } catch(Exception exception) { tracer.Trace(exception.ToString(), "VsGeneratorInfoProvider"); return false; } }
public TestUpToDateChecker(ITestHeaderWriter testHeaderWriter, GeneratorInfo generatorInfo, ProjectSettings projectSettings) { this.testHeaderWriter = testHeaderWriter; this.generatorInfo = generatorInfo; this.projectSettings = projectSettings; }
private bool DetectFromFolder(GeneratorInfo generatorInfo, string generatorFolder) { const string generatorAssemblyFileName = generatorAssemblyName + ".dll"; var generatorPath = Path.Combine(generatorFolder, generatorAssemblyFileName); if (!File.Exists(generatorPath)) return false; tracer.Trace("Generator found at " + generatorPath, "VsGeneratorInfoProvider"); var fileVersion = FileVersionInfo.GetVersionInfo(generatorPath); if (fileVersion.FileVersion == null) { tracer.Trace("Could not detect generator version", "VsGeneratorInfoProvider"); return false; } generatorInfo.GeneratorAssemblyVersion = new Version(fileVersion.FileVersion); generatorInfo.GeneratorFolder = Path.GetDirectoryName(generatorPath); return true; }
private bool DetectFromRuntimeReference(GeneratorInfo generatorInfo) { var specFlowRef = VsxHelper.GetReference(project, "TechTalk.SpecFlow"); if (specFlowRef == null) return false; var specFlowRefPath = specFlowRef.Path; if (string.IsNullOrWhiteSpace(specFlowRefPath)) return false; string runtimeFolder = Path.GetDirectoryName(specFlowRefPath); if (runtimeFolder == null) return false; tracer.Trace("Runtime found at " + runtimeFolder, "VsGeneratorInfoProvider"); return probingPaths.Select(probingPath => Path.GetFullPath(Path.Combine(runtimeFolder, probingPath))) .Any(probingPath => DetectFromFolder(generatorInfo, probingPath)); }
private bool DetectDirectGeneratorReference(GeneratorInfo generatorInfo) { var specFlowGeneratorRef = VsxHelper.GetReference(project, generatorAssemblyName); if (specFlowGeneratorRef == null) return false; tracer.Trace("Direct generator reference found", "VsGeneratorInfoProvider"); generatorInfo.GeneratorAssemblyVersion = new Version(specFlowGeneratorRef.Version); generatorInfo.GeneratorFolder = Path.GetDirectoryName(specFlowGeneratorRef.Path); return true; }