Skip to content

Commit

Permalink
Merge pull request #7 from asimmon/feature/public-api-tracking
Browse files Browse the repository at this point in the history
Use Microsoft.CodeAnalysis.PublicApiAnalyzers to track public APIs changes
  • Loading branch information
asimmon authored Oct 2, 2022
2 parents 331c510 + f756a1c commit cdd9da3
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 40 deletions.
13 changes: 0 additions & 13 deletions src/EphemeralMongo.Core.Tests/IsExternalInit.cs

This file was deleted.

28 changes: 27 additions & 1 deletion src/EphemeralMongo.Core.Tests/MongoRunnerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public void Run_Fails_When_BinaryDirectory_Does_Not_Exist()
StandardOuputLogger = x => this.Logger.LogInformation("{X}", x),
StandardErrorLogger = x => this.Logger.LogInformation("{X}", x),
BinaryDirectory = Guid.NewGuid().ToString(),
AdditionalArguments = string.Empty,
};

IMongoRunner? runner = null;
Expand Down Expand Up @@ -116,5 +117,30 @@ public void Import_Export_Works(bool useSingleNodeReplicaSet)
}
}

private sealed record Person(string Id, string Name);
private sealed class Person
{
public Person()
{
}

public Person(string id, string name)
{
this.Id = id;
this.Name = name;
}

public string Id { get; set; } = string.Empty;

public string Name { get; set; } = string.Empty;

private bool Equals(Person other)
{
return this.Id == other.Id && this.Name == other.Name;
}

public override bool Equals(object? obj)
{
return ReferenceEquals(this, obj) || (obj is Person other && this.Equals(other));
}
}
}
4 changes: 4 additions & 0 deletions src/EphemeralMongo.Core/EphemeralMongo.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

<ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="2.12.0" />
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
13 changes: 0 additions & 13 deletions src/EphemeralMongo.Core/IsExternalInit.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/EphemeralMongo.Core/MongoRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private IMongoRunner RunInternal()
var arguments = string.Format(CultureInfo.InvariantCulture, "--dbpath {0} --port {1} --bind_ip 127.0.0.1", ProcessArgument.Escape(this._dataDirectory), this._options.MongoPort);
arguments += RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? string.Empty : " --tlsMode disabled";
arguments += this._options.UseSingleNodeReplicaSet ? " --replSet " + this._options.ReplicaSetName : string.Empty;
arguments += this._options.AdditionalArguments == null ? string.Empty : " " + this._options.AdditionalArguments;
arguments += string.IsNullOrWhiteSpace(this._options.AdditionalArguments) ? string.Empty : " " + this._options.AdditionalArguments;

this._process = this._processFactory.CreateMongoProcess(this._options, MongoProcessKind.Mongod, executablePath, arguments);
this._process.Start();
Expand Down
24 changes: 12 additions & 12 deletions src/EphemeralMongo.Core/MongoRunnerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,42 @@

