Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Non-windows platforms working #4861

Merged
merged 11 commits into from Jul 21, 2017
6 changes: 1 addition & 5 deletions src/Directory.Build.props
Expand Up @@ -4,10 +4,6 @@
<PackageReference Include="Terrajobst.PlatformCompat.Analyzers" Version="0.0.95-alpha" PrivateAssets="All" />
</ItemGroup>

<PropertyGroup>
<PlatformCompatIgnore>Linux;MacOSX</PlatformCompatIgnore>
</PropertyGroup>

<!-- Workaround for GitVersion 4.0 not creating GitVersionInformation by default -->
<PropertyGroup>
<UpdateAssemblyInfo>true</UpdateAssemblyInfo>
Expand All @@ -25,7 +21,7 @@
<PackageReference Include="GitVersionTask" Version="$(GitVersionTaskVersion)" PrivateAssets="All" />
</ItemGroup>

<ImportGroup Condition="'$(ExcludeRestorePackageImports)' == 'true'">
<ImportGroup Condition="'$(ExcludeRestorePackageImports)' == 'true' And '$(MSBuildRuntimeType)' != 'Core'">
<Import
Project="$(UserProfile)\.nuget\packages\gitversiontask\$(GitVersionTaskVersion)\buildMultiTargeting\GitVersionTask.targets"
Condition="Exists('$(UserProfile)\.nuget\packages\gitversiontask\$(GitVersionTaskVersion)\buildMultiTargeting\GitVersionTask.targets')" />
Expand Down
@@ -1,4 +1,5 @@
锘縰sing System.IO;
锘縰sing System;
using System.IO;
using System.Threading.Tasks;
using NServiceBus;
using NServiceBus.AcceptanceTesting.Support;
Expand All @@ -11,8 +12,19 @@ public Task Configure(string endpointName, EndpointConfiguration configuration,
{
var testRunId = TestContext.CurrentContext.Test.ID;

//can't use bin dir since that will be too long on the build agents
storageDir = Path.Combine(@"c:\temp", testRunId);
string tempDir;

if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
//can't use bin dir since that will be too long on the build agents
tempDir = @"c:\temp";
}
else
{
tempDir = Path.GetTempPath();
}

storageDir = Path.Combine(tempDir, testRunId);

configuration.UsePersistence<InMemoryPersistence, StorageType.Subscriptions>();
configuration.UsePersistence<InMemoryPersistence, StorageType.Timeouts>();
Expand Down
@@ -1,3 +1,4 @@
using System;
using System.IO;
using System.Threading.Tasks;
using NServiceBus;
Expand All @@ -21,8 +22,19 @@ public Task Configure(string endpointName, EndpointConfiguration configuration,
{
var testRunId = TestContext.CurrentContext.Test.ID;

//can't use bin dir since that will be too long on the build agents
storageDir = Path.Combine(@"c:\temp", testRunId);
string tempDir;

if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
//can't use bin dir since that will be too long on the build agents
tempDir = @"c:\temp";
}
else
{
tempDir = Path.GetTempPath();
}

storageDir = Path.Combine(tempDir, testRunId);

//we want the tests to be exposed to concurrency
configuration.LimitMessageProcessingConcurrencyTo(PushRuntimeSettings.Default.MaxConcurrency);
Expand Down
Expand Up @@ -55,7 +55,9 @@ public Guid Generate(SagaIdGeneratorContext context)
static Guid ToGuid(string src)
{
var stringbytes = Encoding.UTF8.GetBytes(src);
#pragma warning disable PC001
using (var provider = new SHA1CryptoServiceProvider())
#pragma warning restore PC001
{
var hashedBytes = provider.ComputeHash(stringbytes);
Array.Resize(ref hashedBytes, 16);
Expand Down
Expand Up @@ -41,7 +41,7 @@ public Sender()
{
EndpointSetup<DefaultServer>(builder =>
{
var basePath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"databus\sender");
var basePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "databus", "sender");
builder.UseDataBus<FileShareDataBus>().BasePath(basePath);

builder.ConfigureTransport().Routing().RouteToEndpoint(typeof(MyMessageWithLargePayload), typeof(Receiver));
Expand All @@ -55,7 +55,7 @@ public Receiver()
{
EndpointSetup<DefaultServer>(builder =>
{
var basePath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"databus\sender");
var basePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "databus", "sender");
builder.UseDataBus<FileShareDataBus>().BasePath(basePath);
builder.RegisterMessageMutator(new Mutator());
});
Expand Down
Expand Up @@ -45,7 +45,7 @@ public Sender()
.DefiningCommandsAs(t => t.Namespace != null && t.FullName == typeof(MyMessageWithLargePayload).FullName)
.DefiningDataBusPropertiesAs(t => t.Name.Contains("Payload"));

var basePath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"databus\sender");
var basePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "databus", "sender");
builder.UseDataBus<FileShareDataBus>().BasePath(basePath);

builder.ConfigureTransport().Routing().RouteToEndpoint(typeof(MyMessageWithLargePayload), typeof(Receiver));
Expand All @@ -63,7 +63,7 @@ public Receiver()
.DefiningCommandsAs(t => t.Namespace != null && t.FullName == typeof(MyMessageWithLargePayload).FullName)
.DefiningDataBusPropertiesAs(t => t.Name.Contains("Payload"));

var basePath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"databus\sender");
var basePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "databus", "sender");
builder.UseDataBus<FileShareDataBus>().BasePath(basePath);
builder.RegisterMessageMutator(new Mutator());
});
Expand Down
2 changes: 2 additions & 0 deletions src/NServiceBus.AcceptanceTests/DeterministicGuid.cs
Expand Up @@ -9,7 +9,9 @@ static class DeterministicGuid
public static Guid Create(params object[] data)
{
// use MD5 hash to get a 16-byte hash of the string
#pragma warning disable PC001
using (var provider = new MD5CryptoServiceProvider())
#pragma warning restore PC001
{
var inputBytes = Encoding.Default.GetBytes(string.Concat(data));
var hashBytes = provider.ComputeHash(inputBytes);
Expand Down
Expand Up @@ -4,6 +4,7 @@
<TargetFrameworks>net452;netcoreapp2.0</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>$(NoWarn);PCR0001</NoWarn>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

<ItemGroup>
Expand Down
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFrameworks>net452;netcoreapp2.0</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/NServiceBus.Core.Tests/ArgumentExceptionTests.cs
Expand Up @@ -136,7 +136,7 @@ bool MethodCallSelf(MethodDefinition method)

static void WriteMethod(MethodDefinition method, TextWriter writer)
{
writer.WriteLine($"\r\n{method.DeclaringType.Name}.{method.Name}");
writer.WriteLine($"{Environment.NewLine}{method.DeclaringType.Name}.{method.Name}");

var mapping = method.DebugInformation.GetSequencePointMapping();

Expand Down
Expand Up @@ -414,11 +414,10 @@ static void ThrowIfCompilationWasNotSuccessful(CompilerResults results)
{
if (results.Errors.HasErrors)
{
var errors = new StringBuilder("Compiler Errors :\r\n");
var errors = new StringBuilder($"Compiler Errors :{Environment.NewLine}");
foreach (CompilerError error in results.Errors)
{
errors.AppendFormat("Line {0},{1}\t: {2}\n",
error.Line, error.Column, error.ErrorText);
errors.Append($"Line {error.Line},{error.Column}\t: {error.ErrorText}{Environment.NewLine}");
}
throw new Exception(errors.ToString());
}
Expand Down
Expand Up @@ -11,7 +11,7 @@ public class When_scanning_assemblies_with_circular_dependencies
[Test]
public void ReferencesNServiceBus_circular()
{
var scanner = new AssemblyScanner(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestDlls\circular"));
var scanner = new AssemblyScanner(Path.Combine(TestContext.CurrentContext.TestDirectory, "TestDlls", "circular"));
scanner.ScanAppDomainAssemblies = false;

var result = scanner.GetScannableAssemblies();
Expand Down
4 changes: 2 additions & 2 deletions src/NServiceBus.Core.Tests/DocumentationTests.cs
Expand Up @@ -28,8 +28,8 @@ public void EnsureNoDocumentationIsEmpty()

if (list.Any())
{
var errors = string.Join("\r\n", list);
throw new Exception("Some members have empty documentation or have a sentence that does not end with a period:\r\n" + errors);
var errors = string.Join(Environment.NewLine, list);
throw new Exception($"Some members have empty documentation or have a sentence that does not end with a period:{Environment.NewLine}{errors}");
}
}

Expand Down
44 changes: 22 additions & 22 deletions src/NServiceBus.Core.Tests/Logging/RollingLoggerTests.cs
Expand Up @@ -23,15 +23,15 @@ public void When_file_already_exists_that_file_is_written_to()
logger1.Write("Foo");
var files1 = tempPath.GetFiles();
Assert.AreEqual(1, files1.Count);
Assert.AreEqual("Foo\r\n", NonLockingFileReader.ReadAllTextWithoutLocking(files1.First()));
Assert.AreEqual($"Foo{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(files1.First()));
var logger2 = new RollingLogger(tempPath.TempDirectory)
{
GetDate = () => dateTime
};
logger2.Write("Bar");
var files2 = tempPath.GetFiles();
Assert.AreEqual(1, files2.Count);
Assert.AreEqual("Foo\r\nBar\r\n", NonLockingFileReader.ReadAllTextWithoutLocking(files2.First()));
Assert.AreEqual($"Foo{Environment.NewLine}Bar{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(files2.First()));
}
}

Expand All @@ -48,7 +48,7 @@ public void When_file_is_deleted_underneath_continues_to_write_afterwards()
var single = tempPath.GetSingle();
File.Delete(single);
logger.Write("Bar");
Assert.AreEqual("Bar\r\n", NonLockingFileReader.ReadAllTextWithoutLocking(single));
Assert.AreEqual($"Bar{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(single));
}
}

Expand All @@ -67,7 +67,7 @@ public void When_file_is_locked_exception_is_swallowed()
{
logger.Write("Bar");
}
Assert.AreEqual("Foo\r\n", NonLockingFileReader.ReadAllTextWithoutLocking(single));
Assert.AreEqual($"Foo{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(single));
}
}

Expand All @@ -89,7 +89,7 @@ public void When_file_is_deleted_underneath_immediately_before_write()
var singleFile = tempPath.GetSingle();
File.Delete(singleFile);
logger.Write("Bar");
Assert.AreEqual("Bar\r\n", NonLockingFileReader.ReadAllTextWithoutLocking(singleFile));
Assert.AreEqual($"Bar{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(singleFile));
}
}

Expand Down Expand Up @@ -129,11 +129,11 @@ public void When_file_already_exists_and_is_too_large_a_new_sequence_file_is_wri

var first = files[0];
Assert.AreEqual("nsb_log_2010-10-01_0.txt", Path.GetFileName(first));
Assert.AreEqual("Some long text\r\n", NonLockingFileReader.ReadAllTextWithoutLocking(files.First()));
Assert.AreEqual($"Some long text{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(files.First()));

var second = files[1];
Assert.AreEqual("nsb_log_2010-10-01_1.txt", Path.GetFileName(second));
Assert.AreEqual("Bar\r\n", NonLockingFileReader.ReadAllTextWithoutLocking(second));
Assert.AreEqual($"Bar{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(second));
}
}

Expand All @@ -158,11 +158,11 @@ public void When_file_already_exists_with_wrong_date_a_file_is_written()

var first = files[0];
Assert.AreEqual("nsb_log_2010-10-01_0.txt", Path.GetFileName(first));
Assert.AreEqual("Foo\r\n", NonLockingFileReader.ReadAllTextWithoutLocking(files.First()));
Assert.AreEqual($"Foo{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(files.First()));

var second = files[1];
Assert.AreEqual("nsb_log_2010-10-02_0.txt", Path.GetFileName(second));
Assert.AreEqual("Bar\r\n", NonLockingFileReader.ReadAllTextWithoutLocking(second));
Assert.AreEqual($"Bar{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(second));
}
}

Expand All @@ -174,7 +174,7 @@ public void When_line_is_write_line_appears_in_file()
var logger = new RollingLogger(tempPath.TempDirectory);
logger.Write("Foo");
var singleFile = tempPath.GetSingle();
Assert.AreEqual("Foo\r\n", NonLockingFileReader.ReadAllTextWithoutLocking(singleFile));
Assert.AreEqual($"Foo{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(singleFile));
}
}

Expand All @@ -187,7 +187,7 @@ public void When_multiple_lines_are_written_lines_appears_in_file()
logger.Write("Foo");
logger.Write("Bar");
var singleFile = tempPath.GetSingle();
Assert.AreEqual("Foo\r\nBar\r\n", NonLockingFileReader.ReadAllTextWithoutLocking(singleFile));
Assert.AreEqual($"Foo{Environment.NewLine}Bar{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(singleFile));
}
}

