Skip to content

Commit

Permalink
Merge branch 'NetStandard' of https://github.com/vchelaru/FlatRedBall
Browse files Browse the repository at this point in the history
…into NetStandard
  • Loading branch information
vchelaru committed Feb 12, 2024
2 parents 7603846 + 2b29b6e commit b24fd1d
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,13 @@ private void CreateDerivedVariantClass(IElement element, string typeOrVariant, I
block.Line($"GetFile = {QualifiedTypeName(derivedElement)}.GetFile,");
block.Line($"LoadStaticContent = {QualifiedTypeName(derivedElement)}.LoadStaticContent,");

foreach (var variable in element.CustomVariables.Where(item => item.SetByDerived
foreach (var variable in element.CustomVariables
//.Where(item => item.SetByDerived
// Why don't we generate is shared? Now that we can inherit shared variables, let's do it so that the user can specify variables for the type, like a Display Name
//&& !item.IsShared
))
)
{
if (!ShouldSkip(variable))
if (!ShouldSkipVariantField(variable))
{
var matchingVariable = derivedElement.CustomVariables.FirstOrDefault(item => item.Name == variable.Name) ?? variable;
if (matchingVariable.DefaultValue != null)
Expand Down Expand Up @@ -134,8 +135,15 @@ private static void FillCreateNew(string methodHeaderParameters, string innerCal

foreach(var variable in element.CustomVariables)
{
var shouldGenerateVariable =
!ShouldSkipVariantField(variable) &&
variable.IsShared == false &&
variable.Name != "X" &&
variable.Name != "Y" &&
variable.Name != "Z";

// don't assign position values - those aget set in the Create New method:
if(variable.Name != "X" && variable.Name != "Y" && variable.Name != "Z")
if(shouldGenerateVariable)
{
var rightSide = $"this.{variable.Name}";
if (IsTypeFileType(variable.Type))
Expand Down Expand Up @@ -182,7 +190,7 @@ private void CreateVariableFields(IElement element, ICodeBlock classBlock)
CustomVariable tempVariable = new CustomVariable();
foreach (var variable in element.CustomVariables.Where(item => item.SetByDerived))
{
if (!ShouldSkip(variable))
if (!ShouldSkipVariantField(variable))
{
// We want this to not be a property, and to not have any source class type so that it generates
// as a simple field
Expand All @@ -209,8 +217,12 @@ private string ConvertFileToType(string type)
return IsTypeFileType(type) ? "string" : type;
}

bool ShouldSkip(CustomVariable customVariable)
static bool ShouldSkipVariantField(CustomVariable customVariable)
{
if(customVariable.SetByDerived == false)
{
return true;
}
var type = customVariable.Type;
switch (type)
{
Expand Down

0 comments on commit b24fd1d

Please sign in to comment.