Skip to content

Commit

Permalink
#87 - AttributeArgument with null value, TypedConstant ToString throw…
Browse files Browse the repository at this point in the history
…s NullReferenceException
  • Loading branch information
NeVeSpl committed Aug 1, 2023
1 parent 23a40b9 commit bf8573c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion NTypewriter.CodeModel.Roslyn/TypedConstant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static object Create(Microsoft.CodeAnalysis.TypedConstant typedConstant)

public override string ToString()
{
string valueAsString = typedConstant.Type.GetDefaultConstantValueAsString(typedConstant.Value).ToString();
string valueAsString = typedConstant.Type.GetDefaultConstantValueAsString(typedConstant.Value)?.ToString();

return valueAsString;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
AuctionContractCount44
NullOne
[StatisticsGroup]
name : object
type : object
value :
-------------
AuctionContractCount44
[StatisticsGroup]
name : type
type : StatisticsGroupTypeEnum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
namespace NTypewriter.Tests.CodeModel
{
public enum RegionStatTypeEnum
{
{
[StatisticsGroup(null)]
NullOne,

[StatisticsGroup(StatisticsGroupTypeEnum.Restriction, FederalLawEnum.FZ44)]
AuctionContractCount44,

Expand All @@ -19,6 +22,11 @@ public enum RegionStatTypeEnum
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true)]
public class StatisticsGroupAttribute : Attribute
{
public StatisticsGroupAttribute(object @object)
{

}

public StatisticsGroupAttribute(StatisticsGroupTypeEnum type, params object[] values)
{

Expand Down

0 comments on commit bf8573c

Please sign in to comment.