Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Bug fix and all unit tests pass
  • Loading branch information
Prashanth Govindarajan committed Sep 24, 2021
commit 4eec26cfcded62d43670516dbefc2e6b0e17ef88
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Collections.Immutable;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using Analyzer.Utilities;
using Analyzer.Utilities.Extensions;
Expand Down Expand Up @@ -255,7 +254,7 @@ public override void Initialize(AnalysisContext context)
}

// Handle symbol operations involving preview features
context.RegisterOperationAction(context => BuildSymbolInformationFromOperations(context, requiresPreviewFeaturesSymbols/*, previewSymbolToMessageAndUrl*/, previewFeaturesAttribute),
context.RegisterOperationAction(context => BuildSymbolInformationFromOperations(context, requiresPreviewFeaturesSymbols, previewFeaturesAttribute),
OperationKind.Invocation,
OperationKind.ObjectCreation,
OperationKind.PropertyReference,
Expand All @@ -271,7 +270,7 @@ public override void Initialize(AnalysisContext context)
);

// Handle preview symbol definitions
context.RegisterSymbolAction(context => AnalyzeSymbol(context, requiresPreviewFeaturesSymbols/*, previewSymbolToMessageAndUrl*/, virtualStaticsInInterfaces, previewFeaturesAttribute), s_symbols);
context.RegisterSymbolAction(context => AnalyzeSymbol(context, requiresPreviewFeaturesSymbols, virtualStaticsInInterfaces, previewFeaturesAttribute), s_symbols);
});
}

Expand Down Expand Up @@ -922,37 +921,6 @@ private bool TypeParametersHavePreviewAttribute(ISymbol namedTypeSymbolOrMethodS
return message;
}

//#pragma warning disable CA1054,CA1055 // url should be of type URI
// private static string? GetMessageAndURLForSymbol(ISymbol symbol,
// INamedTypeSymbol previewFeatureAttribute,
// //ConcurrentDictionary<ISymbol, ValueTuple<string?, string?>> previewSymbolsToMessageAndUrl,
// out string? url)
//#pragma warning restore CA1054,CA1055
// {
// string? message = null;
// url = null;
// if (!previewSymbolsToMessageAndUrl.TryGetValue(symbol, out (string? existingMessage, string? existingUrl) value))
// {
// ImmutableArray<AttributeData> attributes = symbol.GetAttributes();
// foreach (var attribute in attributes)
// {
// if (attribute.AttributeClass.Equals(previewFeatureAttribute))
// {
// message = GetMessageAndURLFromAttributeConstructor(attribute, out url);

// previewSymbolsToMessageAndUrl.GetOrAdd(symbol, new ValueTuple<string?, string?>(message, url));
// }
// }
// }
// else
// {
// message = value.existingMessage;
// url = value.existingUrl;
// }

// return message;
// }

