Re: Unity3D autogenerate .g.cs
Posted: 24 Jun 2019, 09:18
The feature "Skip if x:Class does not exist" doesn't work properly.
For example, parse NocturnalStyle.xaml (theme provided in noesis native SDK) will cause a .g.xaml get generated, which causes compile error.
It's a ResourceDictionary so it doesn't have "FindName" method. Also the generated code will have an empty namespace statement which is illegal.
Further investment found out the problem to be in "string GetCsText()" method. Which I made another small modification:
It works again now. But this is not the final solution, since in WPF, ResourceDictionary can have x:Class, just without the FindName() method. The method does exist but it's an empty implementation (hoory to open source!). So I think that means you can hook events, but not x:Name.
I will try to fix it after digging a little deeper.
For example, parse NocturnalStyle.xaml (theme provided in noesis native SDK) will cause a .g.xaml get generated, which causes compile error.
It's a ResourceDictionary so it doesn't have "FindName" method. Also the generated code will have an empty namespace statement which is illegal.
Further investment found out the problem to be in "string GetCsText()" method. Which I made another small modification:
Code: Select all
string GetCsText()
{
var namespaceString = GetNamespaceString();
var className = GetClassNameString();
var hasCodeBehind = className != null && namespaceString != null;
if (!hasCodeBehind) {
return null;
}
...
I will try to fix it after digging a little deeper.