Ejemplo n.º 1
0
        public void ReferencesAssembliesReturnedByDependencyLoader()
        {
            var name    = "a";
            var version = new Symbols.Interfaces.Version(1, 2, 3);

            CreateAssembly(
                "",
                name,
                version)
            .VerifyDiagnostics()
            .VerifyEmit(testEmittedAssembly: (original, _, _1) =>
            {
                var projectLoader = new ProjectLoader(
                    GetLogger <ProjectLoader>(),
                    new MockDependencyLoader(original),
                    _assemblyFactory,
                    new MockFileSystem(new Dictionary <string, MockFileData>
                {
                    { "sourceFile", "interface I {}" }
                }));
                var assemblyLoadContext = new AssemblyLoadContext(name: null);
                var result = projectLoader.LoadProjectAsync(
                    new ProjectInfo("p", new Version(0, 0), ImmutableArray.Create("sourceFile")),
                    assemblyLoadContext,
                    ImmutableArray <IAssembly> .Empty).Result;
                result.VerifyDiagnostics().VerifyEmit();
                var dependency = result.ReferencedAssembliesAndSelf.First();
                Assert.Equal(original.Name, dependency.Name);
                Assert.Equal(original.Version, dependency.Version);
            });
        }
Ejemplo n.º 2
0
        public async Task IncludedDirectoryOnlyIncludesFilesEndingWithFl()
        {
            var projectLoader = new ProjectLoader(
                GetLogger <ProjectLoader>(),
                new MockDependencyLoader(),
                _assemblyFactory,
                new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { "dir/sourceFile1.fl", "interface I1 {}" },
                { "dir/sourceFile2", "interface I2 {}" }
            }));
            var assemblyLoadContext = new AssemblyLoadContext(name: null);
            var result = await projectLoader.LoadProjectAsync(
                new ProjectInfo(
                    "p",
                    new Version(0, 0),
                    ImmutableArray.Create("dir")),
                assemblyLoadContext,
                ImmutableArray <IAssembly> .Empty);

            result.VerifyDiagnostics().VerifyEmit();
            Assert.Equal(
                new[] { "I1" },
                result.Interfaces.Select(x => x.FullyQualifiedName !.ToString()));
        }
Ejemplo n.º 3
0
        public async Task DeduplicatesFileIncludedMultipleTimesUnix()
        {
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                var projectLoader = new ProjectLoader(
                    GetLogger <ProjectLoader>(),
                    new MockDependencyLoader(),
                    _assemblyFactory,
                    new MockFileSystem(new Dictionary <string, MockFileData>
                {
                    { "/dir/sourceFile.fl", "interface I1 {}" },
                    { "/DIR/sourceFile.fl", "interface I2 {}" }
                }));
                var assemblyLoadContext = new AssemblyLoadContext(name: null);
                var result = await projectLoader.LoadProjectAsync(
                    new ProjectInfo("p", new Version(0, 0), ImmutableArray.Create(
                                        "dir/sourceFile.fl",
                                        "dir/sourceFile.fl",
                                        "DIR/sourceFile.fl",
                                        "/dir/sourceFile.fl",
                                        "dir/sourceFile.fl/",
                                        "dir/../dir/sourceFile.fl",
                                        "dir")),
                    assemblyLoadContext,
                    ImmutableArray <IAssembly> .Empty);

                result.VerifyDiagnostics().VerifyEmit();
                Assert.Equal(
                    new[] { "I1", "I2" },
                    result.Interfaces.Select(x => x.FullyQualifiedName !.ToString()));
            }
        }
Ejemplo n.º 4
0
 public async Task ThrowsIfFileOrDirectoryNotFound(string path)
 {
     var projectLoader = new ProjectLoader(
         GetLogger <ProjectLoader>(),
         new MockDependencyLoader(),
         _assemblyFactory,
         new MockFileSystem());
     var assemblyLoadContext = new AssemblyLoadContext(name: null);
     await Assert.ThrowsAsync <FlcException>(() => projectLoader.LoadProjectAsync(
                                                 new ProjectInfo("p", new Version(0, 0), ImmutableArray.Create(path)),
                                                 assemblyLoadContext,
                                                 ImmutableArray <IAssembly> .Empty).AsTask());
 }
Ejemplo n.º 5
0
        public async Task CanLoadProjectReferencingFile()
        {
            var projectLoader = new ProjectLoader(
                GetLogger <ProjectLoader>(),
                new MockDependencyLoader(),
                _assemblyFactory,
                new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { "sourceFile", "interface I {}" }
            }));
            var assemblyLoadContext = new AssemblyLoadContext(name: null);
            var result = await projectLoader.LoadProjectAsync(
                new ProjectInfo("p", new Version(0, 0), ImmutableArray.Create("sourceFile")),
                assemblyLoadContext,
                ImmutableArray <IAssembly> .Empty);

            result.VerifyDiagnostics().VerifyEmit();
            Assert.Equal("I", result.Interfaces.SingleOrDefault().FullyQualifiedName !.ToString());
        }