Getting FxCop online (#6668)

This commit is contained in:
Clint Rutkas
2020-09-16 12:26:58 -07:00
committed by GitHub
parent 0a716c253b
commit d409a71000
2 changed files with 51 additions and 19 deletions

View File

@@ -2,6 +2,7 @@
// The Microsoft Corporation licenses this file to you under the MIT license. // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System;
using System.Threading; using System.Threading;
using interop; using interop;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -9,46 +10,73 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Microsoft.Interop.Tests namespace Microsoft.Interop.Tests
{ {
[TestClass] [TestClass]
public class InteropTests public class InteropTests : IDisposable
{ {
private const string ServerSidePipe = "\\\\.\\pipe\\serverside"; private const string ServerSidePipe = "\\\\.\\pipe\\serverside";
private const string ClientSidePipe = "\\\\.\\pipe\\clientside"; private const string ClientSidePipe = "\\\\.\\pipe\\clientside";
private TwoWayPipeMessageIPCManaged clientPipe; internal TwoWayPipeMessageIPCManaged ClientPipe { get; set; }
private bool disposedValue;
[TestInitialize] [TestInitialize]
public void Initialize() public void Initialize()
{ {
clientPipe = new TwoWayPipeMessageIPCManaged(ClientSidePipe, ServerSidePipe, null); ClientPipe = new TwoWayPipeMessageIPCManaged(ClientSidePipe, ServerSidePipe, null);
} }
[TestCleanup] [TestCleanup]
public void Cleanup() public void Cleanup()
{ {
clientPipe.End(); ClientPipe.End();
} }
[TestMethod] [TestMethod]
public void TestSend() public void TestSend()
{ {
var testString = "This string is a test\n"; var testString = "This string is a test\n";
var reset = new AutoResetEvent(false); using (var reset = new AutoResetEvent(false))
{
var serverPipe = new TwoWayPipeMessageIPCManaged( using (var serverPipe = new TwoWayPipeMessageIPCManaged(
ServerSidePipe, ServerSidePipe,
ClientSidePipe, ClientSidePipe,
(string msg) => (string msg) =>
{
Assert.AreEqual(testString, msg);
reset.Set();
}))
{ {
Assert.AreEqual(testString, msg); serverPipe.Start();
reset.Set(); ClientPipe.Start();
});
serverPipe.Start();
clientPipe.Start();
clientPipe.Send(testString); ClientPipe.Send(testString);
reset.WaitOne(); reset.WaitOne();
serverPipe.End(); serverPipe.End();
}
}
}
protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
ClientPipe.Dispose();
}
// TODO: free unmanaged resources (unmanaged objects) and override finalizer
// TODO: set large fields to null
disposedValue = true;
}
}
public void Dispose()
{
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
Dispose(disposing: true);
GC.SuppressFinalize(this);
} }
} }
} }

View File

@@ -77,7 +77,6 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
@@ -107,6 +106,11 @@
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers">
<Version>3.3.0</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers"> <PackageReference Include="StyleCop.Analyzers">
<Version>1.1.118</Version> <Version>1.1.118</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>