/// <summary> /// Resets criteria to original state (default custom criteria, common criteria initialized with default values) /// </summary> public void ResetCriteria() { CustomLocalizabilityCriteria.Clear(); // merge CSharpStringResultItem and AspNetStringResultItem criteria CommonLocalizabilityCriteria = CSharpStringResultItem.GetCriteria(); var aspnetMembers = AspNetStringResultItem.GetCriteria(); foreach (var pair in aspnetMembers) { if (!CommonLocalizabilityCriteria.ContainsKey(pair.Key)) { CommonLocalizabilityCriteria.Add(pair.Key, pair.Value); } } }
/// <summary> /// Initializes "batch move to resources" tool window and grid /// </summary> /// <param name="resxItems">List of possible destination items</param> /// <param name="items">Result items</param> /// <param name="fullName">True if "use full name" policy should be applied</param> /// <param name="mark">True if "mark with VL_NO_LOC" policy should be applied</param> /// <param name="resxCounts">Number of resources determined to be moved to each ResX file</param> /// <param name="sourceItemCounts">Number of resource items for each source code file</param> /// <param name="expectedToBeMarked">Number of resources that are expected to be marked with VL_NO_LOC</param> /// <returns></returns> private BatchMoveToResourcesToolWindow_Accessor InitBatchToolWindow(List <ResXProjectItem> resxItems, List <CodeStringResultItem> items, bool fullName, bool mark, out Dictionary <ResXProjectItem, int> resxCounts, out Dictionary <ProjectItem, int> sourceItemCounts, out int expectedToBeMarked) { DTE2 dte = Agent.GetDTE(); expectedToBeMarked = 0; sourceItemCounts = new Dictionary <ProjectItem, int>(); // init window BatchMoveToResourcesToolWindow_Accessor window = new BatchMoveToResourcesToolWindow_Accessor(new PrivateObject(new BatchMoveToResourcesToolWindow())); window.SetData(items); // init the policies window.currentNamespacePolicy = window.NAMESPACE_POLICY_ITEMS[fullName ? 1 : 0]; window.currentRememberOption = window.REMEMBER_OPTIONS[mark ? 1 : 0]; BatchMoveToResourcesToolGrid grid = ((BatchMoveToResourcesToolGrid)window.panel.ToolGrid.Target); int x = 0; Random rnd = new Random(); resxCounts = new Dictionary <ResXProjectItem, int>(); // check/uncheck random rows foreach (DataGridViewKeyValueRow <CodeStringResultItem> row in grid.Rows) { bool check = rnd.Next(2) == 0; if (check) { // set unique key row.Cells[grid.KeyColumnName].Value = string.Format("xx{0}", x); // select random destination item ResXProjectItem destResX = resxItems[rnd.Next(resxItems.Count)]; row.Cells[grid.DestinationColumnName].Value = destResX.ToString(); if (!resxCounts.ContainsKey(destResX)) { resxCounts.Add(destResX, 0); } resxCounts[destResX]++; if (!sourceItemCounts.ContainsKey(row.DataSourceItem.SourceItem)) { sourceItemCounts.Add(row.DataSourceItem.SourceItem, 0); } sourceItemCounts[row.DataSourceItem.SourceItem]++; } else { AspNetStringResultItem aitem = row.DataSourceItem as AspNetStringResultItem; if (((row.DataSourceItem is CSharpStringResultItem) || (aitem != null && aitem.ComesFromCodeBlock && aitem.Language == LANGUAGE.CSHARP))) { if (mark && !row.DataSourceItem.IsMarkedWithUnlocalizableComment) { if (!sourceItemCounts.ContainsKey(row.DataSourceItem.SourceItem)) { sourceItemCounts.Add(row.DataSourceItem.SourceItem, 0); } sourceItemCounts[row.DataSourceItem.SourceItem]++; } expectedToBeMarked++; } } row.Cells[grid.CheckBoxColumnName].Value = check; window.panel.ToolGrid.Validate(row); if (check) { Assert.IsTrue(string.IsNullOrEmpty(row.ErrorText), row.ErrorText); } x++; } // randomly sort the grid grid.Sort(grid.Columns[rnd.Next(grid.Columns.Count)], rnd.Next(2) == 0 ? System.ComponentModel.ListSortDirection.Ascending : System.ComponentModel.ListSortDirection.Descending); return(window); }
/// <summary> /// Returns target property's value /// </summary> /// <param name="resultItem">Result item from which the value is taken</param> /// <param name="relevant">OUT - true if the target is relevant for the result item</param> private string GetTarget(CodeStringResultItem resultItem, out bool relevant) { string testString = null; NetStringResultItem cResItem = resultItem as NetStringResultItem; AspNetStringResultItem aResItem = resultItem as AspNetStringResultItem; relevant = false; switch (Target) { case LocalizationCriterionTarget.VALUE: relevant = true; testString = resultItem.Value; break; case LocalizationCriterionTarget.NAMESPACE_NAME: if (cResItem == null) { return(null); // ASP .NET result items don't have namespaces } try { CodeNamespace nmspc = cResItem.NamespaceElement; if (nmspc != null) { testString = nmspc.FullName; } relevant = true; } catch (COMException) { } break; case LocalizationCriterionTarget.METHOD_NAME: if (cResItem == null) { return(null); // ASP .NET result items don't have methods } relevant = true; testString = cResItem.MethodElementName; break; case LocalizationCriterionTarget.CLASS_NAME: if (cResItem == null) { return(null); // ASP .NET result items don't have classes } relevant = true; testString = cResItem.ClassOrStructElementName; break; case LocalizationCriterionTarget.ELEMENT_NAME: if (aResItem == null) { return(null); // C# or VB result items don't have element names } if (aResItem.ComesFromDirective || aResItem.ComesFromElement || aResItem.ComesFromPlainText) { relevant = true; testString = aResItem.ElementName; } else { return(null); } break; case LocalizationCriterionTarget.ELEMENT_PREFIX: if (aResItem == null) { return(null); // C# or VB result items don't have element prefixes } if (aResItem.ComesFromDirective || aResItem.ComesFromElement || aResItem.ComesFromPlainText) { relevant = true; testString = aResItem.ElementPrefix; } else { return(null); } break; case LocalizationCriterionTarget.VARIABLE_NAME: if (cResItem == null) { return(null); } ; // ASP .NET result items don't initialize variables relevant = true; testString = cResItem.VariableElementName; break; case LocalizationCriterionTarget.ATTRIBUTE_NAME: if (aResItem == null) { return(null); // C# or VB result items don't originate from elements } if (aResItem.ComesFromDirective || aResItem.ComesFromElement) { relevant = true; testString = aResItem.AttributeName; } else { return(null); } break; case LocalizationCriterionTarget.LINE: if (resultItem.Context == null) { return(null); } string[] lines = resultItem.Context.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); if (resultItem.ContextRelativeLine >= 0 && resultItem.ContextRelativeLine < lines.Length) { relevant = true; testString = lines[resultItem.ContextRelativeLine]; } else { return(null); } break; } return(testString); }
public void Move(List <CodeStringResultItem> dataList, ref int errorRows) { // sort according to position dataList.Sort(new ResultItemsPositionCompararer <CodeStringResultItem>()); for (int i = dataList.Count - 1; i >= 0; i--) { try { // initialization of data CodeStringResultItem resultItem = dataList[i]; string path = resultItem.SourceItem.GetFullPath(); ReferenceString referenceText = null; bool addUsingBlock = false; CONTAINS_KEY_RESULT keyConflict = CONTAINS_KEY_RESULT.DOESNT_EXIST; if (resultItem.MoveThisItem) // row was checked in the toolwindow { Validate(resultItem); // check that key, value and destination item was specifed and that row has no errors if (!resultItem.DestinationItem.IsLoaded) { resultItem.DestinationItem.Load(); } if (!loadedResxItems.Contains(resultItem.DestinationItem)) { loadedResxItems.Add(resultItem.DestinationItem); } // check if such item already exists in destination file keyConflict = resultItem.DestinationItem.GetKeyConflictType(resultItem.Key, resultItem.Value, true); if (keyConflict == CONTAINS_KEY_RESULT.EXISTS_WITH_DIFF_VALUE) { throw new InvalidOperationException(string.Format("Key \"{0}\" already exists with different value.", resultItem.Key)); } resultItem.Key = resultItem.DestinationItem.GetRealKey(resultItem.Key); // if key already exists, return its name (solves case-sensitivity problems) NamespacesList usedNamespaces = GetUsedNamespacesFor(resultItem); if (UseFullName || resultItem.MustUseFullName || (resultItem.Language == LANGUAGE.VB && resultItem.DestinationItem.IsProjectDefault(resultItem.SourceItem.ContainingProject))) // reference will contain namespace { referenceText = new ReferenceString(resultItem.DestinationItem.Namespace, resultItem.DestinationItem.Class, resultItem.Key); addUsingBlock = false; // no using block will be added } else { // use resolver whether it is ok to add using block addUsingBlock = usedNamespaces.ResolveNewElement(resultItem.DestinationItem.Namespace, resultItem.DestinationItem.Class, resultItem.Key, resultItem.SourceItem.ContainingProject, out referenceText); } if (addUsingBlock) // new using block will be added { if (!usedNamespacesCache.ContainsKey(resultItem.SourceItem)) { usedNamespacesCache.Add(resultItem.SourceItem, new NamespacesList()); } foreach (var pair in usedNamespacesCache) { if (!pair.Value.ContainsNamespace(resultItem.DestinationItem.Namespace)) { pair.Value.Add(resultItem.DestinationItem.Namespace, null, true); } } } } if (RDTManager.IsFileOpen(path) && RDTManager.IsFileVisible(path)) // file is open { if (resultItem.MoveThisItem || (MarkUncheckedStringsWithComment && !resultItem.IsMarkedWithUnlocalizableComment)) // string literal in text will be modified (referenced or marked with comment) { if (!buffersCache.ContainsKey(path)) { // load file's buffer IVsTextLines textLines = DocumentViewsManager.GetTextLinesForFile(path, false); buffersCache.Add(path, textLines); IOleUndoManager m; // get file's undo manager int hr = textLines.GetUndoManager(out m); Marshal.ThrowExceptionForHR(hr); undoManagersCache.Add(path, m); } } if (resultItem.MoveThisItem) { // perform the text replacement MoveToResource(buffersCache[path], resultItem, referenceText); if (resultItem.IsConst && resultItem.CodeModelSource is CodeVariable2) { CodeVariable2 codeVar = (CodeVariable2)resultItem.CodeModelSource; codeVar.ConstKind = vsCMConstKind.vsCMConstKindNone; } if (addUsingBlock) { // add using block to the source file int beforeLines, afterLines; buffersCache[path].GetLineCount(out beforeLines); resultItem.AddUsingBlock(buffersCache[path]); buffersCache[path].GetLineCount(out afterLines); int diff = afterLines - beforeLines; // because of the previous step, it is necessary to adjust position of all not-yet referenced result items for (int j = i; j >= 0; j--) { var item = dataList[j]; if (item.SourceItem == resultItem.SourceItem) { TextSpan ts = new TextSpan(); ts.iEndIndex = item.ReplaceSpan.iEndIndex; ts.iEndLine = item.ReplaceSpan.iEndLine + diff; ts.iStartIndex = item.ReplaceSpan.iStartIndex; ts.iStartLine = item.ReplaceSpan.iStartLine + diff; item.ReplaceSpan = ts; } } } // previous step (replace and possibly new using block) caused undo unit to be added - remove it int unitsToRemoveCount = (resultItem.IsConst && addUsingBlock ? 3 : (resultItem.IsConst || addUsingBlock ? 2 : 1)); List <IOleUndoUnit> units = undoManagersCache[path].RemoveTopFromUndoStack(unitsToRemoveCount); // and add custom undo unit AbstractUndoUnit newUnit = null; if (keyConflict == CONTAINS_KEY_RESULT.DOESNT_EXIST) { newUnit = new MoveToResourcesUndoUnit(resultItem.Key, resultItem.Value, resultItem.DestinationItem); } else if (keyConflict == CONTAINS_KEY_RESULT.EXISTS_WITH_SAME_VALUE) { newUnit = new MoveToResourcesReferenceUndoUnit(resultItem.Key); } newUnit.AppendUnits.AddRange(units); undoManagersCache[path].Add(newUnit); } else if (MarkUncheckedStringsWithComment && !resultItem.IsMarkedWithUnlocalizableComment) // string literal should be marked with comment { AspNetStringResultItem aitem = resultItem as AspNetStringResultItem; // this operation is only possible if string literal comes from C# code if (resultItem is CSharpStringResultItem || (aitem != null && aitem.ComesFromCodeBlock && aitem.Language == LANGUAGE.CSHARP)) { // add the comment int c = MarkAsNoLoc(buffersCache[path], resultItem); // add undo unit List <IOleUndoUnit> units = undoManagersCache[path].RemoveTopFromUndoStack(1); MarkAsNotLocalizedStringUndoUnit newUnit = new MarkAsNotLocalizedStringUndoUnit(resultItem.Value); newUnit.AppendUnits.AddRange(units); undoManagersCache[path].Add(newUnit); } } } else // file is closed // same as with open file, only operating with text, not buffers { if (resultItem.MoveThisItem || (MarkUncheckedStringsWithComment && !resultItem.IsMarkedWithUnlocalizableComment)) // string literal will be modified // load file's text into the cache { if (!filesCache.ContainsKey(path)) { filesCache.Add(path, new StringBuilder(File.ReadAllText(path))); } } if (resultItem.IsConst && resultItem.CodeModelSource is CodeVariable2) { CodeVariable2 codeVar = (CodeVariable2)resultItem.CodeModelSource; fieldsToRemoveConst.Add(codeVar); } if (resultItem.MoveThisItem) { StringBuilder b = filesCache[path]; // perform the replacement string insertText = resultItem.GetReferenceText(referenceText); b.Remove(resultItem.AbsoluteCharOffset, resultItem.AbsoluteCharLength); b.Insert(resultItem.AbsoluteCharOffset, insertText); if (addUsingBlock) { // add using block if (!newUsingsPlan.ContainsKey(path)) { newUsingsPlan.Add(path, new List <string>()); } newUsingsPlan[path].Add(resultItem.DestinationItem.Namespace); } } else if (MarkUncheckedStringsWithComment && !resultItem.IsMarkedWithUnlocalizableComment) { AspNetStringResultItem aitem = resultItem as AspNetStringResultItem; if (resultItem is CSharpStringResultItem || (aitem != null && aitem.ComesFromCodeBlock && aitem.Language == LANGUAGE.CSHARP)) { StringBuilder b = filesCache[path]; b.Insert(resultItem.AbsoluteCharOffset, resultItem.NoLocalizationComment); } } } if (resultItem.MoveThisItem && keyConflict == CONTAINS_KEY_RESULT.DOESNT_EXIST) { if (!resultItem.DestinationItem.IsInBatchMode) { resultItem.DestinationItem.BeginBatch(); } // add the key to the ResX file resultItem.DestinationItem.AddString(resultItem.Key, resultItem.Value); } } catch (Exception ex) { errorRows++; VLOutputWindow.VisualLocalizerPane.WriteException(ex); } } // add using blocks to closed files texts foreach (var pair in newUsingsPlan) { foreach (string nmspc in pair.Value) { AddUsingBlockTo(pair.Key, nmspc); } } // flush closed files texts foreach (var pair in filesCache) { if (RDTManager.IsFileOpen(pair.Key)) { RDTManager.SetIgnoreFileChanges(pair.Key, true); File.WriteAllText(pair.Key, pair.Value.ToString()); RDTManager.SetIgnoreFileChanges(pair.Key, false); RDTManager.SilentlyReloadFile(pair.Key); } else { File.WriteAllText(pair.Key, pair.Value.ToString()); } } // remove 'const' modifier from fields in closed files HashSet <ProjectItem> itemsToSave = new HashSet <ProjectItem>(); foreach (CodeVariable2 codeVar in fieldsToRemoveConst) { codeVar.ConstKind = vsCMConstKind.vsCMConstKindNone; itemsToSave.Add(codeVar.ProjectItem); } foreach (ProjectItem item in itemsToSave) { item.Save(null); } foreach (ResXProjectItem item in loadedResxItems) { if (item.IsInBatchMode) { item.EndBatch(); } item.Unload(); } if (errorRows > 0) { throw new Exception("Error occured while processing some rows - see Output window for details."); } }
/// <summary> /// Compares expected and actual result item /// </summary> internal static void ValidateItems(AbstractResultItem a, AbstractResultItem b) { if (b is NetStringResultItem) { NetStringResultItem an = a as NetStringResultItem; NetStringResultItem bn = b as NetStringResultItem; Assert.AreEqual(an.VariableElementName, bn.VariableElementName, "Variable names are not equal, " + a.Value); Assert.AreEqual(an.MethodElementName, bn.MethodElementName, "Method names are not equal, " + a.Value); } if (b is CSharpStringResultItem) { TestCSharpStringResultItem an = a as TestCSharpStringResultItem; CSharpStringResultItem bn = b as CSharpStringResultItem; if (an.NamespaceElementName == null) { Assert.IsNull(bn.NamespaceElement, "Namespace null, " + a.Value); } else { Assert.AreEqual(an.NamespaceElementName, bn.NamespaceElement.FullName, "Namespace names are not equal, " + a.Value); } } if (b is VBStringResultItem) { TestVBStringResultItem an = a as TestVBStringResultItem; VBStringResultItem bn = b as VBStringResultItem; if (an.NamespaceElementName == null) { Assert.IsNull(bn.NamespaceElement, "Namespace null, " + a.Value); } else { Assert.AreEqual(an.NamespaceElementName, bn.NamespaceElement.FullName, "Namespace names are not equal, " + a.Value); } } if (b is AspNetStringResultItem) { TestAspNetStringResultItem an = a as TestAspNetStringResultItem; AspNetStringResultItem bn = b as AspNetStringResultItem; Assert.AreEqual(an.ComesFromClientComment, bn.ComesFromClientComment, "ComesFromClientComment are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(an.ComesFromCodeBlock, bn.ComesFromCodeBlock, "ComesFromCodeBlock are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(an.ComesFromDirective, bn.ComesFromDirective, "ComesFromDirective are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(an.ComesFromElement, bn.ComesFromElement, "ComesFromElement are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(an.ComesFromInlineExpression, bn.ComesFromInlineExpression, "ComesFromInlineExpression are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(an.ComesFromPlainText, bn.ComesFromPlainText, "ComesFromPlainText are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(an.ElementName, bn.ElementName, "ElementName are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(an.ElementPrefix, bn.ElementPrefix, "ElementPrefix are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(an.LocalizabilityProved, bn.LocalizabilityProved, "LocalizabilityProved are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(an.Language, bn.Language, "Language are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); } if (b is CodeStringResultItem) { CodeStringResultItem an = a as CodeStringResultItem; CodeStringResultItem bn = b as CodeStringResultItem; Assert.AreEqual(an.WasVerbatim, bn.WasVerbatim, "Verbatim options are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(an.ClassOrStructElementName, bn.ClassOrStructElementName, "Class names are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); } if (b is CodeReferenceResultItem) { CodeReferenceResultItem an = a as CodeReferenceResultItem; CodeReferenceResultItem bn = b as CodeReferenceResultItem; Assert.AreEqual(an.FullReferenceText, bn.FullReferenceText, "FullReferenceText are not equal" + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(an.OriginalReferenceText, bn.OriginalReferenceText, "OriginalReferenceText are not equal" + " on line " + a.ReplaceSpan.iStartLine); } if (b is AspNetCodeReferenceResultItem) { AspNetCodeReferenceResultItem an = a as AspNetCodeReferenceResultItem; AspNetCodeReferenceResultItem bn = b as AspNetCodeReferenceResultItem; Assert.AreEqual(an.ComesFromInlineExpression, bn.ComesFromInlineExpression, "ComesFromInlineExpression are not equal" + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(an.ComesFromWebSiteResourceReference, bn.ComesFromWebSiteResourceReference, "ComesFromWebSiteResourceReference are not equal" + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(an.Language, bn.Language, "Language are not equal" + " on line " + a.ReplaceSpan.iStartLine); if (an.ComesFromInlineExpression) { Assert.IsNotNull(an.InlineReplaceSpan); Assert.IsNotNull(bn.InlineReplaceSpan); Assert.AreEqual(an.InlineReplaceSpan.StartLine, bn.InlineReplaceSpan.StartLine, "StartLine are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(an.InlineReplaceSpan.StartIndex, bn.InlineReplaceSpan.StartIndex, "StartIndex are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(an.InlineReplaceSpan.EndLine, bn.InlineReplaceSpan.EndLine, "EndLine are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(an.InlineReplaceSpan.EndIndex, bn.InlineReplaceSpan.EndIndex, "EndIndex are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(an.InlineReplaceSpan.AbsoluteCharOffset, bn.InlineReplaceSpan.AbsoluteCharOffset, "Offsets are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(an.InlineReplaceSpan.AbsoluteCharLength, bn.InlineReplaceSpan.AbsoluteCharLength, "AbsoluteLengths are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); } else { Assert.IsNull(an.InlineReplaceSpan); Assert.IsNull(bn.InlineReplaceSpan); } } Assert.AreEqual(a.Value, b.Value, "Values are not equal on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(a.SourceItem, b.SourceItem, "Source items are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(a.IsWithinLocalizableFalse, b.IsWithinLocalizableFalse, "[Localizable(false)] options are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(a.IsMarkedWithUnlocalizableComment, b.IsMarkedWithUnlocalizableComment, "/*VL_NO_LOC*/ options are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(a.ComesFromDesignerFile, b.ComesFromDesignerFile, "Designer file options are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.IsNotNull(a.ReplaceSpan); Assert.IsNotNull(b.ReplaceSpan); Assert.AreEqual(a.ReplaceSpan.iStartLine, b.ReplaceSpan.iStartLine, "iStartLine are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(a.ReplaceSpan.iStartIndex, b.ReplaceSpan.iStartIndex, "iStartIndex are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(a.ReplaceSpan.iEndLine, b.ReplaceSpan.iEndLine, "iEndLine are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(a.ReplaceSpan.iEndIndex, b.ReplaceSpan.iEndIndex, "iEndIndex are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(a.AbsoluteCharOffset, b.AbsoluteCharOffset, "Offsets are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(a.AbsoluteCharLength, b.AbsoluteCharLength, "AbsoluteLengths are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine); Assert.AreEqual(a.IsConst, b.IsConst, "IsConst are not equal on line " + a.ReplaceSpan.iStartLine); }