NeVeSpl / NTypewriter

File/code generator using Scriban text templates populated with C# code metadata from Roslyn API.
https://nevespl.github.io/NTypewriter/
MIT License
126 stars 24 forks source link

Unable to build project with SourceGenerator: 'ITypedConstant' could not be found #93

Closed xumix closed 1 year ago

xumix commented 1 year ago

After TypedConstant updates I've got this error during build CS0246: The type or namespace name 'ITypedConstant' could not be found (are you missing a using directive or an assembly reference?). Same file compiles successfully with VS Extension.

Package version: <PackageReference Include="NTypewriter.SourceGenerator" Version="0.2.4" />

Here is the file giving me the error:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

using NTypewriter.CodeModel;
using NTypewriter.CodeModel.Functions;
using NTypewriter.Editor.Config;

namespace Ns
{
    public partial class TplExtensions
    {
// Skipped for brevity
        private static (ITypedConstant Type, ITypedConstant[] Values) GetStatisticsGroups(IEnumValue enumValue)
        {
            var args = enumValue.Attributes.First(f => f.Name == "StatisticsGroup").Arguments;
            var groupType = (ITypedConstant)args.First().Value;

            var values = ((object[])args.Skip(1).First().Value).Cast<ITypedConstant>().ToArray();

            return (groupType, values);
        }
    }
}
NeVeSpl commented 1 year ago

Try version 0.2.5, I have just updated all nugets to make sure that the latest versions are used.

xumix commented 1 year ago

Thanks, it worked!