Skip to content

Commit 3109b5f

Browse files
committed
Let users create our types
Instead of hiding everything but making it virtual for mocking, let the users create their own objects with the data they want.
1 parent 0148eca commit 3109b5f

20 files changed

Lines changed: 155 additions & 178 deletions

LibGit2Sharp/CherryPickResult.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@
55
/// </summary>
66
public class CherryPickResult
77
{
8-
internal CherryPickResult(CherryPickStatus status, Commit commit = null)
9-
{
10-
Commit = commit;
11-
Status = status;
12-
}
13-
148
/// <summary>
159
/// The resulting commit of the cherry pick.
1610
/// <para>
@@ -20,12 +14,12 @@ internal CherryPickResult(CherryPickStatus status, Commit commit = null)
2014
/// 2) The option to not commit on success is set.
2115
/// </para>
2216
/// </summary>
23-
public virtual Commit Commit { get; private set; }
17+
public virtual Commit Commit { get; set; }
2418

2519
/// <summary>
2620
/// The status of the cherry pick.
2721
/// </summary>
28-
public virtual CherryPickStatus Status { get; private set; }
22+
public virtual CherryPickStatus Status { get; set; }
2923
}
3024

3125
/// <summary>

LibGit2Sharp/Configuration.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,9 +700,12 @@ private static ConfigurationEntry<string> BuildConfigEntry(IntPtr entryPtr)
700700
{
701701
var entry = entryPtr.MarshalAs<GitConfigEntry>();
702702

703-
return new ConfigurationEntry<string>(LaxUtf8Marshaler.FromNative(entry.namePtr),
704-
LaxUtf8Marshaler.FromNative(entry.valuePtr),
705-
(ConfigurationLevel)entry.level);
703+
return new ConfigurationEntry<string>
704+
{
705+
Key = LaxUtf8Marshaler.FromNative(entry.namePtr),
706+
Value = LaxUtf8Marshaler.FromNative(entry.valuePtr),
707+
Level = (ConfigurationLevel)entry.level,
708+
};
706709
}
707710

708711
/// <summary>

LibGit2Sharp/ConfigurationEntry.cs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,17 @@ public class ConfigurationEntry<T>
1313
/// <summary>
1414
/// The fully-qualified option name.
1515
/// </summary>
16-
public virtual string Key { get; private set; }
16+
public virtual string Key { get; set; }
1717

1818
/// <summary>
1919
/// The option value.
2020
/// </summary>
21-
public virtual T Value { get; private set; }
21+
public virtual T Value { get; set; }
2222

2323
/// <summary>
2424
/// The origin store.
2525
/// </summary>
26-
public virtual ConfigurationLevel Level { get; private set; }
27-
28-
/// <summary>
29-
/// Initializes a new instance of the <see cref="ConfigurationEntry{T}"/> class with a given key and value
30-
/// </summary>
31-
/// <param name="key">The option name</param>
32-
/// <param name="value">The option value</param>
33-
/// <param name="level">The origin store</param>
34-
protected internal ConfigurationEntry(string key, T value, ConfigurationLevel level)
35-
{
36-
Key = key;
37-
Value = value;
38-
Level = level;
39-
}
26+
public virtual ConfigurationLevel Level { get; set; }
4027

4128
private string DebuggerDisplay
4229
{

LibGit2Sharp/Core/Proxy.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,12 @@ public static ConfigurationEntry<T> git_config_get_entry<T>(ConfigurationSafeHan
506506
handle.SafeDispose();
507507
}
508508

509-
return new ConfigurationEntry<T>(LaxUtf8Marshaler.FromNative(entry.namePtr),
510-
(T)configurationParser[typeof(T)](LaxUtf8Marshaler.FromNative(entry.valuePtr)),
511-
(ConfigurationLevel)entry.level);
509+
return new ConfigurationEntry<T>
510+
{
511+
Key = LaxUtf8Marshaler.FromNative(entry.namePtr),
512+
Value = (T)configurationParser[typeof(T)](LaxUtf8Marshaler.FromNative(entry.valuePtr)),
513+
Level = (ConfigurationLevel)entry.level,
514+
};
512515
}
513516

514517
public static ConfigurationSafeHandle git_config_new()

LibGit2Sharp/FilterAttributeEntry.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ public class FilterAttributeEntry
1616

1717
private readonly string filterDefinition;
1818

19-
/// <summary>
20-
/// For testing purposes
21-
/// </summary>
22-
protected FilterAttributeEntry() { }
23-
2419
/// <summary>
2520
/// The name of the filter found in a .gitattributes file.
2621
/// </summary>

LibGit2Sharp/IndexEntry.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ public class IndexEntry : IEquatable<IndexEntry>
1818
/// <summary>
1919
/// Gets the relative path to the file within the working directory.
2020
/// </summary>
21-
public virtual string Path { get; private set; }
21+
public virtual string Path { get; set; }
2222

2323
/// <summary>
2424
/// Gets the file mode.
2525
/// </summary>
26-
public virtual Mode Mode { get; private set; }
26+
public virtual Mode Mode { get; set; }
2727

