@@ -49,23 +49,12 @@ public class ProjectGeneration : IGenerator
4949
5050 const string m_SolutionProjectEntryTemplate = @"Project(""{{{0}}}"") = ""{1}"", ""{2}"", ""{{{3}}}""{4}EndProject" ;
5151
52- readonly string m_SolutionProjectConfigurationTemplate = string . Join ( k_WindowsNewline ,
53- @" {{{0}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU" ,
54- @" {{{0}}}.Debug|Any CPU.Build.0 = Debug|Any CPU" ,
55- @" {{{0}}}.Release|Any CPU.ActiveCfg = Release|Any CPU" ,
56- @" {{{0}}}.Release|Any CPU.Build.0 = Release|Any CPU" ) . Replace ( " " , "\t " ) ;
57-
58- static readonly string [ ] k_ReimportSyncExtensions = { ".dll" , ".asmdef" } ;
59-
60- HashSet < string > m_ProjectSupportedExtensions = new HashSet < string > ( ) ;
61- HashSet < string > m_BuiltinSupportedExtensions = new HashSet < string > ( ) ;
62- HashSet < string > m_DefaultSupportedExtensions = new HashSet < string > ( new string [ ] { "dll" , "asmdef" , "additionalfile" } ) ;
52+ HashSet < string > _supportedExtensions ;
6353
6454 readonly string m_ProjectName ;
6555 internal readonly IAssemblyNameProvider m_AssemblyNameProvider ;
6656 readonly IFileIO m_FileIOProvider ;
6757 readonly IGUIDGenerator m_GUIDGenerator ;
68- bool m_ShouldGenerateAll ;
6958 IVisualStudioInstallation m_CurrentInstallation ;
7059
7160 public ProjectGeneration ( ) : this ( Directory . GetParent ( Application . dataPath ) . FullName )
@@ -162,7 +151,9 @@ private bool HasFilesBeenModified(IEnumerable<string> affectedFiles, IEnumerable
162151
163152 private static bool ShouldSyncOnReimportedAsset ( string asset )
164153 {
165- return k_ReimportSyncExtensions . Contains ( new FileInfo ( asset ) . Extension ) ;
154+ // ".dll", ".asmdef"
155+ var extension = new FileInfo ( asset ) . Extension ;
156+ return extension == ".dll" || extension == ".asmdef" ;
166157 }
167158
168159 private void RefreshCurrentInstallation ( )
@@ -203,8 +194,22 @@ public bool HasSolutionBeenGenerated()
203194
204195 private void SetupProjectSupportedExtensions ( )
205196 {
206- m_ProjectSupportedExtensions = new HashSet < string > ( m_AssemblyNameProvider . ProjectSupportedExtensions ) ;
207- m_BuiltinSupportedExtensions = new HashSet < string > ( EditorSettings . projectGenerationBuiltinExtensions ) ;
197+ _supportedExtensions = new HashSet < string >
198+ {
199+ "dll" ,
200+ "asmdef" ,
201+ "additionalfile"
202+ } ;
203+
204+ foreach ( var extension in m_AssemblyNameProvider . ProjectSupportedExtensions )
205+ {
206+ _supportedExtensions . Add ( extension ) ;
207+ }
208+
209+ foreach ( var extension in EditorSettings . projectGenerationBuiltinExtensions )
210+ {
211+ _supportedExtensions . Add ( extension ) ;
212+ }
208213 }
209214
210215 private bool ShouldFileBePartOfSolution ( string file )
@@ -238,21 +243,10 @@ public bool IsSupportedFile(string path)
238243 private bool IsSupportedFile ( string path , out string extensionWithoutDot )
239244 {
240245 extensionWithoutDot = GetExtensionWithoutDot ( path ) ;
241-
242- // Dll's are not scripts but still need to be included
243- if ( m_DefaultSupportedExtensions . Contains ( extensionWithoutDot ) )
244- return true ;
245-
246- if ( m_BuiltinSupportedExtensions . Contains ( extensionWithoutDot ) )
247- return true ;
248-
249- if ( m_ProjectSupportedExtensions . Contains ( extensionWithoutDot ) )
250- return true ;
251-
252- return false ;
246+ // dlls and other configured files are not scripts but still need to be included
247+ return _supportedExtensions . Contains ( extensionWithoutDot ) ;
253248 }
254249
255-
256250 private static ScriptingLanguage ScriptingLanguageFor ( Assembly assembly )
257251 {
258252 var files = assembly . sourceFiles ;
@@ -827,26 +821,6 @@ internal virtual void GetProjectFooter(StringBuilder footerBuilder)
827821 {
828822 }
829823
830- private static string GetSolutionText ( )
831- {
832- return string . Join ( k_WindowsNewline ,
833- @"" ,
834- @"Microsoft Visual Studio Solution File, Format Version {0}" ,
835- @"# Visual Studio {1}" ,
836- @"{2}" ,
837- @"Global" ,
838- @" GlobalSection(SolutionConfigurationPlatforms) = preSolution" ,
839- @" Debug|Any CPU = Debug|Any CPU" ,
840- @" Release|Any CPU = Release|Any CPU" ,
841- @" EndGlobalSection" ,
842- @" GlobalSection(ProjectConfigurationPlatforms) = postSolution" ,
843- @"{3}" ,
844- @" EndGlobalSection" ,
845- @"{4}" ,
846- @"EndGlobal" ,
847- @"" ) . Replace ( " " , "\t " ) ;
848- }
849-
850824 private void SyncSolution ( IEnumerable < Assembly > assemblies )
851825 {
852826 if ( InvalidCharactersRegexPattern . IsMatch ( ProjectDirectory ) )
@@ -889,7 +863,24 @@ private string SolutionText(IEnumerable<Assembly> assemblies, Solution previousS
889863 var configurableProjects = projects . Where ( p => ! p . IsSolutionFolderProjectFactory ( ) ) ;
890864 string projectConfigurationsText = string . Join ( k_WindowsNewline , configurableProjects . Select ( p => GetProjectActiveConfigurations ( p . ProjectGuid ) ) . ToArray ( ) ) ;
891865
892- return string . Format ( GetSolutionText ( ) , fileversion , vsversion , projectEntriesText , projectConfigurationsText , propertiesText ) ;
866+ const string solutionText =
867+ "" + k_WindowsNewline
868+ + "Microsoft Visual Studio Solution File, Format Version {0}" + k_WindowsNewline
869+ + "# Visual Studio {1}" + k_WindowsNewline
870+ + "{2}" + k_WindowsNewline
871+ + "Global" + k_WindowsNewline
872+ + "\t GlobalSection(SolutionConfigurationPlatforms) = preSolution" + k_WindowsNewline
873+ + "\t \t Debug|Any CPU = Debug|Any CPU" + k_WindowsNewline
874+ + "\t \t Release|Any CPU = Release|Any CPU" + k_WindowsNewline
875+ + "\t EndGlobalSection" + k_WindowsNewline
876+ + "\t GlobalSection(ProjectConfigurationPlatforms) = postSolution" + k_WindowsNewline
877+ + "{3}" + k_WindowsNewline
878+ + "\t EndGlobalSection" + k_WindowsNewline
879+ + "{4}" + k_WindowsNewline
880+ + "EndGlobal" + k_WindowsNewline
881+ + "" ;
882+
883+ return string . Format ( solutionText , fileversion , vsversion , projectEntriesText , projectConfigurationsText , propertiesText ) ;
893884 }
894885
895886 private static IEnumerable < Assembly > RelevantAssembliesForMode ( IEnumerable < Assembly > assemblies )
@@ -966,8 +957,14 @@ private IEnumerable<SolutionProjectEntry> ToProjectEntries(IEnumerable<Assembly>
966957 /// </summary>
967958 private string GetProjectActiveConfigurations ( string projectGuid )
968959 {
960+ const string solutionProjectConfigurationTemplate =
961+ "\t \t {{{0}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU" + k_WindowsNewline
962+ + "\t \t {{{0}}}.Debug|Any CPU.Build.0 = Debug|Any CPU" + k_WindowsNewline
963+ + "\t \t {{{0}}}.Release|Any CPU.ActiveCfg = Release|Any CPU" + k_WindowsNewline
964+ + "\t \t {{{0}}}.Release|Any CPU.Build.0 = Release|Any CPU" ;
965+
969966 return string . Format (
970- m_SolutionProjectConfigurationTemplate ,
967+ solutionProjectConfigurationTemplate ,
971968 projectGuid ) ;
972969 }
973970
0 commit comments