Skip to content

Commit

Permalink
Fixes markup warnings (#6525)
Browse files Browse the repository at this point in the history
* fixes: suppress warning  CS0659  Type overrides Object.Equals(object o) but does not override Object.GetHashCode()

* fixes: Warning CS0108 'AvaloniaXamlIlCompiler._configuration' hides inherited member 'XamlCompiler<IXamlILEmitter, XamlILNodeEmitResult>._configuration'. Use the new keyword if hiding was intended.

* fixes: Warning CS8765 Nullability of type of parameter 'obj' doesn't match overridden member.
  • Loading branch information
workgroupengineering authored Sep 30, 2021
1 parent d95f489 commit d0401bd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Avalonia.Visuals/Vector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public bool NearlyEquals(Vector other)
MathUtilities.AreClose(_y, other._y);
}

public override bool Equals(object obj) => obj is Vector other && Equals(other);
public override bool Equals(object? obj) => obj is Vector other && Equals(other);

public override int GetHashCode()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,13 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions
{
class AvaloniaXamlIlCompiler : XamlILCompiler
{
private readonly TransformerConfiguration _configuration;
private readonly IXamlType _contextType;
private readonly AvaloniaXamlIlDesignPropertiesTransformer _designTransformer;
private readonly AvaloniaBindingExtensionTransformer _bindingTransformer;

private AvaloniaXamlIlCompiler(TransformerConfiguration configuration, XamlLanguageEmitMappings<IXamlILEmitter, XamlILNodeEmitResult> emitMappings)
: base(configuration, emitMappings, true)
{
_configuration = configuration;

void InsertAfter<T>(params IXamlAstTransformer[] t)
=> Transformers.InsertRange(Transformers.FindIndex(x => x is T) + 1, t);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ public interface ISyntax

}

// Don't need to override GetHashCode as the ISyntax objects will not be stored in a hash; the
// only reason they have overridden Equals methods is for unit testing.
#pragma warning disable CS0659 // Type overrides Object.Equals(object o) but does not override Object.GetHashCode()
public class PropertySyntax : ISyntax
{
public string Name { get; set; } = string.Empty;
Expand All @@ -205,7 +208,7 @@ public override bool Equals(object? obj)
&& other.TypeName == TypeName
&& other.TypeNamespace == TypeNamespace;
}

public class ChildTraversalSyntax : ISyntax
{
public static ChildTraversalSyntax Instance { get; } = new ChildTraversalSyntax();
Expand All @@ -231,5 +234,6 @@ public override bool Equals(object? obj)
&& other.TypeName == TypeName
&& other.TypeNamespace == TypeNamespace;
}
#pragma warning restore CS0659 // Type overrides Object.Equals(object o) but does not override Object.GetHashCode()
}
}

0 comments on commit d0401bd

Please sign in to comment.