Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tmat committed Jul 29, 2022
1 parent 8d2cb69 commit 857bec9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Compilers/CSharp/Test/Emit/PDB/PDBTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ class D { void M() {} }
comp.VerifyPdb(@"
<symbols>
<files>
<file id=""1"" name=""test.cs"" language=""C#"" />
<file id=""2"" name="""" language=""C#"" />
<file id=""1"" name="""" language=""C#"" />
<file id=""2"" name=""test.cs"" language=""C#"" />
</files>
</symbols>
", options: PdbValidationOptions.ExcludeMethods);
", format: DebugInformationFormat.PortablePdb, options: PdbValidationOptions.ExcludeMethods);
}

[WorkItem(846584, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/846584")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private DocumentInfo With(
var newDocumentServiceProvider = documentServiceProvider.HasValue ? documentServiceProvider.Value : DocumentServiceProvider;

if (newAttributes == Attributes &&
newLoader == TextLoader &&
newLoader == _textLoader &&
newDocumentServiceProvider == DocumentServiceProvider)
{
return this;
Expand Down
25 changes: 25 additions & 0 deletions src/Workspaces/CoreTest/SolutionTests/DocumentInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.Text;
using Xunit;

Expand Down Expand Up @@ -44,6 +46,26 @@ public void Create()
Assert.Equal(SourceCodeKind.Script, info.SourceCodeKind);
Assert.Same(loader, info.TextLoader);
Assert.True(info.IsGenerated);
Assert.Equal(SourceHashAlgorithm.Sha256, info.ChecksumAlgorithm);
}

[Fact]
public void Create_NullLoader()
{
var id = DocumentId.CreateNewId(ProjectId.CreateNewId());

var info = DocumentInfo.Create(
id,
name: "doc",
sourceCodeKind: SourceCodeKind.Script,
loader: null,
isGenerated: true);

Assert.Equal(id, info.Id);
Assert.Equal("doc", info.Name);
Assert.Equal(SourceCodeKind.Script, info.SourceCodeKind);
Assert.Null(info.TextLoader);
Assert.True(info.IsGenerated);
}

[Fact]
Expand Down Expand Up @@ -80,11 +102,14 @@ public void TestProperties()
var projectId = ProjectId.CreateNewId();
var documentId = DocumentId.CreateNewId(projectId);
var instance = DocumentInfo.Create(DocumentId.CreateNewId(ProjectId.CreateNewId()), "doc");
var serviceProvider = (IDocumentServiceProvider)new TestDocumentServiceProvider();

SolutionTestHelpers.TestProperty(instance, (old, value) => old.WithId(value), opt => opt.Id, documentId, defaultThrows: true);
SolutionTestHelpers.TestProperty(instance, (old, value) => old.WithName(value), opt => opt.Name, "New", defaultThrows: true);
SolutionTestHelpers.TestProperty(instance, (old, value) => old.WithSourceCodeKind(value), opt => opt.SourceCodeKind, SourceCodeKind.Script);
SolutionTestHelpers.TestProperty(instance, (old, value) => old.WithTextLoader(value), opt => opt.TextLoader, (TextLoader)new FileTextLoader(Path.GetTempPath(), defaultEncoding: null, SourceHashAlgorithm.Sha256));
SolutionTestHelpers.TestProperty(instance, (old, value) => old.WithDesignTimeOnly(value), opt => opt.Attributes.DesignTimeOnly, true);
SolutionTestHelpers.TestProperty(instance, (old, value) => old.WithDocumentServiceProvider(value), opt => opt.DocumentServiceProvider, serviceProvider);

SolutionTestHelpers.TestListProperty(instance, (old, value) => old.WithFolders(value), opt => opt.Folders, "folder", allowDuplicates: true);
}
Expand Down

0 comments on commit 857bec9

Please sign in to comment.