Skip to content

Commit 008f5ba

Browse files
authored
Merge pull request #11 from cpsusie/v0.2.5.x-Issue_10
V0.2.5.x issue 10
2 parents 78dc0b0 + c002dbf commit 008f5ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+544
-1831
lines changed

CafeBabeGame/.editorconfig

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[*.cs]
2+
3+
# DotNetVault_EarlyDisposeJustification: Justification for early dispose of LockedResourceObject
4+
dotnet_diagnostic.DotNetVault_EarlyDisposeJustification.severity = error
5+
6+
# DotNetVault_ReportWhiteLists: Report on location of Whitelist files
7+
dotnet_diagnostic.DotNetVault_ReportWhiteLists.severity = error

CafeBabeGame/CafeBabeGame/CafeBabeGame.csproj

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
</PropertyGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="DotNetVault" Version="0.2.5.9" />
17-
<PackageReference Include="HighPrecisionTimeStamps" Version="0.1.0" />
16+
<PackageReference Include="DotNetVault" Version="0.2.5.18" />
1817
<PackageReference Include="System.Collections.Immutable" Version="5.0.0" />
1918
</ItemGroup>
2019

CafeBabeGame/CafeBabeGame/Program.cs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
namespace CafeBabeGame
1717
{
18+
//[ReportWhiteListLocations]
1819
class Program
1920
{
2021
private static readonly IDeadBeefCafeGameFactory GameFactory = new DeadBeefCafeGameFactorySource().FactoryInstance;

Clorton Game/ClortonGameDemo/ClortonGameDemo.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
</PropertyGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="DotNetVault" Version="0.2.5.9" />
17-
<PackageReference Include="HighPrecisionTimeStamps" Version="0.1.0" />
16+
<PackageReference Include="DotNetVault" Version="0.2.5.18" />
17+
<PackageReference Include="HighPrecisionTimeStamps" Version="1.0.0" />
1818
<PackageReference Include="System.Collections.Immutable" Version="5.0.0" />
1919
</ItemGroup>
2020

Clorton Game/ClortonGameDemo/Program.cs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace ClortonGameDemo
1010
{
11+
//[ReportWhiteListLocations]
1112
class Program
1213
{
1314
private static IClortonGameFactory GameFactory { get; set; }

ConsoleStressTest/ConsoleStressTest.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
</PropertyGroup>
1818

1919
<ItemGroup>
20-
<PackageReference Include="DotNetVault" Version="0.2.5.9" />
21-
<PackageReference Include="HighPrecisionTimeStamps" Version="0.1.0" />
20+
<PackageReference Include="DotNetVault" Version="0.2.5.18" />
21+
<PackageReference Include="HighPrecisionTimeStamps" Version="1.0.0" />
2222
<PackageReference Include="System.Collections.Immutable" Version="5.0.0" />
2323
</ItemGroup>
2424

ConsoleStressTest/Program.cs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace ConsoleStressTest
1212
{
13+
//[ReportWhiteListLocations]
1314
class Program
1415
{
1516
static Program() => TheResultText = new LocklessWriteOnce<string>();

DotNetVault.Test/AnalyzerYetAgainUnitTests.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,18 @@ public class UnitTest : CodeFixVerifier
3030
public void ValidateEmpty()
3131
{
3232
var test = @"";
33-
3433
VerifyCSharpDiagnostic(test);
3534
}
35+
36+
[TestMethod]
37+
public void ValidateWhiteListsReported()
38+
{
39+
var test = ResourceFiles.ReportWhiteListTestCases.ReportOnWhiteListsTestCase;
40+
VerifyCSharpDiagnostic(test, col => col.Count() == 1,
41+
dx => dx.Id == DotNetVaultAnalyzer.DotNetVault_ReportWhiteLists &&
42+
dx.Severity == DiagnosticSeverity.Warning && !dx.IsSuppressed);
43+
}
44+
3645
[TestMethod]
3746
public void Bug76TestCase1()
3847
{

DotNetVault.Test/DotNetVault.Test.csproj

+11-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
<Compile Remove="TestCases\QueryTestCases.cs" />
7272
<Compile Remove="TestCases\RefStructAttributeTestsOk.cs" />
7373
<Compile Remove="TestCases\RefStructAttrNotOkCase1.cs" />
74+
<Compile Remove="TestCases\ReportOnWhiteListsTestCase.cs" />
7475
<Compile Remove="TestCases\RoRegularNotARefStructCase2.cs" />
7576
<Compile Remove="TestCases\SbAndUriBNotVaultSafe.cs" />
7677
<Compile Remove="TestCases\ShouldTriggerDiagnosticBecauseNoUsing.cs" />
@@ -96,7 +97,7 @@
9697
</ItemGroup>
9798

9899
<ItemGroup>
99-
<PackageReference Include="HighPrecisionTimeStamps" Version="0.1.0" />
100+
<PackageReference Include="HighPrecisionTimeStamps" Version="1.0.0" />
100101
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.2">
101102
<PrivateAssets>all</PrivateAssets>
102103
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@@ -164,6 +165,11 @@
164165
<AutoGen>True</AutoGen>
165166
<DependentUpon>RefStructAttributeTestCases.resx</DependentUpon>
166167
</Compile>
168+
<Compile Update="ResourceFiles\ReportWhiteListTestCases.Designer.cs">
169+
<DesignTime>True</DesignTime>
170+
<AutoGen>True</AutoGen>
171+
<DependentUpon>ReportWhiteListTestCases.resx</DependentUpon>
172+
</Compile>
167173
<Compile Update="ResourceFiles\UsingMandatoryTestCases.Designer.cs">
168174
<DesignTime>True</DesignTime>
169175
<AutoGen>True</AutoGen>
@@ -256,6 +262,10 @@
256262
<Generator>ResXFileCodeGenerator</Generator>
257263
<LastGenOutput>RefStructAttributeTestCases.Designer.cs</LastGenOutput>
258264
</EmbeddedResource>
265+
<EmbeddedResource Update="ResourceFiles\ReportWhiteListTestCases.resx">
266+
<Generator>ResXFileCodeGenerator</Generator>
267+
<LastGenOutput>ReportWhiteListTestCases.Designer.cs</LastGenOutput>
268+
</EmbeddedResource>
259269
<EmbeddedResource Update="ResourceFiles\UsingMandatoryTestCases.resx">
260270
<Generator>ResXFileCodeGenerator</Generator>
261271
<LastGenOutput>UsingMandatoryTestCases.Designer.cs</LastGenOutput>

DotNetVault.Test/ResourceFiles/ReportWhiteListTestCases.Designer.cs

+85
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<root>
3+
<!--
4+
Microsoft ResX Schema
5+
6+
Version 2.0
7+
8+
The primary goals of this format is to allow a simple XML format
9+
that is mostly human readable. The generation and parsing of the
10+
various data types are done through the TypeConverter classes
11+
associated with the data types.
12+
13+
Example:
14+
15+
... ado.net/XML headers & schema ...
16+
<resheader name="resmimetype">text/microsoft-resx</resheader>
17+
<resheader name="version">2.0</resheader>
18+
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19+
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20+
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21+
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22+
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23+
<value>[base64 mime encoded serialized .NET Framework object]</value>
24+
</data>
25+
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26+
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27+
<comment>This is a comment</comment>
28+
</data>
29+
30+
There are any number of "resheader" rows that contain simple
31+
name/value pairs.
32+
33+
Each data row contains a name, and value. The row also contains a
34+
type or mimetype. Type corresponds to a .NET class that support
35+
text/value conversion through the TypeConverter architecture.
36+
Classes that don't support this are serialized and stored with the
37+
mimetype set.
38+
39+
The mimetype is used for serialized objects, and tells the
40+
ResXResourceReader how to depersist the object. This is currently not
41+
extensible. For a given mimetype the value must be set accordingly:
42+
43+
Note - application/x-microsoft.net.object.binary.base64 is the format
44+
that the ResXResourceWriter will generate, however the reader can
45+
read any of the formats listed below.
46+
47+
mimetype: application/x-microsoft.net.object.binary.base64
48+
value : The object must be serialized with
49+
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50+
: and then encoded with base64 encoding.
51+
52+
mimetype: application/x-microsoft.net.object.soap.base64
53+
value : The object must be serialized with
54+
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55+
: and then encoded with base64 encoding.
56+
57+
mimetype: application/x-microsoft.net.object.bytearray.base64
58+
value : The object must be serialized into a byte array
59+
: using a System.ComponentModel.TypeConverter
60+
: and then encoded with base64 encoding.
61+
-->
62+
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63+
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64+
<xsd:element name="root" msdata:IsDataSet="true">
65+
<xsd:complexType>
66+
<xsd:choice maxOccurs="unbounded">
67+
<xsd:element name="metadata">
68+
<xsd:complexType>
69+
<xsd:sequence>
70+
<xsd:element name="value" type="xsd:string" minOccurs="0" />
71+
</xsd:sequence>
72+
<xsd:attribute name="name" use="required" type="xsd:string" />
73+
<xsd:attribute name="type" type="xsd:string" />
74+
<xsd:attribute name="mimetype" type="xsd:string" />
75+
<xsd:attribute ref="xml:space" />
76+
</xsd:complexType>
77+
</xsd:element>
78+
<xsd:element name="assembly">
79+
<xsd:complexType>
80+
<xsd:attribute name="alias" type="xsd:string" />
81+
<xsd:attribute name="name" type="xsd:string" />
82+
</xsd:complexType>
83+
</xsd:element>
84+
<xsd:element name="data">
85+
<xsd:complexType>
86+
<xsd:sequence>
87+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88+
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89+
</xsd:sequence>
90+
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91+
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92+
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93+
<xsd:attribute ref="xml:space" />
94+
</xsd:complexType>
95+
</xsd:element>
96+
<xsd:element name="resheader">
97+
<xsd:complexType>
98+
<xsd:sequence>
99+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100+
</xsd:sequence>
101+
<xsd:attribute name="name" type="xsd:string" use="required" />
102+
</xsd:complexType>
103+
</xsd:element>
104+
</xsd:choice>
105+
</xsd:complexType>
106+
</xsd:element>
107+
</xsd:schema>
108+
<resheader name="resmimetype">
109+
<value>text/microsoft-resx</value>
110+
</resheader>
111+
<resheader name="version">
112+
<value>2.0</value>
113+
</resheader>
114+
<resheader name="reader">
115+
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116+
</resheader>
117+
<resheader name="writer">
118+
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119+
</resheader>
120+
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
121+
<data name="ReportOnWhiteListsTestCase" type="System.Resources.ResXFileRef, System.Windows.Forms">
122+
<value>..\testcases\reportonwhiteliststestcase.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
123+
</data>
124+
</root>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using DotNetVault.Attributes;
3+
4+
namespace DotNetVault.Test.TestCases
5+
{
6+
[ReportWhiteListLocations]
7+
public class ReportOnWhiteListsTestCase
8+
{
9+
public Guid Id { get; }
10+
public ReportOnWhiteListsTestCase() => Id = Guid.NewGuid();
11+
12+
}
13+
}

DotNetVault.Test/VaultSafeAnalysisTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void TestSimplePositiveTypes()
9898
[TestMethod]
9999
public void LoadDiagnosticDescriptorsText()
100100
{
101-
const int numDescriptors = 19;
101+
const int numDescriptors = 20;
102102
var descriptors = DotNetVaultAnalyzer.DiagnosticDescriptors;
103103
Assert.IsTrue(numDescriptors == descriptors.Length);
104104
foreach (var descriptor in descriptors)

DotNetVault.Vsix/DotNetVault.Vsix.csproj

+4-7
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@
6060
<Link>.editorconfig</Link>
6161
</None>
6262
<None Include="app.config" />
63-
<None Include="LICENSE" />
6463
<None Include="packages.config" />
65-
<None Include="Readme.md" />
6664
<None Include="source.extension.vsixmanifest">
6765
<SubType>Designer</SubType>
6866
</None>
@@ -76,11 +74,11 @@
7674
</ProjectReference>
7775
</ItemGroup>
7876
<ItemGroup>
79-
<Reference Include="HighPrecisionTimeStamps, Version=0.1.0.0, Culture=neutral, processorArchitecture=MSIL">
80-
<HintPath>..\packages\HighPrecisionTimeStamps.0.1.0\lib\netstandard2.0\HighPrecisionTimeStamps.dll</HintPath>
77+
<Reference Include="HighPrecisionTimeStamps, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
78+
<HintPath>..\packages\HighPrecisionTimeStamps.1.0.0\lib\netstandard2.0\HighPrecisionTimeStamps.dll</HintPath>
8179
</Reference>
82-
<Reference Include="JetBrains.Annotations, Version=2020.3.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL">
83-
<HintPath>..\packages\JetBrains.Annotations.2020.3.0\lib\net20\JetBrains.Annotations.dll</HintPath>
80+
<Reference Include="JetBrains.Annotations, Version=2021.2.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL">
81+
<HintPath>..\packages\JetBrains.Annotations.2021.2.0\lib\net20\JetBrains.Annotations.dll</HintPath>
8482
</Reference>
8583
<Reference Include="System" />
8684
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
@@ -97,7 +95,6 @@
9795
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
9896
</Reference>
9997
</ItemGroup>
100-
<ItemGroup />
10198
<ItemGroup>
10299
<Compile Include="Properties\AssemblyInfo.cs" />
103100
</ItemGroup>

0 commit comments

Comments
 (0)