Skip to content

Commit

Permalink
Started work on reporting syntax version on .dll
Browse files Browse the repository at this point in the history
Fixed text above search bar.
  • Loading branch information
vchelaru committed Jan 20, 2024
1 parent 5ace47c commit 182546d
Show file tree
Hide file tree
Showing 17 changed files with 183 additions and 84 deletions.
7 changes: 7 additions & 0 deletions Engines/FlatRedBallXNA/FlatRedBall/FlatRedBallServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,15 @@ public object GetService(Type serviceType)
#endregion
}

public class SyntaxVersionAttribute : Attribute
{
public int Version = 51;
}

public static partial class FlatRedBallServices
{
internal static SingleThreadSynchronizationContext singleThreadSynchronizationContext;

#region Fields

static List<IManager> mManagers = new List<IManager>();
Expand Down Expand Up @@ -164,6 +170,7 @@ public static partial class FlatRedBallServices
private static SpriteBatch _loadingScreenSpriteBatch = null;
private static Rectangle _sourceRect;


#endregion

#region Properties
Expand Down
2 changes: 2 additions & 0 deletions FRBDK/Glue/Glue/GlueFormsCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@
<!--<ExcludeAssets>runtime</ExcludeAssets>-->
</PackageReference>

<PackageReference Include="Mono.Cecil" Version="0.11.5" />

<PackageReference Include="NAudio" Version="2.1.0" />
<PackageReference Include="NAudio.Core" Version="2.1.0" />
<PackageReference Include="NAudio.Vorbis" Version="1.5.0" />
Expand Down
2 changes: 1 addition & 1 deletion FRBDK/Glue/Glue/IO/BuiltFileCopier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ bool NeedsCopiedXnbs(ProjectBase project)
project is Windows8MonoGameProject ||
project is AndroidProject ||
project is UwpProject ||
project is DesktopGlProject;
project is MonoGameDesktopGlBaseProject;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public bool GetIfHandledByContentPipelinePlugin(VisualStudioProject targetProjec
extension == "fbx" ||
(extension == "png" && rfs != null && rfs.UseContentPipeline);
}
else if(targetProject is DesktopGlLinuxProject || targetProject is DesktopGlProject)
else if(targetProject is DesktopGlLinuxProject || targetProject is MonoGameDesktopGlBaseProject)
{
// DesktopGL can support other audio engines like NAudio. I don't know if other
// platforms will get this, but we may want to expand this at some point in the future...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ public bool IsReferencingFrbSource
}
else
{
if(CurrentMainProject is DesktopGlProject)
if(CurrentMainProject is MonoGameDesktopGlBaseProject)
{
// todo - handle different types of projects
string projectReferenceName;
Expand Down
2 changes: 2 additions & 0 deletions FRBDK/Glue/Glue/SaveClasses/GlueProjectSave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ public enum GluxVersions
// Technically this isn't referencing GumCommon project, but it's referencing code from GumCommon
GumCommonCodeReferencing = 50,
GumTextSupportsBbCode = 51

// Stop! If adding an entry here, modify SyntaxVersionAttribute.Version
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace FlatRedBall.Glue.VSHelpers.Projects
{
public class DesktopGlLinuxProject : DesktopGlProject
public class DesktopGlLinuxProject : MonoGameDesktopGlNetFrameworkProject
{

public override string ProjectId { get { return "DesktopGlLinux"; } }
Expand Down
71 changes: 0 additions & 71 deletions FRBDK/Glue/Glue/VSHelpers/Projects/DesktopGlProject.cs

This file was deleted.

42 changes: 42 additions & 0 deletions FRBDK/Glue/Glue/VSHelpers/Projects/MonoGameDesktopGlBaseProject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Microsoft.Build.Evaluation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FlatRedBall.Glue.VSHelpers.Projects
{
public abstract class MonoGameDesktopGlBaseProject : VisualStudioProject
{
public override string ProjectId { get { return "DesktopGl"; } }
public override string PrecompilerDirective { get { return "DESKTOP_GL"; } }

public override bool AllowContentCompile => false;

public override string ContentDirectory => "Content/";


public override string FolderName => "DesktopGl";

protected override bool NeedToSaveContentProject => false;

public MonoGameDesktopGlBaseProject(Project project) : base(project)
{
}

public override string ProcessInclude(string path)
{
var returnValue = base.ProcessInclude(path);

return returnValue.ToLowerInvariant();
}

public override string ProcessLink(string path)
{
var returnValue = base.ProcessLink(path);
// Linux is case-sensitive
return returnValue.ToLowerInvariant();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Build.Evaluation;

namespace FlatRedBall.Glue.VSHelpers.Projects
{
public class MonoGameDesktopGlNetCoreProject : MonoGameDesktopGlBaseProject
{

const string FlatRedBallDll = "FlatRedBallDesktopGL.dll";

public override List<string> LibraryDlls
{
get
{
return new List<string>
{
FlatRedBallDll
};
}
}

public override string NeededVisualStudioVersion
{
get { return "14.0"; }

}

public MonoGameDesktopGlNetCoreProject(Project project) : base(project)
{
}



}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Build.Evaluation;

namespace FlatRedBall.Glue.VSHelpers.Projects
{
public class MonoGameDesktopGlNetFrameworkProject : MonoGameDesktopGlBaseProject
{

const string FlatRedBallDll = "FlatRedBallDesktopGL.dll";

public override List<string> LibraryDlls
{
get
{
return new List<string>
{
FlatRedBallDll
};
}
}

public override string NeededVisualStudioVersion
{
get { return "14.0"; }

}

public MonoGameDesktopGlNetFrameworkProject(Project project) : base(project)
{
}



}
}
38 changes: 34 additions & 4 deletions FRBDK/Glue/Glue/VSHelpers/Projects/ProjectCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,18 +235,42 @@ class PreprocessorAndFunc
{
public string Preprocessor;
public Func<ProjectBase> Func;
public Version MinVersion;

public PreprocessorAndFunc(string preprocessor, Func<ProjectBase> func)
{
Preprocessor = preprocessor;
Func = func;
}

public PreprocessorAndFunc(string preprocessor, Version minVersion, Func<ProjectBase> func)
{
Preprocessor = preprocessor;
Func = func;
MinVersion = minVersion;
}
}


private static ProjectBase TryGetProjectTypeFromDefineConstants(Project coreVisualStudioProject, out string message)
{
string preProcessorConstants = GetPreProcessorConstantsFromProject(coreVisualStudioProject);
var frameworkProperty = coreVisualStudioProject.AllEvaluatedProperties.FirstOrDefault(item => item.Name == "TargetFrameworkVersion");
var dotNetVersionString = frameworkProperty?.EvaluatedValue;
Version version = null;
if (dotNetVersionString?.StartsWith("v") == true)
{
var afterV = dotNetVersionString.Substring(1);
try
{
version = new Version(afterV);
}
catch
{

}

}

//string sasfd = ProjectManager.LibrariesPath;

Expand All @@ -272,7 +296,8 @@ private static ProjectBase TryGetProjectTypeFromDefineConstants(Project coreVisu
loadCalls.Add(new PreprocessorAndFunc("ANDROID", () => new AndroidProject(coreVisualStudioProject)));
loadCalls.Add(new PreprocessorAndFunc("IOS", () => new IosMonogameProject(coreVisualStudioProject)));
loadCalls.Add(new PreprocessorAndFunc("UWP", () => new UwpProject(coreVisualStudioProject)));
loadCalls.Add(new PreprocessorAndFunc("DESKTOP_GL", () => new DesktopGlProject(coreVisualStudioProject)));
loadCalls.Add(new PreprocessorAndFunc("DESKTOP_GL", new Version(6,0), () => new MonoGameDesktopGlNetCoreProject(coreVisualStudioProject)));
loadCalls.Add(new PreprocessorAndFunc("DESKTOP_GL", () => new MonoGameDesktopGlNetFrameworkProject(coreVisualStudioProject)));
loadCalls.Add(new PreprocessorAndFunc("FNA", () => new FnaDesktopProject(coreVisualStudioProject)));
// Do XNA_4 last, since every
// other project type has this
Expand All @@ -285,7 +310,12 @@ private static ProjectBase TryGetProjectTypeFromDefineConstants(Project coreVisu

foreach (var call in loadCalls)
{
if(preProcessorConstants?.Contains(call.Preprocessor) == true)
var matchesPreprocessor =
preProcessorConstants?.Contains(call.Preprocessor) == true;

var matchesOrExceedsVersion = call.MinVersion == null || version >= call.MinVersion;

if (matchesPreprocessor && matchesOrExceedsVersion)
{
toReturn = call.Func();
break;
Expand All @@ -306,9 +336,9 @@ private static ProjectBase TryGetProjectTypeFromDefineConstants(Project coreVisu
message += "\n\nThis project has no preprocessor directives. An unknown error has occurred.";

message += "\n\nThe project has the following properties:";
foreach (var property in coreVisualStudioProject.Properties)
foreach (var vsProperty in coreVisualStudioProject.Properties)
{
message += $"{property.Name} {property.EvaluatedValue}";
message += $"{vsProperty.Name} {vsProperty.EvaluatedValue}";
}
}
else
Expand Down
9 changes: 9 additions & 0 deletions FRBDK/Glue/Glue/VSHelpers/Projects/VisualStudioProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public abstract class VisualStudioProject : ProjectBase

List<string> mExtensionsToIgnore = new List<string>();

public int? FlatRedBallSyntaxVersion { get; set; }

#endregion

#region Properties
Expand Down Expand Up @@ -631,6 +633,13 @@ public override void Load(string fileName)
}

LoadContentProject();

FindSyntaxVersion();
}

protected virtual void FindSyntaxVersion()
{
// derived are responsible for this
}

public override void Unload()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public async Task RefreshBuiltFilesFor(VisualStudioProject project, bool forcePn

public static bool GetIfNeedsMonoGameFilesBuilt(ProjectBase project)
{
return project is DesktopGlProject ||
return project is MonoGameDesktopGlBaseProject ||
project is AndroidProject ||
project is UwpProject
// todo: need to support iOS
Expand Down Expand Up @@ -294,7 +294,7 @@ private static string GetPipelinePlatformNameFor(ProjectBase project)
// PSVita
// XboxOne
// Switch
if (project is DesktopGlProject)
if (project is MonoGameDesktopGlBaseProject)
{
platform = "DesktopGL";
}
Expand Down
Loading

0 comments on commit 182546d

Please sign in to comment.