CCNet.ProjectChecker.Program.CheckWrongReferences C# (CSharp) Метод

CheckWrongReferences() публичный статический Метод

Checks "WrongReferences" condition.
public static CheckWrongReferences ( ) : void
Результат void
		public static void CheckWrongReferences()
		{
			StringBuilder message = new StringBuilder();
			List<string> projects = ProjectHelper.GetProjectReferences();

			if (Arguments.ProjectType != ProjectType.Azure)
			{
				foreach (string project in projects)
				{
					message.AppendLine(
						Strings.DontUseProjectReference
						.Display(project));
				}
			}

			List<Reference> references = ProjectHelper.GetBinaryReferences();
			CheckReferenceProperties(references, message);

			List<ReferenceFile> allExternals = ReferenceFolder.GetAllFiles(Arguments.ExternalReferencesPath);
			List<ReferenceFile> allInternals = ReferenceFolder.GetAllFiles(Arguments.InternalReferencesPath);
			List<ReferenceFile> usedExternals = new List<ReferenceFile>();
			List<ReferenceFile> usedInternals = new List<ReferenceFile>();
			List<Reference> usedGac = new List<Reference>();

			foreach (Reference reference in references)
			{
				ReferenceFile usedExternal = allExternals.Where(file => file.AssemblyName == reference.Name).FirstOrDefault();
				ReferenceFile usedInternal = allInternals.Where(file => file.AssemblyName == reference.Name).FirstOrDefault();

				if (usedExternal != null)
				{
					usedExternals.Add(usedExternal);
				}
				else if (usedInternal != null)
				{
					usedInternals.Add(usedInternal);
				}
				else
				{
					usedGac.Add(reference);
				}
			}

			foreach (string project in projects)
			{
				ReferenceFile usedInternal = allInternals
					.Where(file => file.AssemblyName == Path.GetFileNameWithoutExtension(project))
					.FirstOrDefault();

				if (usedInternal != null)
				{
					usedInternals.Add(usedInternal);
				}
			}

			ReferenceMark.SetupActual(
				ReferenceType.External,
				Arguments.ReferencesDirectory,
				usedExternals.Select(item => item.ProjectName).Distinct());

			ReferenceMark.SetupActual(
				ReferenceType.Internal,
				Arguments.ReferencesDirectory,
				usedInternals.Select(item => item.ProjectName).Distinct());

			List<string> requiredGac = new List<string>();
			List<string> allowedGac = new List<string>();
			allowedGac.Add("envdte");
			allowedGac.Add("envdte80");
			allowedGac.Add("Microsoft.Contracts");
			allowedGac.Add("Microsoft.CSharp");
			allowedGac.Add("Microsoft.JScript");
			allowedGac.Add("Microsoft.mshtml");
			allowedGac.Add("Microsoft.ReportViewer.Common");
			allowedGac.Add("Microsoft.ReportViewer.WebForms");
			allowedGac.Add("Microsoft.Synchronization");
			allowedGac.Add("Microsoft.Synchronization.Data");
			allowedGac.Add("Microsoft.Synchronization.Data.SqlServer");
			allowedGac.Add("Microsoft.VisualBasic");
			allowedGac.Add("Microsoft.VisualBasic.Compatibility.Data");
			allowedGac.Add("Microsoft.VisualStudio.QualityTools.UnitTestFramework");
			allowedGac.Add("PresentationCore");
			allowedGac.Add("PresentationFramework");
			allowedGac.Add("System");
			allowedGac.Add("System.Core");
			allowedGac.Add("System.ComponentModel.DataAnnotations");
			allowedGac.Add("System.Configuration");
			allowedGac.Add("System.configuration");
			allowedGac.Add("System.Configuration.Install");
			allowedGac.Add("System.Data");
			allowedGac.Add("System.Data.DataSetExtensions");
			allowedGac.Add("System.Data.Entity");
			allowedGac.Add("System.Data.Linq");
			allowedGac.Add("System.Data.Services");
			allowedGac.Add("System.Data.Services.Client");
			allowedGac.Add("System.Deployment");
			allowedGac.Add("System.Design");
			allowedGac.Add("System.DirectoryServices");
			allowedGac.Add("System.Drawing");
			allowedGac.Add("System.EnterpriseServices");
			allowedGac.Add("System.IdentityModel");
			allowedGac.Add("System.IdentityModel.Selectors");
			allowedGac.Add("System.Management");
			allowedGac.Add("System.Messaging");
			allowedGac.Add("System.Runtime.Remoting");
			allowedGac.Add("System.Runtime.Serialization");
			allowedGac.Add("System.Runtime.Serialization.Formatters.Soap");
			allowedGac.Add("System.Security");
			allowedGac.Add("System.ServiceModel");
			allowedGac.Add("System.ServiceModel.Web");
			allowedGac.Add("System.ServiceModel.DomainServices.EntityFramework");
			allowedGac.Add("System.ServiceModel.DomainServices.Hosting");
			allowedGac.Add("System.ServiceModel.DomainServices.Server");
			allowedGac.Add("System.ServiceProcess");
			allowedGac.Add("System.Transactions");
			allowedGac.Add("System.Web");
			allowedGac.Add("System.Web.Abstractions");
			allowedGac.Add("System.Web.ApplicationServices");
			allowedGac.Add("System.Web.DynamicData");
			allowedGac.Add("System.Web.Entity");
			allowedGac.Add("System.Web.Extensions");
			allowedGac.Add("System.Web.Extensions.Design");
			allowedGac.Add("System.Web.Helpers");
			allowedGac.Add("System.Web.Mobile");
			allowedGac.Add("System.Web.Routing");
			allowedGac.Add("System.Web.Services");
			allowedGac.Add("System.Web.WebPages");
			allowedGac.Add("System.Windows.Forms");
			allowedGac.Add("System.Xaml");
			allowedGac.Add("System.XML");
			allowedGac.Add("System.Xml");
			allowedGac.Add("System.Xml.Linq");
			allowedGac.Add("UIAutomationClient");
			allowedGac.Add("UIAutomationClientsideProviders");
			allowedGac.Add("UIAutomationProvider");
			allowedGac.Add("UIAutomationTypes");
			allowedGac.Add("WindowsBase");

			string description;
			if (!ValidationHelper.CheckEntries(
				usedGac.Select(reference => reference.Name).ToList(),
				requiredGac,
				allowedGac,
				out description))
			{
				message.Append(description);
			}

			if (message.Length == 0)
				return;

			RaiseError.WrongReferences(message.ToString());
		}