Пример #1
0
        public override List <Change> PerformChanges(RefactoringOptions options, object properties)
        {
            List <Change> changes           = new List <Change>();
            var           textReplaceChange = new TextReplaceChange();

            textReplaceChange.FileName     = context.GetCurrentFilePath();
            textReplaceChange.RemovedChars = 0;
            int num = data.Document.LocationToOffset(insertionPoint.Location);

            textReplaceChange.Offset = num;

            var resolveResult = context.GetResolvedTypeNameResult();

            if (resolveResult == null)
            {
                throw new InvalidOperationException("Cannot generate class here");
            }
            var           nspace         = resolveResult.CallingType.Namespace;
            string        newTypeName    = resolveResult.ResolvedExpression.Expression;
            StringBuilder contentBuilder = new StringBuilder();

            if (insertionPoint.LineBefore == NewLineInsertion.Eol)
            {
                contentBuilder.Append(data.EolMarker);
            }
            contentBuilder.Append(data.EolMarker);
            contentBuilder.Append(data.EolMarker);
            var content = fileFormatResolver.GetNewTypeContent(newTypeName, indent, data.EolMarker);

            contentBuilder.Append(content);
            if (insertionPoint.LineAfter == NewLineInsertion.None)
            {
                contentBuilder.Append(data.EolMarker);
            }
            textReplaceChange.InsertedText = contentBuilder.ToString();

            changes.Add(textReplaceChange);
            return(changes);
        }
Пример #2
0
        public void Returns_the_exact_interface_format()
        {
            string fileFormat = resolver.GetNewTypeContent("IDoSomething", "", eol);

            Assert.AreEqual("public interface IDoSomething {\r\n\t\r\n}", fileFormat);
        }