public sealed class MongoRunnerOptions
{
private readonly string? _dataDirectory;
private readonly string? _binaryDirectory;
private readonly TimeSpan _connectionTimeout = TimeSpan.FromSeconds(30);
private readonly TimeSpan _replicaSetSetupTimeout = TimeSpan.FromSeconds(10);
private string? _dataDirectory;
private string? _binaryDirectory;
private TimeSpan _connectionTimeout = TimeSpan.FromSeconds(30);
private TimeSpan _replicaSetSetupTimeout = TimeSpan.FromSeconds(10);

public string? DataDirectory
{
get => this._dataDirectory;
init => this._dataDirectory = CheckDirectoryPathFormat(value) is { } ex ? throw new ArgumentException(nameof(this.DataDirectory), ex) : value;
set => this._dataDirectory = CheckDirectoryPathFormat(value) is { } ex ? throw new ArgumentException(nameof(this.DataDirectory), ex) : value;
}

public string? BinaryDirectory
{
get => this._binaryDirectory;
init => this._binaryDirectory = CheckDirectoryPathFormat(value) is { } ex ? throw new ArgumentException(nameof(this.BinaryDirectory), ex) : value;
set => this._binaryDirectory = CheckDirectoryPathFormat(value) is { } ex ? throw new ArgumentException(nameof(this.BinaryDirectory), ex) : value;
}

public string? AdditionalArguments { get; init; }
public string? AdditionalArguments { get; set; }

public TimeSpan ConnectionTimeout
{
get => this._connectionTimeout;
init => this._connectionTimeout = value >= TimeSpan.Zero ? value : throw new ArgumentOutOfRangeException(nameof(this.ConnectionTimeout));
set => this._connectionTimeout = value >= TimeSpan.Zero ? value : throw new ArgumentOutOfRangeException(nameof(this.ConnectionTimeout));
}

public bool UseSingleNodeReplicaSet { get; init; }
public bool UseSingleNodeReplicaSet { get; set; }

public TimeSpan ReplicaSetSetupTimeout
{
get => this._replicaSetSetupTimeout;
init => this._replicaSetSetupTimeout = value >= TimeSpan.Zero ? value : throw new ArgumentOutOfRangeException(nameof(this.ReplicaSetSetupTimeout));
set => this._replicaSetSetupTimeout = value >= TimeSpan.Zero ? value : throw new ArgumentOutOfRangeException(nameof(this.ReplicaSetSetupTimeout));
}

public Logger? StandardOuputLogger { get; init; }
public Logger? StandardOuputLogger { get; set; }

public Logger? StandardErrorLogger { get; init; }
public Logger? StandardErrorLogger { get; set; }

// Internal properties start here
internal string ReplicaSetName { get; set; } = "singleNodeReplSet";
Expand Down
26 changes: 26 additions & 0 deletions src/EphemeralMongo.Core/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#nullable enable
EphemeralMongo.IMongoRunner
EphemeralMongo.IMongoRunner.ConnectionString.get -> string!
EphemeralMongo.IMongoRunner.Export(string! database, string! collection, string! outputFilePath, string? additionalArguments = null) -> void
EphemeralMongo.IMongoRunner.Import(string! database, string! collection, string! inputFilePath, string? additionalArguments = null, bool drop = false) -> void
EphemeralMongo.Logger
EphemeralMongo.MongoRunner
EphemeralMongo.MongoRunnerOptions
EphemeralMongo.MongoRunnerOptions.AdditionalArguments.get -> string?
EphemeralMongo.MongoRunnerOptions.AdditionalArguments.set -> void
EphemeralMongo.MongoRunnerOptions.BinaryDirectory.get -> string?
EphemeralMongo.MongoRunnerOptions.BinaryDirectory.set -> void
EphemeralMongo.MongoRunnerOptions.ConnectionTimeout.get -> System.TimeSpan
EphemeralMongo.MongoRunnerOptions.ConnectionTimeout.set -> void
EphemeralMongo.MongoRunnerOptions.DataDirectory.get -> string?
EphemeralMongo.MongoRunnerOptions.DataDirectory.set -> void
EphemeralMongo.MongoRunnerOptions.MongoRunnerOptions() -> void
EphemeralMongo.MongoRunnerOptions.ReplicaSetSetupTimeout.get -> System.TimeSpan
EphemeralMongo.MongoRunnerOptions.ReplicaSetSetupTimeout.set -> void
EphemeralMongo.MongoRunnerOptions.StandardErrorLogger.get -> EphemeralMongo.Logger?
EphemeralMongo.MongoRunnerOptions.StandardErrorLogger.set -> void
EphemeralMongo.MongoRunnerOptions.StandardOuputLogger.get -> EphemeralMongo.Logger?
EphemeralMongo.MongoRunnerOptions.StandardOuputLogger.set -> void
EphemeralMongo.MongoRunnerOptions.UseSingleNodeReplicaSet.get -> bool
EphemeralMongo.MongoRunnerOptions.UseSingleNodeReplicaSet.set -> void
static EphemeralMongo.MongoRunner.Run(EphemeralMongo.MongoRunnerOptions? options = null) -> EphemeralMongo.IMongoRunner!
1 change: 1 addition & 0 deletions src/EphemeralMongo.Core/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#nullable enable

0 comments on commit cdd9da3

Please sign in to comment.