Skip to content

Commit

Permalink
Prevent NullReferenceException found in telemetry (#2644)
Browse files Browse the repository at this point in the history
We found a NRE in Power Apps telemetry that was happening in the Intellisense code on Power Fx. We don't know exactly the cause, but this change adds a defense-in-depth that will help preventing that.
  • Loading branch information
CarlosFigueiraMSFT committed Sep 19, 2024
1 parent f4232bf commit b87018f
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,14 @@ protected static void TypeMatchPriority(DType type, IList<IntellisenseSuggestion

foreach (var suggestion in suggestions)
{
if (!suggestion.Type.IsUnknown &&
var suggestionType = suggestion.Type;
if (!suggestionType.IsUnknown &&

// Most type acceptance is straightforward
(type.Accepts(suggestion.Type, exact: true, useLegacyDateTimeAccepts: false, usePowerFxV1CompatibilityRules: usePowerFxV1CompatibilityRules) ||
(type.Accepts(suggestionType, exact: true, useLegacyDateTimeAccepts: false, usePowerFxV1CompatibilityRules: usePowerFxV1CompatibilityRules) ||

// Option Set expected types should also include the option set base as a reccomendation.
(suggestion.Type.IsOptionSet && type.Accepts(DType.CreateOptionSetValueType(suggestion.Type.OptionSetInfo), exact: true, useLegacyDateTimeAccepts: false, usePowerFxV1CompatibilityRules: usePowerFxV1CompatibilityRules))))
(suggestionType.IsOptionSet && suggestionType.OptionSetInfo != null && type.Accepts(DType.CreateOptionSetValueType(suggestionType.OptionSetInfo), exact: true, useLegacyDateTimeAccepts: false, usePowerFxV1CompatibilityRules: usePowerFxV1CompatibilityRules))))
{
suggestion.SortPriority++;
}
Expand Down

0 comments on commit b87018f

Please sign in to comment.