Skip to content

Commit 08c6647

Browse files
author
Martin Taillefer (from Dev Box)
committed
Address PR feedback
1 parent dc4535f commit 08c6647

File tree

5 files changed

+23
-25
lines changed

5 files changed

+23
-25
lines changed

src/Generators/Microsoft.Gen.Logging/Emission/Emitter.Method.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ private string MakeClassificationValue(HashSet<string> classificationTypes)
569569
{
570570
if (i > 0)
571571
{
572-
_ = sb.Append(" , ");
572+
_ = sb.Append(", ");
573573
}
574574

575575
_ = sb.Append(_classificationMap[ct]);

src/Libraries/Microsoft.Extensions.Compliance.Abstractions/Classification/DataClassification.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace Microsoft.Extensions.Compliance.Classification;
88

99
/// <summary>
10-
/// Represents a single data class which is part of a data taxonomy.
10+
/// Represents a single classification which is part of a data taxonomy.
1111
/// </summary>
1212
public readonly struct DataClassification : IEquatable<DataClassification>
1313
{
@@ -27,15 +27,15 @@ namespace Microsoft.Extensions.Compliance.Classification;
2727
public string TaxonomyName { get; }
2828

2929
/// <summary>
30-
/// Gets the value representing the data class within the taxonomy.
30+
/// Gets the value representing the classification within the taxonomy.
3131
/// </summary>
3232
public string Value { get; }
3333

3434
/// <summary>
3535
/// Initializes a new instance of the <see cref="DataClassification"/> struct.
3636
/// </summary>
37-
/// <param name="taxonomyName">The name of the taxonomy this classification belongs to.</param>
38-
/// <param name="value">The taxonomy-specific value representing the data class.</param>
37+
/// <param name="taxonomyName">The name of the data taxonomy this classification belongs to.</param>
38+
/// <param name="value">The taxonomy-specific value representing the classification.</param>
3939
public DataClassification(string taxonomyName, string value)
4040
{
4141
TaxonomyName = Throw.IfNullOrEmpty(taxonomyName);
@@ -49,21 +49,21 @@ private DataClassification(string value)
4949
}
5050

5151
/// <summary>
52-
/// Checks if object is equal to this instance of <see cref="DataClassification"/>.
52+
/// Checks if an object is equal to this instance of <see cref="DataClassification"/>.
5353
/// </summary>
5454
/// <param name="obj">Object to check for equality.</param>
5555
/// <returns><see langword="true" /> if object instances are equal <see langword="false" /> otherwise.</returns>
5656
public override bool Equals(object? obj) => (obj is DataClassification dc) && Equals(dc);
5757

5858
/// <summary>
59-
/// Checks if object is equal to this instance of <see cref="DataClassification"/>.
59+
/// Checks if an object is equal to this instance of <see cref="DataClassification"/>.
6060
/// </summary>
6161
/// <param name="other">Instance of <see cref="DataClassification"/> to check for equality.</param>
6262
/// <returns><see langword="true" /> if object instances are equal <see langword="false" /> otherwise.</returns>
6363
public bool Equals(DataClassification other) => other.TaxonomyName == TaxonomyName && other.Value == Value;
6464

6565
/// <summary>
66-
/// Get the hash code the current instance.
66+
/// Get the hash code for the current instance.
6767
/// </summary>
6868
/// <returns>Hash code.</returns>
6969
public override int GetHashCode()
@@ -97,5 +97,5 @@ public override int GetHashCode()
9797
/// Gets a string representation of this object.
9898
/// </summary>
9999
/// <returns>A string representing the object.</returns>
100-
public override string ToString() => $"{TaxonomyName}:{Value}";
100+
public override string ToString() => string.IsNullOrWhiteSpace(TaxonomyName) ? Value : $"{TaxonomyName}:{Value}";
101101
}

src/Libraries/Microsoft.Extensions.Compliance.Abstractions/Classification/DataClassificationAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class DataClassificationAttribute : Attribute
2929
public string Notes { get; set; } = string.Empty;
3030

3131
/// <summary>
32-
/// Gets the data class represented by this attribute.
32+
/// Gets the classification represented by this attribute.
3333
/// </summary>
3434
public DataClassification Classification { get; }
3535

src/Libraries/Microsoft.Extensions.Compliance.Abstractions/Classification/DataClassificationSet.cs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace Microsoft.Extensions.Compliance.Classification;
1111

1212
/// <summary>
13-
/// Represents a set of data classes.
13+
/// Represents a set of data classifications.
1414
/// </summary>
1515
public sealed class DataClassificationSet : IEquatable<DataClassificationSet>
1616
{
@@ -46,7 +46,7 @@ public DataClassificationSet(params DataClassification[] classifications)
4646
}
4747

4848
/// <summary>
49-
/// Converts a data classification to a data classification set.
49+
/// Converts a single classification to a data classification set.
5050
/// </summary>
5151
/// <param name="classification">The classification to include in the set.</param>
5252
public static implicit operator DataClassificationSet(DataClassification classification)
@@ -55,16 +55,19 @@ public static implicit operator DataClassificationSet(DataClassification classif
5555
}
5656

5757
/// <summary>
58-
/// Converts a data classification to a data classification set.
58+
/// Converts a single classification to a data classification set.
5959
/// </summary>
6060
/// <param name="classification">The classification to include in the set.</param>
6161
/// <returns>The resulting data classification set.</returns>
6262
public static DataClassificationSet FromDataClassification(DataClassification classification) => new(classification);
6363

6464
/// <summary>
65-
/// Creates a new data classification that combines the current classifications with another set.
65+
/// Creates a new data classification set that combines the current classifications with another set.
6666
/// </summary>
6767
/// <param name="other">The other set.</param>
68+
/// <remarks>
69+
/// This method doesn't modify the two input sets, it creates a new set.
70+
/// </remarks>
6871
/// <returns>The resulting set which combines the current instance's classifications and the other ones.</returns>
6972
public DataClassificationSet Union(DataClassificationSet other)
7073
{
@@ -83,26 +86,18 @@ public DataClassificationSet Union(DataClassificationSet other)
8386
public override int GetHashCode() => _classifications.GetHashCode();
8487

8588
/// <summary>
86-
/// Compares an object with the current instance to see if they contain the same data classes.
89+
/// Compares an object with the current instance to see if they contain the same classifications.
8790
/// </summary>
8891
/// <param name="obj">The other data classification to compare to.</param>
8992
/// <returns><see langword="true"/> if the two sets contain the same classifications.</returns>
9093
public override bool Equals(object? obj) => Equals(obj as DataClassificationSet);
9194

9295
/// <summary>
93-
/// Compares an object with the current instance to see if they contain the same data classes.
96+
/// Compares an object with the current instance to see if they contain the same classifications.
9497
/// </summary>
9598
/// <param name="other">The other data classification to compare to.</param>
9699
/// <returns><see langword="true"/> if the two sets contain the same classifications.</returns>
97-
public bool Equals(DataClassificationSet? other)
98-
{
99-
if (other == null)
100-
{
101-
return false;
102-
}
103-
104-
return _classifications.SetEquals(other._classifications);
105-
}
100+
public bool Equals(DataClassificationSet? other) => other != null && _classifications.SetEquals(other._classifications);
106101

107102
/// <summary>
108103
/// Returns a string representation of this object.

test/Libraries/Microsoft.Extensions.Compliance.Abstractions.Tests/Classification/DataClassificationTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,8 @@ public static void ToStringOutput()
4545
var dc = new DataClassification(TaxonomyName, Value);
4646

4747
Assert.Equal($"{TaxonomyName}:{Value}", dc.ToString());
48+
49+
Assert.Equal("None", DataClassification.None.ToString());
50+
Assert.Equal("Unknown", DataClassification.Unknown.ToString());
4851
}
4952
}

0 commit comments

Comments
 (0)