-
Notifications
You must be signed in to change notification settings - Fork 899
Initial change to type-safe Diff.Compare #1180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ public class MetaFixture | |
{ | ||
private static readonly HashSet<Type> explicitOnlyInterfaces = new HashSet<Type> | ||
{ | ||
typeof(IBelongToARepository), | ||
typeof(IBelongToARepository), typeof(IDiffResult), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this for an empty interface? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Otherwise the test will check whether all the public api of the class is the public API contract defined by the interface. Which is empty. So every method will end up being 'extra' and the test will fail. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
}; | ||
|
||
[Fact] | ||
|
@@ -401,6 +401,20 @@ where method.IsDefined(typeof(ExtensionAttribute), false) | |
select method; | ||
return query; | ||
} | ||
|
||
[Fact] | ||
public void AllIDiffResultsAreInChangesBuilder() | ||
{ | ||
var diff = typeof(Diff).GetField("ChangesBuilders", BindingFlags.NonPublic | BindingFlags.Static); | ||
var changesBuilders = (System.Collections.IDictionary)diff.GetValue(null); | ||
|
||
IEnumerable<Type> diffResults = typeof(Diff).Assembly.GetExportedTypes() | ||
.Where(type => type.GetInterface("IDiffResult") != null); | ||
|
||
var nonBuilderTypes = diffResults.Where(diffResult => !changesBuilders.Contains(diffResult)); | ||
Assert.False(nonBuilderTypes.Any(), "Classes which implement IDiffResult but are not registered under ChangesBuilders in Diff:" + Environment.NewLine + | ||
string.Join(Environment.NewLine, nonBuilderTypes.Select(type => type.FullName))); | ||
} | ||
} | ||
|
||
internal static class TypeExtensions | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace LibGit2Sharp | ||
{ | ||
public interface IDiffResult | ||
{ } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test fails to compile, to removed. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. That's a win! 😉