Skip to content

Commit 3a49ab9

Browse files
authored
FRB now reports why a file was added to the .csproj (#1763)
1 parent 1c38fc1 commit 3a49ab9

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

FRBDK/Glue/Glue/Plugins/EmbeddedPlugins/SyncedProjects/SyncedProjectLogic.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ public void SyncContentFromTo(VisualStudioProject from, VisualStudioProject to)
3434
!(to is CombinedEmbeddedContentProject);
3535
}
3636

37-
GlueCommands.Self.ProjectCommands.UpdateFileMembershipInProject(to, absoluteFileName, useContentPipeline: forceToContent, shouldLink: true, recursive:false);
37+
GlueCommands.Self.ProjectCommands.UpdateFileMembershipInProject(to, absoluteFileName, useContentPipeline: forceToContent, shouldLink: true,
38+
recursive:false,
39+
reasonForAdd: $"{from} (original project) references file");
3840
}
3941
}
4042

FRBDK/Glue/Glue/Plugins/ExportedImplementations/CommandInterfaces/ProjectCommands.cs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ public bool UpdateFileMembershipInProject(ReferencedFileSave referencedFileSave,
236236
wasAnythingAdded = UpdateFileMembershipInProject(GlueState.Self.CurrentMainProject, absoluteFilePath,
237237
useContentPipeline, false,
238238
fileRfs: referencedFileSave,
239-
reEvaluateAfterAdd: reEvaluateAfterAdd);
239+
reEvaluateAfterAdd: reEvaluateAfterAdd,
240+
reasonForAdd: $"{referencedFileSave} Explicitly added as file in FRB");
240241
}
241242

242243
foreach (ProjectSpecificFile projectSpecificFile in referencedFileSave.ProjectSpecificFiles)
@@ -262,9 +263,13 @@ public bool UpdateFileMembershipInProject(ReferencedFileSave referencedFileSave,
262263
/// <param name="shouldLink"></param>
263264
/// <param name="parentFile"></param>
264265
/// <returns>Whether the project was modified.</returns>
265-
public bool UpdateFileMembershipInProject(VisualStudioProject project, FilePath fileName, bool useContentPipeline, bool shouldLink,
266-
string parentFile = null, bool recursive = true, List<string> alreadyReferencedFiles = null, ReferencedFileSave fileRfs = null,
267-
bool reEvaluateAfterAdd = true)
266+
public bool UpdateFileMembershipInProject(VisualStudioProject project,
267+
FilePath fileName, bool useContentPipeline, bool shouldLink,
268+
string parentFile = null, bool recursive = true,
269+
List<string> alreadyReferencedFiles = null,
270+
ReferencedFileSave fileRfs = null,
271+
bool reEvaluateAfterAdd = true,
272+
string reasonForAdd = "")
268273
{
269274
bool wasProjectModified = false;
270275
///////////////////Early Out/////////////////////
@@ -368,7 +373,7 @@ project.ContentProject is VisualStudioProject &&
368373

369374
if (needsToBeInContentProject)
370375
{
371-
AddFileToContentProject(project, useContentPipeline, shouldLink, fileToAddAbsolute, fileRfs, reEvaluateAfterAdd);
376+
AddFileToContentProject(project, useContentPipeline, shouldLink, fileToAddAbsolute, fileRfs, reEvaluateAfterAdd, reasonForAdd:reasonForAdd);
372377
}
373378
else
374379
{
@@ -421,7 +426,9 @@ project.ContentProject is VisualStudioProject &&
421426
}
422427
else
423428
{
424-
wasProjectModified |= UpdateFileMembershipInProject(project, file, useContentPipeline, shouldLink, fileToAddAbsolute, recursive: true, alreadyReferencedFiles: alreadyReferencedFiles, reEvaluateAfterAdd:reEvaluateAfterAdd);
429+
wasProjectModified |= UpdateFileMembershipInProject(project, file, useContentPipeline, shouldLink, fileToAddAbsolute,
430+
recursive: true, alreadyReferencedFiles: alreadyReferencedFiles, reEvaluateAfterAdd:reEvaluateAfterAdd,
431+
reasonForAdd:$"Referenced by {fileName}");
425432
}
426433
}
427434
}
@@ -477,7 +484,9 @@ private static bool ShouldFileBeInContentProject(FilePath filePath)
477484
}
478485

479486
private static void AddFileToContentProject(ProjectBase project, bool useContentPipeline,
480-
bool shouldLink, string fileToAddAbsolute, ReferencedFileSave rfs, bool reEvaluateAfterAdd = true)
487+
bool shouldLink, string fileToAddAbsolute,
488+
ReferencedFileSave rfs, bool reEvaluateAfterAdd = true,
489+
string reasonForAdd = "")
481490
{
482491
string relativeFileName = FileManager.MakeRelative(
483492
fileToAddAbsolute,
@@ -515,7 +524,14 @@ private static void AddFileToContentProject(ProjectBase project, bool useContent
515524

516525
}
517526

518-
PluginManager.ReceiveOutput("Added " + relativeFileName + $" to {project.Name} as content");
527+
if(reasonForAdd != string.Empty)
528+
{
529+
PluginManager.ReceiveOutput("Added " + relativeFileName + $" to {project.Name} as content. Reason: {reasonForAdd}");
530+
}
531+
else
532+
{
533+
PluginManager.ReceiveOutput("Added " + relativeFileName + $" to {project.Name} as content");
534+
}
519535
}
520536

521537
public void CreateAndAddCodeFile(string relativeFileName)

FRBDK/Glue/Glue/Plugins/ExportedInterfaces/CommandInterfaces/IProjectCommands.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ bool UpdateFileMembershipInProject(VisualStudioProject project, FilePath fileNam
9898
string parentFile = null,
9999
bool recursive = true,
100100
List<string> alreadyReferencedFiles = null,
101-
ReferencedFileSave fileRfs = null, bool reEvaluateAfterAdd = true);
101+
ReferencedFileSave fileRfs = null,
102+
bool reEvaluateAfterAdd = true,
103+
string reasonForAdd = "");
102104

103105
ProjectBase AddSyncedProject(FilePath filePath);
104106

0 commit comments

Comments
 (0)