Skip to content

Commit

Permalink
Apply code style fixes from analyzers
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Sep 30, 2024
1 parent bdf15ed commit 5fd8e84
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public static HRESULT SetTransformMapperImpl(IUnknown* effect, byte* data, uint
/// <param name="dataSize">The number of bytes in the property to retrieve.</param>
/// <param name="actualSize">A optional pointer to a variable that stores the actual number of bytes retrieved on the property.</param>
/// <returns>The <see cref="HRESULT"/> for the operation.</returns>
private int GetResourceTextureManagerAtIndex(int index, byte* data, uint dataSize, uint* actualSize)
private readonly int GetResourceTextureManagerAtIndex(int index, byte* data, uint dataSize, uint* actualSize)
{
try
{
Expand Down Expand Up @@ -210,22 +210,23 @@ private int SetResourceTextureManagerAtIndex(int index, byte* data, uint dataSiz
// Check that the input object implements ID2D1ResourceTextureManager
unknown.CopyTo(resourceTextureManager.GetAddressOf()).Assert();

using ComPtr<ID2D1ResourceTextureManagerInternal> resourceTextureManagerInternal = default;

// Then, also check that it implements ID2D1ResourceTextureManagerInternal
unknown.CopyTo(resourceTextureManagerInternal.GetAddressOf()).Assert();

// Initialize the resource texture manager, if an effect context is available
if (this.d2D1EffectContext.Get() is not null)
using (ComPtr<ID2D1ResourceTextureManagerInternal> resourceTextureManagerInternal = default)
{
uint dimensions = (uint)GetGlobals().ResourceTextureDescriptions.Span[index].Dimensions;

// ID2D1ResourceTextureManager::Initialize should generally return either S_OK for first
// initialization, S_FALSE if an ID2D1EffectContext is already present (which is allowed, to
// enable sharing resource texture managers across different source textures and effects), or
// E_INVALIDARG if the manager has already been initialized through the public interface,
// and the stored dimensions for that don't match the ones for this resource texture index.
resourceTextureManagerInternal.Get()->Initialize(this.d2D1EffectContext.Get(), &dimensions).Assert();
// Then, also check that it implements ID2D1ResourceTextureManagerInternal
unknown.CopyTo(resourceTextureManagerInternal.GetAddressOf()).Assert();

// Initialize the resource texture manager, if an effect context is available
if (this.d2D1EffectContext.Get() is not null)
{
uint dimensions = (uint)GetGlobals().ResourceTextureDescriptions.Span[index].Dimensions;

// ID2D1ResourceTextureManager::Initialize should generally return either S_OK for first
// initialization, S_FALSE if an ID2D1EffectContext is already present (which is allowed, to
// enable sharing resource texture managers across different source textures and effects), or
// E_INVALIDARG if the manager has already been initialized through the public interface,
// and the stored dimensions for that don't match the ones for this resource texture index.
resourceTextureManagerInternal.Get()->Initialize(this.d2D1EffectContext.Get(), &dimensions).Assert();
}
}

// Store the resource texture manager into the buffer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private uint Release()
/// </summary>
/// <returns>The <see cref="Globals"/> instance for the current effect.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private Globals GetGlobals()
private readonly Globals GetGlobals()
{
return Unsafe.As<Globals>(this.globalsHandle.Target!);
}
Expand Down
6 changes: 3 additions & 3 deletions src/ComputeSharp.SourceGeneration/Helpers/HashCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Runtime.InteropServices;
using System.Security.Cryptography;

#pragma warning disable CS0809, IDE0009, IDE1006, IDE0048
#pragma warning disable CS0809, IDE0009, IDE1006, IDE0048, CA1065

namespace System;

Expand Down Expand Up @@ -274,15 +274,15 @@ public static int Combine<T1, T2, T3, T4, T5, T6, T7>(T1 value1, T2 value2, T3 v
/// <typeparam name="T5">The type of the fifth value to combine into the hash code.</typeparam>
/// <typeparam name="T6">The type of the sixth value to combine into the hash code.</typeparam>
/// <typeparam name="T7">The type of the seventh value to combine into the hash code.</typeparam>
/// <typeparam name="T8">The type of the eigth value to combine into the hash code.</typeparam>
/// <typeparam name="T8">The type of the eighth value to combine into the hash code.</typeparam>
/// <param name="value1">The first value to combine into the hash code.</param>
/// <param name="value2">The second value to combine into the hash code.</param>
/// <param name="value3">The third value to combine into the hash code.</param>
/// <param name="value4">The fourth value to combine into the hash code.</param>
/// <param name="value5">The fifth value to combine into the hash code.</param>
/// <param name="value6">The sixth value to combine into the hash code.</param>
/// <param name="value7">The seventh value to combine into the hash code.</param>
/// <param name="value8">The eigth value to combine into the hash code.</param>
/// <param name="value8">The eighth value to combine into the hash code.</param>
/// <returns>The hash code that represents the values.</returns>
public static int Combine<T1, T2, T3, T4, T5, T6, T7, T8>(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static void Create(IBufferWriter<byte> writer, IBufferWriterWrapper** str
/// </summary>
/// <returns>The captured <see cref="IBufferWriter{T}"/> instance</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private IBufferWriter<byte> GetWriter()
private readonly IBufferWriter<byte> GetWriter()
{
return Unsafe.As<IBufferWriter<byte>>(this.writerHandle.Target!);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static void Create(Stream stream, IStreamWrapper** streamWrapper)
/// </summary>
/// <returns>The captured <see cref="Stream"/> instance</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private Stream GetStream()
private readonly Stream GetStream()
{
return Unsafe.As<Stream>(this.streamHandle.Target!);
}
Expand Down

0 comments on commit 5fd8e84

Please sign in to comment.