Browse Source

Merge branch 'master' into itemspanel-no-logical-children

pull/10454/head
Steven Kirk 4 years ago
committed by GitHub
parent
commit
908a87de92
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      packages/Avalonia/Avalonia.props
  2. 13
      src/tools/PublicAnalyzers/AvaloniaPropertyAnalyzer.CompileAnalyzer.cs

5
packages/Avalonia/Avalonia.props

@ -6,4 +6,9 @@
<AvaloniaUseExternalMSBuild>false</AvaloniaUseExternalMSBuild>
</PropertyGroup>
<Import Project="$(MSBuildThisFileDirectory)\AvaloniaBuildTasks.props"/>
<!-- Allow loading the AvaloniaVS extension when referencing the Avalonia nuget package -->
<ItemGroup>
<ProjectCapability Include="Avalonia"/>
</ItemGroup>
</Project>

13
src/tools/PublicAnalyzers/AvaloniaPropertyAnalyzer.CompileAnalyzer.cs

@ -396,7 +396,7 @@ public partial class AvaloniaPropertyAnalyzer
hostTypeRef = new(_avaloniaObjectType, Location.None); // assume that an attached property applies everywhere until we find its registration
}
var result = new AvaloniaPropertyDescription(inferredName, propertyType, valueType) { HostType = hostTypeRef };
var result = new AvaloniaPropertyDescription(inferredName, propertyType, valueType) { HostType = hostTypeRef };
// assume that the property is owned by its containing type at the point of assignment, until we find its registration
result.SetAssignment(s, new(s.ContainingType, Location.None));
@ -570,7 +570,7 @@ public partial class AvaloniaPropertyAnalyzer
if (_allGetSetMethods.Contains(originalMethod))
{
if (invocation.Instance is IInstanceReferenceOperation { ReferenceKind: InstanceReferenceKind.ContainingTypeInstance } &&
if (invocation.Instance is IInstanceReferenceOperation { ReferenceKind: InstanceReferenceKind.ContainingTypeInstance } &&
GetReferencedProperty(invocation.Arguments[0]) is { } refProp &&
refProp.description.AssignedTo.TryGetValue(refProp.storageSymbol, out var ownerType) &&
!DerivesFrom(context.ContainingSymbol.ContainingType, ownerType.Type) &&
@ -694,9 +694,14 @@ public partial class AvaloniaPropertyAnalyzer
void VerifyAccessor(IMethodSymbol? method, string verb, string methodName)
{
if (method == null)
if (method is null)
{
context.ReportDiagnostic(Diagnostic.Create(MissingAccessor, property.Locations[0], avaloniaPropertyStorage, verb, methodName));
if (avaloniaPropertyStorage.DeclaredAccessibility == Accessibility.Public ||
(avaloniaPropertyStorage.DeclaredAccessibility == Accessibility.Protected
&& avaloniaPropertyStorage.ContainingSymbol.DeclaredAccessibility == Accessibility.Public))
{
context.ReportDiagnostic(Diagnostic.Create(MissingAccessor, property.Locations[0], avaloniaPropertyStorage, verb, methodName));
}
}
else if (method.DeclaredAccessibility != avaloniaPropertyStorage.DeclaredAccessibility && method.DeclaredAccessibility != property.DeclaredAccessibility)
{

Loading…
Cancel
Save