public GenericPropagationTheorem(MathIdentifier id, MathIdentifier providedPropertyId, ImpliesProperty impliesProperty, BuildProperty buildProperty) { this.id = id; this.providedPropertyId = providedPropertyId; this.impliesProperty = impliesProperty; this.buildProperty = buildProperty; }
public void TestClone1() { bp = new BuildProperty("name", "value"); bp.Clone(false); }
public void TestCtor3() { bp = new BuildProperty("name", null); }
public void TestCtor2() { bp = new BuildProperty(null, "value"); }
public void TestToString() { bp = new BuildProperty("name", "a;b"); Assert.AreEqual("a;b", bp.ToString()); }
public void TestOpExplicit2() { BuildProperty bp = null; Assert.AreEqual(String.Empty, (string)bp, "A1"); }
public void TestOpExplicit1() { bp = new BuildProperty("name", "value"); Assert.AreEqual("value", (string)bp, "A1"); }
private static void HandleServiceBuildPropertyNameMapping(YamlMappingNode yamlMappingNode, BuildProperty buildProperty) { foreach (var child in yamlMappingNode !.Children) { var key = YamlParser.GetScalarValue(child.Key); switch (key) { case "name": buildProperty.Name = YamlParser.GetScalarValue(key, child.Value); break; case "value": buildProperty.Value = YamlParser.GetScalarValue(key, child.Value); break; default: throw new TyeYamlException(child.Key.Start, CoreStrings.FormatUnrecognizedKey(key)); } } }
/// <summary> /// Builds the index. /// </summary> /// <param name="rebuild">if set to <c>true</c> [rebuild].</param> public override void BuildIndex(bool rebuild) { OnEvent(String.Format("CatalogIndexBuilder Started"), 0); IndexBuilder indexer = this.Indexer; DateTime lastBuild = DateTime.MinValue; // Parameters used to restart build from the previous error //string restartCatalogName = String.Empty; //int restartRecordKey = 0; // On complete rebuild no need to check date if (!rebuild) { lastBuild = indexer.GetBuildConfig().LastBuildDate; } ICatalogSystem system = CatalogContext.Current; // Get catalog lists CatalogDto catalogs = system.GetCatalogDto(); double percentage = 0; bool incremental = false; int allRecords = 0; int allCurrentRecord = 0; int allRecordsCount = GetTotalRecords(); int catalogCount = 1; // If date is set, we do incremental rebuild if (lastBuild != DateTime.MinValue) { incremental = true; } // remove deleted items first if (incremental) { int startingRecord = 0; int totalRemoved = 0; while (true) { int count = 0; LogDto dto = LogManager.GetAppLog("catalog", DataRowState.Deleted.ToString(), "entry", lastBuild.ToUniversalTime(), startingRecord, 100, ref count); // add up to a total number to calculate percentage correctly if (startingRecord == 0) { allRecordsCount += count; } if (count <= 0) { break; } foreach (LogDto.ApplicationLogRow row in dto.ApplicationLog) { allCurrentRecord++; if (allCurrentRecord % 20 == 0) { percentage = ((double)allCurrentRecord / (double)allRecordsCount) * 100; OnEvent(String.Format("Removing old entry from index ({1}/{2}) ...", allCurrentRecord, count), percentage); } totalRemoved += indexer.DeleteContent("_id", row.ObjectKey); } startingRecord += 100; } percentage = ((double)allCurrentRecord / (double)allRecordsCount) * 100; OnEvent(String.Format("CatalogIndexBuilder Removed {0} records.", totalRemoved), percentage); } // Index new or updated items foreach (CatalogDto.CatalogRow catalog in catalogs.Catalog) { string catalogName = catalog.Name; string defaultCurrency = catalog.DefaultCurrency; OnEvent(String.Format("Indexing {0} catalog ...", catalogName), percentage); int currentRecord = 0; int startingRecord = 0; int totalIndexed = 0; int lastRecordKey = 0; catalogCount++; while (true) { // Get Catalog Nodes CatalogSearchParameters pars = new CatalogSearchParameters(); CatalogSearchOptions options = new CatalogSearchOptions(); options.CacheResults = false; pars.CatalogNames.Add(catalogName); options.RecordsToRetrieve = 100; options.StartingRecord = startingRecord; if (incremental) { pars.SqlMetaWhereClause = String.Format("META.Modified > '{0}'", lastBuild.ToUniversalTime().ToString("s")); } int count = 0; CatalogEntryDto entryDto = CatalogContext.Current.FindItemsDto(pars, options, ref count, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull)); if (count <= 0) { break; } startingRecord += options.RecordsToRetrieve; List <string> languages = new List <string>(); languages.Add(catalog.DefaultLanguage); foreach (CatalogDto.CatalogLanguageRow row in catalog.GetCatalogLanguageRows()) { languages.Add(row.LanguageCode); } foreach (CatalogEntryDto.CatalogEntryRow row in entryDto.CatalogEntry) { currentRecord++; allCurrentRecord++; // Do not index non active entries if (!row.IsActive) { continue; } // In case of incremental, check if item already exists and delete it if (incremental) { indexer.DeleteContent("_id", row.CatalogEntryId.ToString()); } try { lastRecordKey = row.CatalogEntryId; totalIndexed += IndexCatalogEntryDto(indexer, row, defaultCurrency, languages.ToArray()); } catch (Exception) { percentage = ((double)allCurrentRecord / (double)allRecordsCount) * 100; OnEvent(String.Format("Failed to index catalog entry {0}({1}) in {2}.", row.Name, row.CatalogEntryId, catalogName), percentage); throw; } if (allCurrentRecord % 20 == 0) { percentage = ((double)allCurrentRecord / (double)allRecordsCount) * 100; OnEvent(String.Format("Indexing {0} catalog entries ({1}/{2}) ...", catalogName, allCurrentRecord, allRecordsCount), percentage); } } // Save index every 500 records if (allCurrentRecord % 500 == 0) { percentage = ((double)allCurrentRecord / (double)allRecordsCount) * 100; OnEvent(String.Format("Saving {0} catalog index file.", catalogName), percentage); Build config = indexer.GetBuildConfig(); // Preserve the information needed to restart the indexing on the exact same location as before BuildProperty prop1 = new BuildProperty(); prop1.name = "StartingRecord"; prop1.value = startingRecord.ToString(); BuildProperty prop2 = new BuildProperty(); prop2.name = "LastRecordKey"; prop2.value = lastRecordKey.ToString(); BuildProperty prop3 = new BuildProperty(); prop3.name = "CatalogName"; prop3.value = catalogName; config.Properties = new BuildProperty[] { prop1, prop2, prop3 }; indexer.SaveBuild(Status.Started); indexer.Close(); } if (startingRecord > count) { break; } } percentage = ((double)allCurrentRecord / (double)allRecordsCount) * 100; catalogCount++; allRecords += totalIndexed; } OnEvent(String.Format("CatalogIndexBuilder Indexed {0} language records in {1} catalog(s)", allRecords.ToString(), (catalogCount - 1).ToString()), 99); OnEvent(String.Format("CatalogIndexBuilder Finished"), 100); }
public static string op_Explicit(BuildProperty propertyToCast) { }
public void TestCustomSerialization() { string projectFileName = "ProjectFileName"; string[] targetNames = new string[] { "Build" }; BuildPropertyGroup globalProperties = null; string toolsVersion = "Tool35"; int requestId = 1; int handleId = 4; globalProperties = new BuildPropertyGroup(); BuildProperty propertyToAdd = new BuildProperty("PropertyName", "Value"); globalProperties.SetProperty(propertyToAdd); BuildRequest request1 = new BuildRequest(handleId, projectFileName, targetNames, globalProperties, toolsVersion, requestId, true, true); request1.ParentBuildEventContext = new BuildEventContext(1, 2, 3, 4); BuildRequest request2 = new BuildRequest(handleId, projectFileName, null, globalProperties, toolsVersion, requestId, true, true); request2.GlobalProperties = null; request2.ProjectFileName = null; request2.DefaultTargets = null; request2.InitialTargets = null; request2.UseResultsCache = false; request2.ParentBuildEventContext = null; MemoryStream stream = new MemoryStream(); BinaryWriter writer = new BinaryWriter(stream); BinaryReader reader = new BinaryReader(stream); try { stream.Position = 0; request1.WriteToStream(writer); long streamWriteEndPosition = stream.Position; request2.WriteToStream(writer); long streamWriteEndPosition2 = stream.Position; stream.Position = 0; BuildRequest request3 = BuildRequest.CreateFromStream(reader); long streamReadEndPosition = stream.Position; Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream end positions should be equal"); Assert.IsTrue(request1.HandleId == request3.HandleId, "Expected HandleId to Match"); Assert.IsTrue(request1.RequestId == request3.RequestId, "Expected Request to Match"); Assert.IsTrue(string.Compare(request1.ProjectFileName, request3.ProjectFileName, StringComparison.OrdinalIgnoreCase) == 0, "Expected ProjectFileName to Match"); Assert.IsTrue(string.Compare(targetNames[0], request3.TargetNames[0], StringComparison.OrdinalIgnoreCase) == 0, "Expected TargetNames to Match"); Assert.IsTrue(string.Compare(toolsVersion, request3.ToolsetVersion, StringComparison.OrdinalIgnoreCase) == 0, "Expected ToolsetVersion to Match"); Assert.IsTrue(request3.TargetNames.Length == 1, "Expected there to be one TargetName"); Assert.IsTrue(request3.UnloadProjectsOnCompletion, "Expected UnloadProjectsOnCompletion to be true"); Assert.IsTrue(request3.UseResultsCache, "Expected UseResultsCache to be true"); Assert.IsTrue(string.Compare(request3.GlobalProperties["PropertyName"].Value, "Value", StringComparison.OrdinalIgnoreCase) == 0); Assert.AreEqual(request1.ParentBuildEventContext, request3.ParentBuildEventContext, "Expected BuildEventContext to Match"); BuildRequest request4 = BuildRequest.CreateFromStream(reader); streamReadEndPosition = stream.Position; Assert.IsTrue(streamWriteEndPosition2 == streamReadEndPosition, "Stream end positions should be equal"); Assert.IsTrue(request2.HandleId == request4.HandleId, "Expected HandleId to Match"); Assert.IsTrue(request2.RequestId == request4.RequestId, "Expected Request to Match"); Assert.IsNull(request4.ProjectFileName); Assert.IsNull(request4.TargetNames); Assert.IsNull(request4.GlobalProperties); Assert.IsNull(request4.ParentBuildEventContext); } finally { reader.Close(); writer = null; stream = null; } }
/// <summary> /// This code demonstrates the use of the following methods: /// Engine constructor /// Project constructor /// Project.LoadFromXml /// Project.Xml /// BuildPropertyGroupCollection.GetEnumerator /// BuildPropertyGroup.GetEnumerator /// BuildProperty.Name (get) /// BuildProperty.Value (set) /// BuildPropertyGroup.RemoveProperty /// BuildPropertyGroup.AddNewProperty /// </summary> static void Main() { // Create a new Engine object. Engine engine = new Engine(Environment.CurrentDirectory); // Create a new Project object. Project project = new Project(engine); // Load the project with the following XML, which contains // two PropertyGroups. project.LoadXml(@" <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'> <PropertyGroup> <Optimize>true</Optimize> <WarningLevel>4</WarningLevel> </PropertyGroup> <PropertyGroup> <OutputPath>bin\debug\</OutputPath> <RemoveThisPropertyPlease>1</RemoveThisPropertyPlease> </PropertyGroup> </Project> "); // Iterate through each PropertyGroup in the Project. There are two. foreach (BuildPropertyGroup pg in project.PropertyGroups) { BuildProperty propertyToRemove = null; // Iterate through each Property in the PropertyGroup. foreach (BuildProperty property in pg) { // If the property's name is "RemoveThisPropertyPlease", then // store a reference to this property in a local variable, // so we can remove it later. if (property.Name == "RemoveThisPropertyPlease") { propertyToRemove = property; } // If the property's name is "OutputPath", change its value // from "bin\debug\" to "bin\release\". if (property.Name == "OutputPath") { property.Value = @"bin\release\"; } } // Remove the property named "RemoveThisPropertyPlease" from the // PropertyGroup if (propertyToRemove != null) { pg.RemoveProperty(propertyToRemove); } // For each PropertyGroup that we found, add to the end of it // a new property called "MyNewProperty". pg.AddNewProperty("MyNewProperty", "MyNewValue"); } // The project now looks like this: // // <?xml version="1.0" encoding="utf-16"?> // <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> // <PropertyGroup> // <Optimize>true</Optimize> // <WarningLevel>4</WarningLevel> // <MyNewProperty>MyNewValue</MyNewProperty> // </PropertyGroup> // <PropertyGroup> // <OutputPath>bin\release</OutputPath> // <MyNewProperty>MyNewValue</MyNewProperty> // </PropertyGroup> // </Project> Console.WriteLine(project.Xml); }
public void RemoveProperty(BuildProperty property) {}
public GenericPropagationTheorem(MathIdentifier id, MathIdentifier providedPropertyId, ImpliesProperty impliesProperty, BuildProperty buildProperty) { this.id = id; this.providedPropertyId = providedPropertyId; this.impliesProperty = impliesProperty; this.buildProperty = buildProperty; }
public void TestClone2() { bp = new BuildProperty("name", "value"); bp.Clone(true); }
public void TestCondition2() { BuildProperty a = new BuildProperty("name", "value"); a.Condition = "true"; }
public static string op_Explicit(BuildProperty propertyToCast) {}
public void TestItemsInandOutOfSharedMemory() { string name = Guid.NewGuid().ToString(); // Create the shared memory buffer SharedMemory readSharedMemory = new SharedMemory ( name, SharedMemoryType.ReadOnly, true ); SharedMemory writeSharedMemory = new SharedMemory ( name, SharedMemoryType.WriteOnly, true ); DualQueue <LocalCallDescriptor> queue = new DualQueue <LocalCallDescriptor>(); DualQueue <LocalCallDescriptor> hiPriQueue = new DualQueue <LocalCallDescriptor>(); LocalCallDescriptorForPostLoggingMessagesToHost LargeLogEvent = CreatePostMessageCallDescriptor(1); LocalCallDescriptorForUpdateNodeSettings updateNodeSettings = new LocalCallDescriptorForUpdateNodeSettings(true, true, true); LocalCallDescriptorForPostBuildResult buildResult = new LocalCallDescriptorForPostBuildResult(CreateBuildResult()); LocalCallDescriptorForPostBuildRequests buildRequests = new LocalCallDescriptorForPostBuildRequests(CreateBuildRequest()); LocalCallDescriptorForRequestStatus requestStatus = new LocalCallDescriptorForRequestStatus(4); LocalCallDescriptorForPostStatus nodeStatusNoExcept = new LocalCallDescriptorForPostStatus(new NodeStatus(1, true, 2, 3, 4, true)); LocalCallDescriptorForPostStatus nodeStatusExcept = new LocalCallDescriptorForPostStatus(new NodeStatus(new Exception("I am bad"))); LocalCallDescriptorForShutdownNode shutdownNode = new LocalCallDescriptorForShutdownNode(Node.NodeShutdownLevel.BuildCompleteSuccess, true); LocalCallDescriptorForShutdownComplete shutdownComplete = new LocalCallDescriptorForShutdownComplete(Node.NodeShutdownLevel.BuildCompleteFailure, 0); LocalCallDescriptorForInitializationComplete initializeComplete = new LocalCallDescriptorForInitializationComplete(99); BuildPropertyGroup propertyGroup = new BuildPropertyGroup(); BuildProperty propertyToAdd = new BuildProperty("PropertyName", "Value"); propertyGroup.SetProperty(propertyToAdd); CacheEntry[] entries = CreateCacheEntries(); LocalCallDescriptorForGettingCacheEntriesFromHost getCacheEntries = new LocalCallDescriptorForGettingCacheEntriesFromHost(new string[] { "Hi", "Hello" }, "Name", propertyGroup, "3.5", CacheContentType.Properties); LocalCallDescriptorForPostingCacheEntriesToHost postCacheEntries = new LocalCallDescriptorForPostingCacheEntriesToHost(entries, "ScopeName", propertyGroup, "3.5", CacheContentType.BuildResults); LocalReplyCallDescriptor replyDescriptor1 = new LocalReplyCallDescriptor(1, entries); LocalReplyCallDescriptor replyDescriptor2 = new LocalReplyCallDescriptor(6, "Foo"); IDictionary environmentVariables = Environment.GetEnvironmentVariables(); Hashtable environmentVariablesHashtable = new Hashtable(environmentVariables); string className = "Class"; string loggerAssemblyName = "Class"; string loggerFileAssembly = null; string loggerSwitchParameters = "Class"; LoggerVerbosity verbosity = LoggerVerbosity.Detailed; LoggerDescription description = new LoggerDescription(className, loggerAssemblyName, loggerFileAssembly, loggerSwitchParameters, verbosity); LocalCallDescriptorForInitializeNode initializeNode = new LocalCallDescriptorForInitializeNode(environmentVariablesHashtable, new LoggerDescription[] { description }, 4, propertyGroup, ToolsetDefinitionLocations.ConfigurationFile, 5, String.Empty); queue.Enqueue(LargeLogEvent); queue.Enqueue(updateNodeSettings); queue.Enqueue(buildResult); queue.Enqueue(buildRequests); queue.Enqueue(requestStatus); queue.Enqueue(nodeStatusNoExcept); queue.Enqueue(nodeStatusExcept); queue.Enqueue(shutdownNode); queue.Enqueue(shutdownComplete); queue.Enqueue(initializeComplete); queue.Enqueue(getCacheEntries); queue.Enqueue(postCacheEntries); queue.Enqueue(replyDescriptor1); queue.Enqueue(replyDescriptor2); queue.Enqueue(initializeNode); writeSharedMemory.Write(queue, hiPriQueue, false); IList localCallDescriptorList = readSharedMemory.Read(); Assert.IsTrue(localCallDescriptorList.Count == 15); LocalCallDescriptorForPostLoggingMessagesToHost messageCallDescriptor = localCallDescriptorList[0] as LocalCallDescriptorForPostLoggingMessagesToHost; VerifyPostMessagesToHost(messageCallDescriptor, 1); LocalCallDescriptorForUpdateNodeSettings updateSettingsCallDescriptor = localCallDescriptorList[1] as LocalCallDescriptorForUpdateNodeSettings; VerifyUpdateSettings(updateSettingsCallDescriptor); LocalCallDescriptorForPostBuildResult buildResultCallDescriptor = localCallDescriptorList[2] as LocalCallDescriptorForPostBuildResult; CompareBuildResult(buildResultCallDescriptor); LocalCallDescriptorForPostBuildRequests buildRequestsCallDescriptor = localCallDescriptorList[3] as LocalCallDescriptorForPostBuildRequests; ComparebuildRequests(buildRequestsCallDescriptor); LocalCallDescriptorForRequestStatus requestStatusCallDescriptor = localCallDescriptorList[4] as LocalCallDescriptorForRequestStatus; Assert.IsTrue(requestStatusCallDescriptor.RequestId == 4); LocalCallDescriptorForPostStatus nodeStatus1CallDescriptor = localCallDescriptorList[5] as LocalCallDescriptorForPostStatus; VerifyNodeStatus1(nodeStatus1CallDescriptor); LocalCallDescriptorForPostStatus nodeStatus2CallDescriptor = localCallDescriptorList[6] as LocalCallDescriptorForPostStatus; VerifyNodeStatus2(nodeStatus2CallDescriptor); LocalCallDescriptorForShutdownNode shutdownNodeCallDescriptor = localCallDescriptorList[7] as LocalCallDescriptorForShutdownNode; Assert.IsTrue(shutdownNodeCallDescriptor.ShutdownLevel == Node.NodeShutdownLevel.BuildCompleteSuccess); Assert.IsTrue(shutdownNodeCallDescriptor.ExitProcess); LocalCallDescriptorForShutdownComplete shutdownNodeCompleteCallDescriptor = localCallDescriptorList[8] as LocalCallDescriptorForShutdownComplete; Assert.IsTrue(shutdownNodeCompleteCallDescriptor.ShutdownLevel == Node.NodeShutdownLevel.BuildCompleteFailure); LocalCallDescriptorForInitializationComplete initializeCompleteCallDescriptor = localCallDescriptorList[9] as LocalCallDescriptorForInitializationComplete; Assert.IsTrue(initializeCompleteCallDescriptor.ProcessId == 99); LocalCallDescriptorForGettingCacheEntriesFromHost getCacheEntriesCallDescriptor = localCallDescriptorList[10] as LocalCallDescriptorForGettingCacheEntriesFromHost; VerifyGetCacheEntryFromHost(getCacheEntriesCallDescriptor); LocalCallDescriptorForPostingCacheEntriesToHost postCacheEntriesCallDescriptor = localCallDescriptorList[11] as LocalCallDescriptorForPostingCacheEntriesToHost; Assert.IsTrue(string.Compare(postCacheEntriesCallDescriptor.ScopeName, "ScopeName", StringComparison.OrdinalIgnoreCase) == 0); Assert.IsTrue(string.Compare(postCacheEntriesCallDescriptor.ScopeProperties["PropertyName"].Value, "Value", StringComparison.OrdinalIgnoreCase) == 0); Assert.IsTrue(string.Compare(postCacheEntriesCallDescriptor.ScopeToolsVersion, "3.5", StringComparison.OrdinalIgnoreCase) == 0); Assert.IsTrue(postCacheEntriesCallDescriptor.ContentType == CacheContentType.BuildResults); VerifyGetCacheEntries(postCacheEntriesCallDescriptor.Entries); LocalReplyCallDescriptor reply1CallDescriptor = localCallDescriptorList[12] as LocalReplyCallDescriptor; Assert.IsTrue(reply1CallDescriptor.RequestingCallNumber == 1); VerifyGetCacheEntries((CacheEntry[])reply1CallDescriptor.ReplyData); LocalReplyCallDescriptor reply2CallDescriptor = localCallDescriptorList[13] as LocalReplyCallDescriptor; Assert.IsTrue(reply2CallDescriptor.RequestingCallNumber == 6); Assert.IsTrue(string.Compare("Foo", (string)reply2CallDescriptor.ReplyData, StringComparison.OrdinalIgnoreCase) == 0); LocalCallDescriptorForInitializeNode initializeCallDescriptor = localCallDescriptorList[14] as LocalCallDescriptorForInitializeNode; Assert.IsTrue(initializeCallDescriptor.ParentProcessId == 5); Assert.IsTrue(initializeCallDescriptor.NodeId == 4); Assert.IsTrue(initializeCallDescriptor.ToolsetSearchLocations == ToolsetDefinitionLocations.ConfigurationFile); Assert.IsTrue(string.Compare(initializeCallDescriptor.ParentGlobalProperties["PropertyName"].Value, "Value", StringComparison.OrdinalIgnoreCase) == 0); Assert.IsTrue(string.Compare(initializeCallDescriptor.NodeLoggers[0].Name, "Class", StringComparison.OrdinalIgnoreCase) == 0); IDictionary variables = Environment.GetEnvironmentVariables(); Assert.IsTrue(variables.Count == initializeCallDescriptor.EnvironmentVariables.Count); foreach (string key in variables.Keys) { Assert.IsTrue(string.Compare((string)initializeCallDescriptor.EnvironmentVariables[key], (string)variables[key], StringComparison.OrdinalIgnoreCase) == 0); } writeSharedMemory.Reset(); readSharedMemory.Reset(); readSharedMemory = null; writeSharedMemory = null; }