vovgou / loxodon-framework

An MVVM & Databinding framework that can use C# and Lua to develop games
MIT License
1.9k stars 362 forks source link

建议为每个包添加 csc.rsp #42

Closed MonoLogueChi closed 3 months ago

MonoLogueChi commented 4 months ago

Assets 目录下的 csc.rsp 也会影响到 upm 包安装的插件,可能会导致编译错误。

如使用 C# 11 时会导致 Loxodon Framework TextMeshPro 错误

Library\PackageCache\com.vovgou.loxodon-framework-textformatting@2.6.4\Runtime\Framework\TextFormatting\DateTimeFormat.cs(1177,26): error CS8347: Cannot use a result of 'DateTimeFormat.ExpandPredefinedFormat(ReadOnlySpan<char>, ref DateTime, ref DateTimeFormatInfo, ref TimeSpan)' in this context because it may expose variables referenced by parameter 'dateTime' outside of their declaration scope

Library\PackageCache\com.vovgou.loxodon-framework-textformatting@2.6.4\Runtime\Framework\TextFormatting\DateTimeFormat.cs(1177,61): error CS8166: Cannot return a parameter by reference 'dateTime' because it is not a ref parameter

在 C# 9 或 10 语法是允许的,11中不允许。

示例可见

https://github.com/MonoLogueChi/LoxodonFrameworkCscBug.git

vovgou commented 4 months ago

Assets 目录下的 csc.rsp 也会影响到 upm 包安装的插件,可能会导致编译错误。

如使用 C# 11 时会导致 Loxodon Framework TextMeshPro 错误

Library\PackageCache\com.vovgou.loxodon-framework-textformatting@2.6.4\Runtime\Framework\TextFormatting\DateTimeFormat.cs(1177,26): error CS8347: Cannot use a result of 'DateTimeFormat.ExpandPredefinedFormat(ReadOnlySpan<char>, ref DateTime, ref DateTimeFormatInfo, ref TimeSpan)' in this context because it may expose variables referenced by parameter 'dateTime' outside of their declaration scope

Library\PackageCache\com.vovgou.loxodon-framework-textformatting@2.6.4\Runtime\Framework\TextFormatting\DateTimeFormat.cs(1177,61): error CS8166: Cannot return a parameter by reference 'dateTime' because it is not a ref parameter

在 C# 9 或 10 语法是允许的,11中不允许。

示例可见

https://github.com/MonoLogueChi/LoxodonFrameworkCscBug.git

你使用的Unity版本是哪个版本?我测试一下!

MonoLogueChi commented 4 months ago

你使用的Unity版本是哪个版本?我测试一下!

2022.3.27f1,理论上 2022.3.12 以后的版本都可以

vovgou commented 4 months ago

你使用的Unity版本是哪个版本?我测试一下!

2022.3.27f1,理论上 2022.3.12 以后的版本都可以

我测试了下,我在com.vovgou.loxodon-framework-textformatting@2.6.4中配置csc.rsp 的版本为9.0无效啊。 你可以试试,你将 com.vovgou.loxodon-framework-textformatting@2.6.4从Library/PackageCache 目录下拷贝到 /Packages/ 目录下,变成一个本地的upm包,就可以编辑了。你在里面添加csc.rsp看看,如果有效你可以这样解决这个问题。

MonoLogueChi commented 4 months ago

我测试了下,我在com.vovgou.loxodon-framework-textformatting@2.6.4中配置csc.rsp 的版本为9.0无效啊。 你可以试试,你将 com.vovgou.loxodon-framework-textformatting@2.6.4从Library/PackageCache 目录下拷贝到 /Packages/ 目录下,变成一个本地的upm包,就可以编辑了。你在里面添加csc.rsp看看,如果有效你可以这样解决这个问题。

我已经解决了,解包com.vovgou.loxodon-framework-textformatting@2.6.4,添加csc.rsp后再打包,使用本地包

MonoLogueChi commented 4 months ago

image

MonoLogueChi commented 4 months ago

我把修复后的工程推送到仓库里了,可以看 https://github.com/MonoLogueChi/LoxodonFrameworkCscBug/tree/a1e8b44ba272613c9a7e49e799275ed529c9f5a4