Expand All @@ -207,11 +207,11 @@ public void When_max_file_size_is_exceeded_sequence_number_is_added()

var first = files[0];
Assert.AreEqual("nsb_log_2010-10-01_0.txt", Path.GetFileName(first));
Assert.AreEqual("Some long text\r\n", NonLockingFileReader.ReadAllTextWithoutLocking(first));
Assert.AreEqual($"Some long text{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(first));

var second = files[1];
Assert.AreEqual("nsb_log_2010-10-01_1.txt", Path.GetFileName(second));
Assert.AreEqual("Bar\r\n", NonLockingFileReader.ReadAllTextWithoutLocking(second));
Assert.AreEqual($"Bar{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(second));
}
}

Expand Down Expand Up @@ -241,7 +241,7 @@ public void When_new_write_causes_overlap_of_file_size_line_is_written_to_curren
logger.Write("Foo");
logger.Write("Some long text");
var singleFile = tempPath.GetSingle();
Assert.AreEqual("Foo\r\nSome long text\r\n", NonLockingFileReader.ReadAllTextWithoutLocking(singleFile));
Assert.AreEqual($"Foo{Environment.NewLine}Some long text{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(singleFile));
}
}

Expand All @@ -262,11 +262,11 @@ public void When_date_changes_new_file_is_written()

var first = files[0];
Assert.AreEqual("nsb_log_2010-10-01_0.txt", Path.GetFileName(first));
Assert.AreEqual("Foo\r\n", NonLockingFileReader.ReadAllTextWithoutLocking(first));
Assert.AreEqual($"Foo{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(first));

var second = files[1];
Assert.AreEqual("nsb_log_2010-10-02_0.txt", Path.GetFileName(second));
Assert.AreEqual("Bar\r\n", NonLockingFileReader.ReadAllTextWithoutLocking(second));
Assert.AreEqual($"Bar{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(second));
}
}

Expand Down Expand Up @@ -348,15 +348,15 @@ public void When_many_files_written_over_size_old_files_are_deleted()

var first = files[0];
Assert.AreEqual("nsb_log_2010-10-01_2.txt", Path.GetFileName(first));
Assert.AreEqual("Long text2\r\n", NonLockingFileReader.ReadAllTextWithoutLocking(first));
Assert.AreEqual($"Long text2{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(first));

var second = files[1];
Assert.AreEqual("nsb_log_2010-10-01_3.txt", Path.GetFileName(second));
Assert.AreEqual("Long text3\r\n", NonLockingFileReader.ReadAllTextWithoutLocking(second));
Assert.AreEqual($"Long text3{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(second));

var third = files[2];
Assert.AreEqual("nsb_log_2010-10-01_4.txt", Path.GetFileName(third));
Assert.AreEqual("Long text4\r\n", NonLockingFileReader.ReadAllTextWithoutLocking(third));
Assert.AreEqual($"Long text4{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(third));
}
}

Expand All @@ -383,15 +383,15 @@ public void When_many_files_written_over_dates_old_files_are_deleted()

var first = files[0];
Assert.AreEqual("nsb_log_2010-10-03_0.txt", Path.GetFileName(first));
Assert.AreEqual("Foo3\r\n", NonLockingFileReader.ReadAllTextWithoutLocking(first));
Assert.AreEqual($"Foo3{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(first));

var second = files[1];
Assert.AreEqual("nsb_log_2010-10-04_0.txt", Path.GetFileName(second));
Assert.AreEqual("Foo4\r\n", NonLockingFileReader.ReadAllTextWithoutLocking(second));
Assert.AreEqual($"Foo4{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(second));

var third = files[2];
Assert.AreEqual("nsb_log_2010-10-05_0.txt", Path.GetFileName(third));
Assert.AreEqual("Foo5\r\n", NonLockingFileReader.ReadAllTextWithoutLocking(third));
Assert.AreEqual($"Foo5{Environment.NewLine}", NonLockingFileReader.ReadAllTextWithoutLocking(third));
}
}

Expand Down
1 change: 1 addition & 0 deletions src/NServiceBus.Core.Tests/NServiceBus.Core.Tests.csproj
Expand Up @@ -7,6 +7,7 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>$(NoWarn);NU1701</NoWarn>
<Optimize>False</Optimize>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

<ItemGroup>
Expand Down