/// <summary> /// Gets project reference from candidates. /// </summary> /// <param name="scope">Scope.</param> /// <returns>Project reference.</returns> private ProjectReference GetFromCandidates(IMetadataScope scope) { string publicKeyToken = scope.GetScopePublicKeyToken(); string assemblyName = scope.GetAssemblyName(); return(CandidateReferences.FirstOrDefault( item => string.Compare(item.Name, assemblyName, StringComparison.OrdinalIgnoreCase) == 0 && string.Compare(item.PublicKeyToken, publicKeyToken, StringComparison.OrdinalIgnoreCase) == 0)); }
/// <summary> /// Remove references from candidates. /// </summary> /// <param name="reference">The project reference.</param> public void RemoveFromCandidates(ProjectReference reference) { if (_candidateReferences == null) { throw Error.ObjectDisposed(this); } if (reference != null) { CandidateReferences.Remove(reference); } }
public int InsertReferences(CandidateReferences candidateReferences) { using (var conn = SqlConnectionFactory.CreateConnection()) { var sql = "INSERT INTO CandidateReferences " + " (CandidateId, Name, Duration, Designation, Organization, Email, Mobile, AlternateNumber) " + " VALUES (@CandidateId, @Name, @Duration, @Designation, @Organization, @Email, @Mobile, @AlternateNumber)" + " SELECT CAST(SCOPE_IDENTITY() as int)"; var result = conn.Query <int>(sql, new { candidateReferences.CandidateId, candidateReferences.Name, candidateReferences.Duration, candidateReferences.Designation, candidateReferences.Organization, candidateReferences.Email, candidateReferences.Mobile, candidateReferences.AlternateNumber }).Single(); return(result); } }
public override bool Execute() { if (String.IsNullOrEmpty(PackageTargetFramework)) { Log.LogMessage(LogImportance.Low, $"Skipping validation since PackageTargetFramework is not defined"); return(true); } NuGetFramework fx = null; try { fx = NuGetFramework.Parse(PackageTargetFramework); } catch (Exception ex) { Log.LogError($"Could not parse PackageTargetFramework {PackageTargetFramework}. {ex}"); return(false); } Version assemblyVersion = null; if (!Version.TryParse(AssemblyVersion, out assemblyVersion)) { Log.LogError($"Could not parse AssemblyVersion {AssemblyVersion}."); return(false); } if (UseNetPlatform) { if (fx.Framework == FrameworkConstants.FrameworkIdentifiers.NetStandard) { Log.LogError($"Validating for legacy 'dotnet' moniker but package targets new 'netstandard' moniker."); return(false); } else if (fx.Framework != FrameworkConstants.FrameworkIdentifiers.NetPlatform) { Log.LogMessage(LogImportance.Low, $"Skipping validation since PackageTargetFramework {fx} is not {FrameworkConstants.FrameworkIdentifiers.NetPlatform}"); return(true); } } else { if (fx.Framework == FrameworkConstants.FrameworkIdentifiers.NetPlatform) { if (fx.Version > new Version(5, 0)) { NuGetFramework netstandardFx = new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.NetStandard, new Version(fx.Version.Major - 4, fx.Version.Minor - 1)); Log.LogError($"{fx.GetShortFolderName()} is no longer supported please update to {netstandardFx.GetShortFolderName()}. Validating as {netstandardFx.GetShortFolderName()}."); // update to netstandard so that we can get the right number of errors fx = netstandardFx; } else { Log.LogError($"Invalid framework version {fx.GetShortFolderName()} please update to appropriate netstandard version."); // update to nestandard so that we'll do the actual calculation fx = FrameworkConstants.CommonFrameworks.NetStandard; } } if (fx.Framework != FrameworkConstants.FrameworkIdentifiers.NetStandard) { Log.LogMessage(LogImportance.Low, $"Skipping validation since PackageTargetFramework {fx} is not {FrameworkConstants.FrameworkIdentifiers.NetStandard}"); return(true); } } _generations = Generations.Load(GenerationDefinitionsFile, UseNetPlatform); Dictionary <string, string> candidateRefs = CandidateReferences.ToDictionary(r => r.GetMetadata("FileName"), r => r.GetMetadata("FullPath")); Version idealGeneration = _generations.DetermineGenerationFromSeeds(AssemblyName, assemblyVersion, Log) ?? new Version(0, 0, 0, 0); if (idealGeneration > fx.Version) { Log.LogError($"Assembly {AssemblyName}, Version={assemblyVersion} is generation {idealGeneration} based on the seed data in {GenerationDefinitionsFile} which is greater than project generation {fx.Version}."); } HashSet <string> ignoredRefs = null; if (IgnoredReferences != null) { ignoredRefs = new HashSet <string>(IgnoredReferences.Select(ir => ir.ItemSpec), StringComparer.OrdinalIgnoreCase); } Version defaultGeneration = UseNetPlatform ? FrameworkConstants.CommonFrameworks.DotNet.Version : FrameworkConstants.CommonFrameworks.NetStandard.Version; foreach (var reference in DirectReferences) { string path = reference.GetMetadata("FullPath"); // workaround issue where portable targeting pack design time facades // include dangling refs and refs to higher versions of contracts than // exist in the targeting pack. if (path.IndexOf(".NETPortable", StringComparison.OrdinalIgnoreCase) != -1 && designTimeFacades.Contains(Path.GetFileNameWithoutExtension(path))) { continue; } if (ignoredRefs != null && ignoredRefs.Contains(Path.GetFileNameWithoutExtension(path))) { continue; } if (!File.Exists(path)) { Log.LogError($"Reference {path} does not exist."); continue; } var dependencyGeneration = _generations.DetermineGenerationFromFile(path, Log, candidateRefs: candidateRefs, ignoredRefs: ignoredRefs) ?? defaultGeneration; if (dependencyGeneration > fx.Version) { Log.LogError($"Dependency {path} is generation {dependencyGeneration} which is greater than project generation {fx.Version}."); } if (dependencyGeneration > idealGeneration) { idealGeneration = dependencyGeneration; } } if (fx.Version > idealGeneration) { Log.LogMessage(LogImportance.Low, $"Generation {fx.Version} is higher than the ideal miniumum {idealGeneration}."); } return(!Log.HasLoggedErrors); }