public void SharedSourceFiles_Methods()
        {
            string projectPath = null;
            string outputPath = null;
            TestHelper.GetProjectPaths("SFT", out projectPath, out outputPath);
            string clientProjectPath = CodeGenHelper.ClientClassLibProjectPath(projectPath);
            List<string> sourceFiles = CodeGenHelper.ClientClassLibSourceFiles(clientProjectPath);
            ConsoleLogger logger = new ConsoleLogger();
            FilenameMap filenameMap = new FilenameMap();

            using (SourceFileLocationService locationService = new SourceFileLocationService(new[] { new PdbSourceFileProviderFactory(/*symbolSearchPath*/ null, logger) }, filenameMap))
            {
                SharedSourceFiles ssf = new SharedSourceFiles(locationService, filenameMap, sourceFiles);

                int[] fileIds = ssf.GetSharedFileIds(CodeMemberKey.CreateMethodKey(typeof(TestValidator).GetMethod("IsValid")));
                Assert.IsNotNull(fileIds, "Expected TestValidator.IsValid to have non-null file ID's because it is shared");
                Assert.AreEqual(1, fileIds.Length, "Expected TestValidator.IsValid to be found in exactly one file");
                Assert.IsTrue(filenameMap[fileIds[0]].Contains("TestValidator.linked.cs"), "Expected TestValidator.IsValid to be in TestValidator.linked.cs");

                fileIds = ssf.GetSharedFileIds(CodeMemberKey.CreateMethodKey(typeof(TestEntity).GetMethod("ServerAndClientMethod")));
                Assert.IsNotNull(fileIds, "Expected TestEntity.ServerAndClientMethod to have non-null file ID's because it is shared");
                Assert.AreEqual(1, fileIds.Length, "Expected TestEntity.ServerAndClientMethod to be found in exactly one file");
                Assert.IsTrue(filenameMap[fileIds[0]].Contains("TestEntity.linked.cs"), "Expected TestEntity.ServerAndClientMethod to be in TestEntity.linked.cs");

                fileIds = ssf.GetSharedFileIds(CodeMemberKey.CreateMethodKey(typeof(TestEntity).GetMethod("ServerMethod")));
                Assert.IsNull(fileIds, "Expected TestEntity.ServerMethod to have null file ids");

                fileIds = ssf.GetSharedFileIds(CodeMemberKey.CreateMethodKey(typeof(TestValidatorServer).GetMethod("IsValid")));
                Assert.IsNull(fileIds, "Expected TestValidatorServer.IsValid to have null file ids");
            }
        }
        public void SharedSourceFiles_Types()
        {
            string projectPath = null;
            string outputPath = null;
            TestHelper.GetProjectPaths("SFT", out projectPath, out outputPath);
            string clientProjectPath = CodeGenHelper.ClientClassLibProjectPath(projectPath);
            List<string> sourceFiles = CodeGenHelper.ClientClassLibSourceFiles(clientProjectPath);
            ConsoleLogger logger = new ConsoleLogger();
            FilenameMap filenameMap = new FilenameMap();

            using (SourceFileLocationService locationService = new SourceFileLocationService(new[] { new PdbSourceFileProviderFactory(/*symbolSearchPath*/ null, logger) }, filenameMap))
            {
                SharedSourceFiles ssf = new SharedSourceFiles(locationService, filenameMap, sourceFiles);

                int[] fileIds = ssf.GetSharedFileIds(CodeMemberKey.CreateTypeKey(typeof(TestEntity)));
                Assert.IsNotNull(fileIds, "Expected TestEntity to have non-null file ID's because it is shared");
                Assert.AreEqual(2, fileIds.Length, "Expected TestEntity to be found in exactly 2 files");
                foreach (int i in fileIds)
                {
                    string file = filenameMap[i];
                    Assert.IsTrue(file.Contains("TestEntity.linked.cs") || file.Contains("TestEntity.reverse.linked.cs"), "Expected exactly these 2 files to be shared");
                }

                fileIds = ssf.GetSharedFileIds(CodeMemberKey.CreateTypeKey(typeof(TestValidator)));
                Assert.IsNotNull(fileIds, "Expected TestValidator to have non-null file ID's because it is shared");
                Assert.AreEqual(1, fileIds.Length, "Expected TestValidator to be found in exactly one file");
                Assert.IsTrue(filenameMap[fileIds[0]].Contains("TestValidator.linked.cs"), "expected this to be the sole shared file for TestValidator");

                fileIds = ssf.GetSharedFileIds(CodeMemberKey.CreateTypeKey(typeof(DomainService)));
                Assert.IsNull(fileIds, "Expected DomainService to have no shared file ids");

                fileIds = ssf.GetSharedFileIds(CodeMemberKey.CreateTypeKey(typeof(TestValidatorServer)));
                Assert.IsNull(fileIds, "Expected DomainService to have no shared file ids");
            }
        }
        internal SharedCodeService(SharedCodeServiceParameters parameters, ILoggingService loggingService)
        {
            Debug.Assert(parameters != null, "parameters cannot be null");
            Debug.Assert(parameters.SharedSourceFiles != null, "sharedSourceFiles cannot be null");
            Debug.Assert(parameters.ClientAssemblies != null, "clientAssemblies cannot be null");

            // Convert optional list of PDB paths to semicolon separated list
            string symbolSearchPath = parameters.SymbolSearchPaths == null
                                        ? null
                                        : string.Join(";", parameters.SymbolSearchPaths);

            // We create an aggregating source file location service that will check in this order:
            //  1. SourceInfoAttributes generated by Live Intellisense, then
            //  2. PDB info
            ISourceFileProviderFactory[] factories = new ISourceFileProviderFactory[]
            {
                new SourceInfoSourceFileProviderFactory(),
                new PdbSourceFileProviderFactory(symbolSearchPath, loggingService)
            };

            this._locationService   = new SourceFileLocationService(factories, this._filenameMap);
            this._sharedSourceFiles = new SharedSourceFiles(this._locationService, this._filenameMap, parameters.SharedSourceFiles);
            this._sharedAssemblies  = new SharedAssemblies(parameters.ClientAssemblies, parameters.ClientAssemblyPathsNormalized, loggingService);
        }
        internal SharedCodeService(SharedCodeServiceParameters parameters, ILoggingService loggingService)
        {
            Debug.Assert(parameters != null, "parameters cannot be null");
            Debug.Assert(parameters.SharedSourceFiles != null, "sharedSourceFiles cannot be null");
            Debug.Assert(parameters.ClientAssemblies != null, "clientAssemblies cannot be null");

            // Convert optional list of PDB paths to semicolon separated list
            string symbolSearchPath = parameters.SymbolSearchPaths == null
                                        ? null
                                        : string.Join(";", parameters.SymbolSearchPaths);

            // We create an aggregating source file location service that will check in this order:
            //  1. SourceInfoAttributes generated by Live Intellisense, then
            //  2. PDB info
            ISourceFileProviderFactory[] factories = new ISourceFileProviderFactory[] 
            {
                new SourceInfoSourceFileProviderFactory(),
                new PdbSourceFileProviderFactory(symbolSearchPath, loggingService)
            };

            this._locationService = new SourceFileLocationService(factories, this._filenameMap);
            this._sharedSourceFiles = new SharedSourceFiles(this._locationService, this._filenameMap, parameters.SharedSourceFiles);
            this._sharedAssemblies = new SharedAssemblies(parameters.ClientAssemblies, parameters.ClientAssemblyPathsNormalized, loggingService);
        }