Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

提供构建时的自动生成代码 #32

Open
lindexi opened this issue Sep 6, 2021 · 0 comments
Open

提供构建时的自动生成代码 #32

lindexi opened this issue Sep 6, 2021 · 0 comments

Comments

@lindexi
Copy link
Member

lindexi commented Sep 6, 2021

不同的是生成的代码将会被加入版本管理

        [dotnetCampus.Telescope.GenerateCodeHere] // 将在此生成代码
        [GeneratedCode("SourceTelescope", "1.0.0")]
        internal AttributedTypeMetadata<TBaseClass, TAttribute>[] GetXxx()
        {
            // 此方法体的所有代码,将会在下次构建时被替换
            return new AttributedTypeMetadata[]
            {
               
            };
        }

以上的 GenerateCodeHere 特性和 AttributedTypeMetadata 返回值由 SourceYard 技术管理,返回值要求一定是 internal 类型

将会在构建时,替换掉 GetXxx 方法里面的所有代码,每次构建分析不同点,决定是否替换。另外还可以在某些特殊需求时,干掉 GenerateCodeHere 特性,换为手工写代码

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant