Skip to content

Commit

Permalink
CA1416 handle call-site empty sets causing warnings when TFM attribut…
Browse files Browse the repository at this point in the history
…es applied (#4740)

* Handle call site empty sets causing warnings when TFM attributes applied
  • Loading branch information
buyaa-n authored Feb 1, 2021
1 parent ce5008a commit e12c29c
Show file tree
Hide file tree
Showing 4 changed files with 562 additions and 206 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using Analyzer.Utilities;

namespace Microsoft.NetCore.Analyzers.InteropServices
{
Expand All @@ -22,14 +23,28 @@ public sealed partial class PlatformCompatibilityAnalyzer
/// - UnsupportedFirst - keeps the lowest version of [UnsupportedOSPlatform] attribute found
/// - UnsupportedSecond - keeps the second lowest version of [UnsupportedOSPlatform] attribute found
/// </summary>
private class PlatformAttributes
private class Versions
{
public Version? SupportedFirst { get; set; }
public Version? SupportedSecond { get; set; }
public Version? UnsupportedFirst { get; set; }
public Version? UnsupportedSecond { get; set; }
public bool HasAttribute() => SupportedFirst != null || UnsupportedFirst != null ||
public bool IsSet() => SupportedFirst != null || UnsupportedFirst != null ||
SupportedSecond != null || UnsupportedSecond != null;
}

private sealed class PlatformAttributes
{
public PlatformAttributes() { }

public PlatformAttributes(Callsite callsite, SmallDictionary<string, Versions> platforms)
{
Callsite = callsite;
Platforms = platforms;
}

public SmallDictionary<string, Versions>? Platforms { get; set; }
public Callsite Callsite { get; set; }
}
}
}
Loading

0 comments on commit e12c29c

Please sign in to comment.