The case just shows how to developers added (in parallel) the same method in two different locations. SemanticMerge is able to detect the situation and include only one of the two, while a regular merge tool would incorrectly add the two.
This is a typical cleanup scenario: you just go to ‘code cleanup’ in ReSharper and get some methods rearranged. Then later someone else, concurrently, modifies a methods on its ‘original’ location. Regular merge tools would have a really bad time merging this… But Semantic can merge automatically since it ‘understands’ the code structure.
Splitting in subclasses is a rich scenario involving complex modifications.
The scenario starts with a single ‘socket’ class that will be split into two: ClientSocket and ServerSocket plus the old ‘Socket’ being renamed to ‘DNS’.
Understanding the scenario is not hard for a programmer, but a text-based mergetool will turn the merge into a real pain.
ReSharper can easily perform the refactor in a few clicks. We will simulate two developes working in parallel, one creating the ClientSocket while the second creates the ServerSocket. Then the code will be merged by Semantic.
Jump to demo mode and go step by step refactoring the code with ReSharper, showing how to developers make the changes in parallel (simulated). Note: need to decide the version control. Git would be fine. Plastic can do too.
The goal is to show how Semantic can seamlessly merge the refactor created by ReSharper
This case will continue where the ‘split class in subclasses’ left. What if now the developers move a method to two different subclasses and also modify it?
Demo: Perform the refactor (move methods) with ReSharper Merge with Semantic
No fear refactoring in the DVCS age
ReSharper + SemanticMerge
pablo santos @psluaces
• Introduce SemanticMerge
• Walk through different refactor and merge cases using ReSharper +
• It is refactor-aware and programming language-
• Handles merging at the structure level and not
• It means:
• It first parses the code – creates intermediate trees.
• Then calculates diff pairs: base-src, base-dst.
• Then looks for conflicts between pairs.
• Enabling eXtreme Refactoring was always the goal :-)
• It is a 3-way merge tool (handles src, dst and base).
I guess you all know by now ;-)
3-way merge - reminder
2 5 6
Can be used with any version control
• And Plastic SCM
(Free trial available and very affordable)
Case0 –What a conventional 3-way merge tool
• No conflict!
• And two methods!!
Case0 –What will a conventional 3-way merge
• No conflict!
• And two methods!!
• It simply finds two blocks of text being
added … Doesn’t care about the code
Case0 –What SemanticMerge does
• It *knows* about the methods so…
Case 1 – Cleaned up code
• Typical case where an Open Source contributor “helps” rearranging a
class with ReSharper.
• While another contributor was making changes in the original file.
• Merge will be a nightmare… :-)
Case 4 – Code format changes
Semantic is able to discard the changes made on source (method call in
multiple lines) and automatically accept the new param instead of raising
a conflict resolution
Case 5 – Move/delete conflict
• What happens if you move a method inside a class
• That is deleted on a different branch?
• How the merge deals with this scenario?
Detect conflicts that regular tools can’t
• What if the same method is modified concurrently at different lines?
• Semantic detects the case and can force the conflict resolution to be
manual – a regular text based merge tool can’t do that because it doesn’t have the context
1) It helps simplifying the mergesTODAY
2) But more importantly it enables new
scenarios that you’re not doing today: clean
up the code, move methods, split classes…
and just be able to merge it back.
Creating a tree-like view of the code
namespace Sample [4-26]
int Add(int a, int b) [8-12]
int Mul(int a, int b) [14-18]
int Subst(int a, int b) [20-24]
using System 
using System.Text 
class Math [6-25]
source tree destination tree
src-base diffs dst-base diffs
source ops to apply
Some complex cases – cyclic move
namespace Testnamespace Test
class DNSclass Utils
Evil twin namespace Test
method Send method Send
Two methods with exactly the same
signature can’t be added on the same
location -> conflict