private static void ReportDiagnosticWithCustomMessageIfItExists(OperationAnalysisContext context,
IOperation operation,
ISymbol symbol,
Expand Down Expand Up @@ -1070,6 +1038,7 @@ private static bool SymbolIsAnnotatedAsPreview(ISymbol symbol, ConcurrentDiction
{
string? message = GetMessageAndURLFromAttributeConstructor(attribute, out string? url);
requiresPreviewFeaturesSymbols.GetOrAdd(symbol, new ValueTuple<bool, string?, string?>(true, message, url));
return true;
}
}

Expand All @@ -1083,6 +1052,7 @@ private static bool SymbolIsAnnotatedAsPreview(ISymbol symbol, ConcurrentDiction
{
if (SymbolIsAnnotatedAsPreview(parent, requiresPreviewFeaturesSymbols, previewFeatureAttribute))
{
requiresPreviewFeaturesSymbols.GetOrAdd(symbol, new ValueTuple<bool, string?, string?>(true, null, null));
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,11 @@
<note />
</trans-unit>
<trans-unit id="DerivesFromPreviewClassMessage">
<source>'{0}' derives from preview class '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{0}' derives from preview class '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</target>
<note />
</trans-unit>
<trans-unit id="DerivesFromPreviewClassMessageWithCustomMessagePlaceholder">
<source>'{3}' '{0}' derives from preview class '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{3}' '{0}' derives from preview class '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</target>
<note />
Expand All @@ -348,6 +353,11 @@
<note />
</trans-unit>
<trans-unit id="DetectPreviewFeaturesMessage">
<source>Using '{0}' requires opting into preview features. See {1} for more information.</source>
<target state="new">Using '{0}' requires opting into preview features. See {1} for more information.</target>
<note />
</trans-unit>
<trans-unit id="DetectPreviewFeaturesMessageWithCustomMessagePlaceholder">
<source>{2} Using '{0}' requires opting into preview features. See {1} for more information.</source>
<target state="new">{2} Using '{0}' requires opting into preview features. See {1} for more information.</target>
<note />
Expand Down Expand Up @@ -1103,6 +1113,11 @@
<note />
</trans-unit>
<trans-unit id="FieldIsPreviewTypeMessage">
<source>'{0}''s type contains the preview type '{1}' and requires opting into preview features. See '{2}' for more information.</source>
<target state="new">'{0}''s type contains the preview type '{1}' and requires opting into preview features. See '{2}' for more information.</target>
<note />
</trans-unit>
<trans-unit id="FieldIsPreviewTypeMessageWithCustomMessagePlaceholder">
<source>'{3}' '{0}''s type contains the preview type '{1}' and requires opting into preview features. See '{2}' for more information.</source>
<target state="new">'{3}' '{0}''s type contains the preview type '{1}' and requires opting into preview features. See '{2}' for more information.</target>
<note />
Expand Down Expand Up @@ -1258,11 +1273,21 @@
<note />
</trans-unit>
<trans-unit id="ImplementsPreviewInterfaceMessage">
<source>'{0}' implements the preview interface '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{0}' implements the preview interface '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</target>
<note />
</trans-unit>
<trans-unit id="ImplementsPreviewInterfaceMessageWithCustomMessagePlaceholder">
<source>'{3}' '{0}' implements the preview interface '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{3}' '{0}' implements the preview interface '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</target>
<note />
</trans-unit>
<trans-unit id="ImplementsPreviewMethodMessage">
<source>'{0}' implements the preview method '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{0}' implements the preview method '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</target>
<note />
</trans-unit>
<trans-unit id="ImplementsPreviewMethodMessageWithCustomMessagePlaceholder">
<source>'{3}' '{0}' implements the preview method '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{3}' '{0}' implements the preview method '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</target>
<note />
Expand Down Expand Up @@ -1573,11 +1598,21 @@
<note />
</trans-unit>
<trans-unit id="MethodReturnsPreviewTypeMessage">
<source>'{0}' returns the preview type '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{0}' returns the preview type '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</target>
<note />
</trans-unit>
<trans-unit id="MethodReturnsPreviewTypeMessageWithCustomMessagePlaceholder">
<source>'{3}' '{0}' returns the preview type '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{3}' '{0}' returns the preview type '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</target>
<note />
</trans-unit>
<trans-unit id="MethodUsesPreviewTypeAsParamaterMessage">
<trans-unit id="MethodUsesPreviewTypeAsParameterMessage">
<source>'{0}' takes in a preview parameter of type '{1}' and needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{0}' takes in a preview parameter of type '{1}' and needs to opt into preview features. See '{2}' for more information.</target>
<note />
</trans-unit>
<trans-unit id="MethodUsesPreviewTypeAsParameterMessageWithCustomMessagePlaceholder">
<source>'{3}' '{0}' takes in a preview parameter of type '{1}' and needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{3}' '{0}' takes in a preview parameter of type '{1}' and needs to opt into preview features. See '{2}' for more information.</target>
<note />
Expand Down Expand Up @@ -1673,6 +1708,11 @@
<note />
</trans-unit>
<trans-unit id="OverridesPreviewMethodMessage">
<source>'{0}' overrides the preview method '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{0}' overrides the preview method '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</target>
<note />
</trans-unit>
<trans-unit id="OverridesPreviewMethodMessageWithCustomMessagePlaceholder">
<source>'{3}' '{0}' overrides the preview method '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{3}' '{0}' overrides the preview method '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</target>
<note />
Expand Down Expand Up @@ -2768,6 +2808,11 @@
<note />
</trans-unit>
<trans-unit id="UsesPreviewTypeParameterMessage">
<source>'{0}' uses the preview type '{1}' and needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{0}' uses the preview type '{1}' and needs to opt into preview features. See '{2}' for more information.</target>
<note />
</trans-unit>
<trans-unit id="UsesPreviewTypeParameterMessageWithCustomMessagePlaceholder">
<source>'{3}' '{0}' uses the preview type '{1}' and needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{3}' '{0}' uses the preview type '{1}' and needs to opt into preview features. See '{2}' for more information.</target>
<note />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,11 @@
<note />
</trans-unit>
<trans-unit id="DerivesFromPreviewClassMessage">
<source>'{0}' derives from preview class '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{0}' derives from preview class '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</target>
<note />
</trans-unit>
<trans-unit id="DerivesFromPreviewClassMessageWithCustomMessagePlaceholder">
<source>'{3}' '{0}' derives from preview class '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{3}' '{0}' derives from preview class '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</target>
<note />
Expand All @@ -348,6 +353,11 @@
<note />
</trans-unit>
<trans-unit id="DetectPreviewFeaturesMessage">
<source>Using '{0}' requires opting into preview features. See {1} for more information.</source>
<target state="new">Using '{0}' requires opting into preview features. See {1} for more information.</target>
<note />
</trans-unit>
<trans-unit id="DetectPreviewFeaturesMessageWithCustomMessagePlaceholder">
<source>{2} Using '{0}' requires opting into preview features. See {1} for more information.</source>
<target state="new">{2} Using '{0}' requires opting into preview features. See {1} for more information.</target>
<note />
Expand Down Expand Up @@ -1103,6 +1113,11 @@
<note />
</trans-unit>
<trans-unit id="FieldIsPreviewTypeMessage">
<source>'{0}''s type contains the preview type '{1}' and requires opting into preview features. See '{2}' for more information.</source>
<target state="new">'{0}''s type contains the preview type '{1}' and requires opting into preview features. See '{2}' for more information.</target>
<note />
</trans-unit>
<trans-unit id="FieldIsPreviewTypeMessageWithCustomMessagePlaceholder">
<source>'{3}' '{0}''s type contains the preview type '{1}' and requires opting into preview features. See '{2}' for more information.</source>
<target state="new">'{3}' '{0}''s type contains the preview type '{1}' and requires opting into preview features. See '{2}' for more information.</target>
<note />
Expand Down Expand Up @@ -1258,11 +1273,21 @@
<note />
</trans-unit>
<trans-unit id="ImplementsPreviewInterfaceMessage">
<source>'{0}' implements the preview interface '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{0}' implements the preview interface '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</target>
<note />
</trans-unit>
<trans-unit id="ImplementsPreviewInterfaceMessageWithCustomMessagePlaceholder">
<source>'{3}' '{0}' implements the preview interface '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{3}' '{0}' implements the preview interface '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</target>
<note />
</trans-unit>
<trans-unit id="ImplementsPreviewMethodMessage">
<source>'{0}' implements the preview method '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{0}' implements the preview method '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</target>
<note />
</trans-unit>
<trans-unit id="ImplementsPreviewMethodMessageWithCustomMessagePlaceholder">
<source>'{3}' '{0}' implements the preview method '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{3}' '{0}' implements the preview method '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</target>
<note />
Expand Down Expand Up @@ -1573,11 +1598,21 @@
<note />
</trans-unit>
<trans-unit id="MethodReturnsPreviewTypeMessage">
<source>'{0}' returns the preview type '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{0}' returns the preview type '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</target>
<note />
</trans-unit>
<trans-unit id="MethodReturnsPreviewTypeMessageWithCustomMessagePlaceholder">
<source>'{3}' '{0}' returns the preview type '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{3}' '{0}' returns the preview type '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</target>
<note />
</trans-unit>
<trans-unit id="MethodUsesPreviewTypeAsParamaterMessage">
<trans-unit id="MethodUsesPreviewTypeAsParameterMessage">
<source>'{0}' takes in a preview parameter of type '{1}' and needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{0}' takes in a preview parameter of type '{1}' and needs to opt into preview features. See '{2}' for more information.</target>
<note />
</trans-unit>
<trans-unit id="MethodUsesPreviewTypeAsParameterMessageWithCustomMessagePlaceholder">
<source>'{3}' '{0}' takes in a preview parameter of type '{1}' and needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{3}' '{0}' takes in a preview parameter of type '{1}' and needs to opt into preview features. See '{2}' for more information.</target>
<note />
Expand Down Expand Up @@ -1673,6 +1708,11 @@
<note />
</trans-unit>
<trans-unit id="OverridesPreviewMethodMessage">
<source>'{0}' overrides the preview method '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{0}' overrides the preview method '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</target>
<note />
</trans-unit>
<trans-unit id="OverridesPreviewMethodMessageWithCustomMessagePlaceholder">
<source>'{3}' '{0}' overrides the preview method '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{3}' '{0}' overrides the preview method '{1}' and therefore needs to opt into preview features. See '{2}' for more information.</target>
<note />
Expand Down Expand Up @@ -2768,6 +2808,11 @@
<note />
</trans-unit>
<trans-unit id="UsesPreviewTypeParameterMessage">
<source>'{0}' uses the preview type '{1}' and needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{0}' uses the preview type '{1}' and needs to opt into preview features. See '{2}' for more information.</target>
<note />
</trans-unit>
<trans-unit id="UsesPreviewTypeParameterMessageWithCustomMessagePlaceholder">
<source>'{3}' '{0}' uses the preview type '{1}' and needs to opt into preview features. See '{2}' for more information.</source>
<target state="new">'{3}' '{0}' uses the preview type '{1}' and needs to opt into preview features. See '{2}' for more information.</target>
<note />
Expand Down
Loading