Skip to content

Commit

Permalink
Code clean: 1) Remove the backup files, 2) Remve the .NETCore related…
Browse files Browse the repository at this point in the history
… 3) Add 'Microsoft.CodeAnalysis.NetAnalyzers' for code analysis
  • Loading branch information
xuzhg committed Dec 10, 2024
1 parent 5e715a2 commit 25b6e8e
Show file tree
Hide file tree
Showing 19 changed files with 24 additions and 2,601 deletions.
4 changes: 4 additions & 0 deletions src/Microsoft.OData.Client/Microsoft.OData.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public TextWriter StartTextWriterValueScope(string contentType)
WriteItemWithSeparatorIfNeeded();

this.currentTextWriterContentType = contentType;
this.isWritingJson = this.CheckIfWritingJson(this.currentTextWriterContentType);
this.isWritingJson = CheckIfWritingJson(this.currentTextWriterContentType);

// We don't perform escaping when the content type is not JSON
// since we assume the input to be already a valid JSON with all escaping handled by the caller.
Expand Down Expand Up @@ -128,7 +128,7 @@ public async Task EndTextWriterValueScopeAsync()
/// Checks whether the current TextWriter is writing JSON
/// </summary>
/// <returns></returns>
private bool CheckIfWritingJson(string currentContentType)
private static bool CheckIfWritingJson(string currentContentType)
{
return string.IsNullOrEmpty(currentContentType) || currentContentType.StartsWith(MimeConstants.MimeApplicationJson, StringComparison.Ordinal);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OData.Core/Json/TranscodingWriteStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ async ValueTask WriteAsyncCore(ReadOnlyMemory<byte> remainingOuterEncodedBytes,
public override void WriteByte(byte value)
=> Write(new ReadOnlySpan<byte>(new byte[] { value }));

private static void ValidateBufferArguments(byte[] buffer, int offset, int size)
private static new void ValidateBufferArguments(byte[] buffer, int offset, int size)
{
if (buffer == null)
{
Expand Down
4 changes: 4 additions & 0 deletions src/Microsoft.OData.Core/Microsoft.OData.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.OData.Core/ShippingAssemblyAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,4 @@
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Microsoft.Test.Taupo.OData" + AssemblyRef.TestPublicKey)]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Microsoft.OData.Core.Tests" + AssemblyRef.TestPublicKey)]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Microsoft.OData.Client.Tests" + AssemblyRef.TestPublicKey)]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Microsoft.Test.OData.DependencyInjection.NetCore" + AssemblyRef.TestPublicKey)]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Microsoft.OData.Core.Tests.NetCore" + AssemblyRef.TestPublicKey)]
#pragma warning restore 436
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override bool Equals(PathSegmentToken first, PathSegmentToken second)
return false;
}

return this.ToHashableString(first) == this.ToHashableString(second);
return ToHashableString(first) == ToHashableString(second);
}

/// <summary>
Expand All @@ -49,22 +49,22 @@ public override int GetHashCode(PathSegmentToken path)
return 0;
}

return this.ToHashableString(path).GetHashCode(StringComparison.Ordinal);
return ToHashableString(path).GetHashCode(StringComparison.Ordinal);
}

/// <summary>
/// Converts the token to a string that is sufficiently unique to be hashed or compared.
/// </summary>
/// <param name="token">The path token to convert to a string.</param>
/// <returns>A string representing the path.</returns>
private string ToHashableString(PathSegmentToken token)
private static string ToHashableString(PathSegmentToken token)
{
if (token.NextToken == null)
{
return token.Identifier;
}

return token.Identifier + "/" + this.ToHashableString(token.NextToken);
return token.Identifier + "/" + ToHashableString(token.NextToken);
}
}
}
4 changes: 4 additions & 0 deletions src/Microsoft.OData.Edm/Microsoft.OData.Edm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
6 changes: 0 additions & 6 deletions src/Microsoft.OData.Edm/ShippingAssemblyAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,3 @@
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("EdmLibTests" + AssemblyRef.TestPublicKey)]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("EdmLibTests.SL" + AssemblyRef.TestPublicKey)]
#pragma warning restore 436

// .NET Core
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Microsoft.OData.TestCommon.NetCore" + AssemblyRef.TestPublicKey)]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Microsoft.OData.Edm.Tests.NetCore" + AssemblyRef.TestPublicKey)]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Microsoft.OData.Core.Tests.NetCore" + AssemblyRef.TestPublicKey)]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Microsoft.Spatial.Tests.NetCore" + AssemblyRef.TestPublicKey)]
8 changes: 1 addition & 7 deletions src/Microsoft.Spatial/InternalsVisibleTo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,4 @@
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Microsoft.OData.Service.Test.Client.TDDUnitTests" + AssemblyRef.TestPublicKey)]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("AstoriaUnitTests.TDDUnitTests" + AssemblyRef.TestPublicKey)]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Microsoft.Spatial.TDDUnitTests" + AssemblyRef.TestPublicKey)]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Microsoft.Spatial.Tests" + AssemblyRef.TestPublicKey)]

// .NET Core
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Microsoft.OData.TestCommon.NetCore" + AssemblyRef.TestPublicKey)]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Microsoft.OData.Edm.Tests.NetCore" + AssemblyRef.TestPublicKey)]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Microsoft.OData.Core.Tests.NetCore" + AssemblyRef.TestPublicKey)]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Microsoft.Spatial.Tests.NetCore" + AssemblyRef.TestPublicKey)]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Microsoft.Spatial.Tests" + AssemblyRef.TestPublicKey)]
4 changes: 4 additions & 0 deletions src/Microsoft.Spatial/Microsoft.Spatial.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Loading

0 comments on commit 25b6e8e

Please sign in to comment.