2828
/// <summary>
2929
/// Gets the stage number.
3030
/// </summary>
31-
public virtual StageLevel StageLevel { get; private set; }
31+
public virtual StageLevel StageLevel { get; set; }
3232

3333
/// <summary>
3434
/// Whether the file is marked as assume-unchanged
3535
/// </summary>
36-
public virtual bool AssumeUnchanged { get; private set; }
36+
public virtual bool AssumeUnchanged { get; set; }
3737

3838
/// <summary>
3939
/// Gets the id of the <see cref="Blob"/> pointed at by this index entry.

LibGit2Sharp/IndexNameEntry.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ internal static IndexNameEntry BuildFromPtr(IndexNameEntrySafeHandle handle)
4646
/// <summary>
4747
/// Gets the path of the ancestor side of the conflict.
4848
/// </summary>
49-
public virtual string Ancestor { get; private set; }
49+
public virtual string Ancestor { get; set; }
5050

5151
/// <summary>
5252
/// Gets the path of the "ours" side of the conflict.
5353
/// </summary>
54-
public virtual string Ours { get; private set; }
54+
public virtual string Ours { get; set; }
5555

5656
/// <summary>
5757
/// Gets the path of the "theirs" side of the conflict.
5858
/// </summary>
59-
public virtual string Theirs { get; private set; }
59+
public virtual string Theirs { get; set; }
6060

6161
/// <summary>
6262
/// Determines whether the specified <see cref="Object"/> is equal to the current <see cref="IndexNameEntry"/>.

LibGit2Sharp/IndexReucEntry.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,43 +45,43 @@ internal static IndexReucEntry BuildFromPtr(IndexReucEntrySafeHandle handle)
4545
/// <summary>
4646
/// Gets the path of this conflict.
4747
/// </summary>
48-
public virtual string Path { get; private set; }
48+
public virtual string Path { get; set; }
4949

5050
/// <summary>
5151
/// Gets the <see cref="ObjectId"/> that was the ancestor of this
5252
/// conflict.
5353
/// </summary>
54-
public virtual ObjectId AncestorId { get; private set; }
54+
public virtual ObjectId AncestorId { get; set; }
5555

5656
/// <summary>
5757
/// Gets the <see cref="Mode"/> of the file that was the ancestor of
5858
/// conflict.
5959
/// </summary>
60-
public virtual Mode AncestorMode { get; private set; }
60+
public virtual Mode AncestorMode { get; set; }
6161

6262
/// <summary>
6363
/// Gets the <see cref="ObjectId"/> that was "our" side of this
6464
/// conflict.
6565
/// </summary>
66-
public virtual ObjectId OurId { get; private set; }
66+
public virtual ObjectId OurId { get; set; }
6767

6868
/// <summary>
6969
/// Gets the <see cref="Mode"/> of the file that was "our" side of
7070
/// the conflict.
7171
/// </summary>
72-
public virtual Mode OurMode { get; private set; }
72+
public virtual Mode OurMode { get; set; }
7373

7474
/// <summary>
7575
/// Gets the <see cref="ObjectId"/> that was "their" side of this
7676
/// conflict.
7777
/// </summary>
78-
public virtual ObjectId TheirId { get; private set; }
78+
public virtual ObjectId TheirId { get; set; }
7979

8080
/// <summary>
8181
/// Gets the <see cref="Mode"/> of the file that was "their" side of
8282
/// the conflict.
8383
/// </summary>
84-
public virtual Mode TheirMode { get; private set; }
84+
public virtual Mode TheirMode { get; set; }
8585

8686
/// <summary>
8787
/// Determines whether the specified <see cref="Object"/> is equal to the current <see cref="IndexReucEntry"/>.

LibGit2Sharp/LogEntry.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ public sealed class LogEntry
88
/// <summary>
99
/// The file's path relative to the repository's root.
1010
/// </summary>
11-
public string Path { get; internal set; }
11+
public string Path { get; set; }
1212

1313
/// <summary>
1414
/// The commit in which the file was created or changed.
1515
/// </summary>
16-
public Commit Commit { get; internal set; }
16+
public Commit Commit { get; set; }
1717
}
1818
}

LibGit2Sharp/MergeResult.cs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,17 @@
55
/// </summary>
66
public class MergeResult
77
{
8-
internal MergeResult(MergeStatus status, Commit commit = null)
9-
{
10-
this.Status = status;
11-
this.Commit = commit;
12-
}
13-
148
/// <summary>
159
/// The status of the merge.
1610
/// </summary>
17-
public virtual MergeStatus Status
18-
{
19-
get;
20-
private set;
21-
}
11+
public virtual MergeStatus Status { get; set; }
2212

2313
/// <summary>
2414
/// The resulting commit of the merge. For fast-forward merges, this is the
2515
/// commit that merge was fast forwarded to.
2616
/// <para>This will return <code>null</code> if the merge has been unsuccessful due to conflicts.</para>
2717
/// </summary>
28-
public virtual Commit Commit
29-
{
30-
get;
31-
private set;
32-
}
18+
public virtual Commit Commit { get; set; }
3319
}
3420

3521
/// <summary>

0 commit comments

Comments
 (0)