Skip to content

Commit

Permalink
Replace invalid sourcegen debug assertion with runtime check (#68828)
Browse files Browse the repository at this point in the history
* Replace AttributeConstructor null assertion with runtime exception

* Remove redundand Json.NET package references

* Revert "Remove redundand Json.NET package references"

This reverts commit 5247c1f.
  • Loading branch information
eiriktsarpalis authored May 5, 2022
1 parent 992b395 commit d66d72d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using Microsoft.CodeAnalysis;
Expand All @@ -15,6 +16,7 @@ internal class ConstructorInfoWrapper : ConstructorInfo

public ConstructorInfoWrapper(IMethodSymbol ctor, MetadataLoadContextInternal metadataLoadContext)
{
Debug.Assert(ctor != null);
_ctor = ctor;
_metadataLoadContext = metadataLoadContext;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ internal class CustomAttributeDataWrapper : CustomAttributeData
{
public CustomAttributeDataWrapper(AttributeData a, MetadataLoadContextInternal metadataLoadContext)
{
Debug.Assert(a.AttributeConstructor != null);
if (a.AttributeConstructor is null)
{
throw new InvalidOperationException();
}

var namedArguments = new List<CustomAttributeNamedArgument>();
foreach (KeyValuePair<string, TypedConstant> na in a.NamedArguments)
Expand Down

0 comments on commit d66d72d

Please sign in to comment.