Conversation
| var (compilation, isError) = bc.CreateCompilation(optionsReader, "test", sources, references); | ||
|
|
||
| Assert.False(isError); | ||
| Assert.Equal(platform, compilation!.Options.Platform); |
There was a problem hiding this comment.
Think we need to take the next step and ensuring the original and rebuilt compilation have the same byte[] output. Consider doing as a helper so future tests can just build on top of that.
There was a problem hiding this comment.
I think this is a good idea, but there are issues with it to iron out that I'm not sure I want to block on.
There was a problem hiding this comment.
Fine on working it out later but let's file an issue to track.
| namespace Rebuild.UnitTests | ||
| { | ||
| //[CompilerTrait(CompilerFeature.)] | ||
| public class CSharpRebuildTests : CSharpTestBase |
There was a problem hiding this comment.
I think it would be good to have a VB version of this test. I guess in that case we'd want to add a reference to the VB test helpers?
There was a problem hiding this comment.
My instinct was to have an abstract base class and then have both a VB and C# derivation. Hoping that it would be easy to abstract over the languages this way.
There was a problem hiding this comment.
I'd like to introduce a few more test cases and then try to figure out what test helpers would be most useful.
Co-authored-by: Jared Parsons <jaredpparsons@gmail.com>
|
@jaredpar have responded to the feedback. |
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using Roslyn.Utilities; |
There was a problem hiding this comment.
Roslyn.Utilities [](start = 6, length = 16)
Is this needed?
There was a problem hiding this comment.
No, thanks, have removed.
| }; | ||
|
|
||
| private static Platform GetPlatform(string? platform) | ||
| => platform is null |
There was a problem hiding this comment.
=> [](start = 8, length = 3)
Should this be indented? #Closed
| <ProjectReference Include="..\Rebuild\Rebuild.csproj" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <PackageReference Include="Moq" Version="$(MoqVersion)" /> |
There was a problem hiding this comment.
[](start = 4, length = 58)
Is this package used? #Closed
|
|
||
| var factory = LoggerFactory.Create(configure => { }); | ||
| var logger = factory.CreateLogger(path); | ||
| // TODO: shouldn't need to pass a logger. |
There was a problem hiding this comment.
If we need an ILogger instance, could we create a simple implementation of ILogger in this test class?
There was a problem hiding this comment.
Yes, but it feels like users of the public API shouldn't be required to provide a logger, and shouldn't provide it as its own parameter. Maybe a property on an options object that can be specified if the user wants, but not a parameter to public API that they have to deal with.
| { | ||
| var text = st.GetText(); | ||
| return new ResolvedSource(OnDiskPath: null, text, new SourceFileInfo(path, text.ChecksumAlgorithm, text.GetChecksum().ToArray(), text, embeddedCompressedHash: null)); | ||
| }).ToImmutableArray(); |
There was a problem hiding this comment.
ToImmutableArray [](start = 15, length = 16)
Could use SyntaxTrees.SelectAsArray(...) instead.
There was a problem hiding this comment.
I think this project is missing an IVT to MS.CA for this. I will punt on it for now if that's ok.
| } | ||
|
|
||
| var platform = module.CommonCompilation.Options.Platform; | ||
| WriteValue(CompilationOptionNames.Platform, platform.ToString()); |
There was a problem hiding this comment.
Platform can't be determined from the CLR/PE header flags of the dll? Seems like it should be possible.
There was a problem hiding this comment.
It may be possible, but I wasn't able to get all the values to round trip. The CoffHeader.Machine, for example, is not enough information. There must be other bits that imply Platform.AnyCpu and Platform.AnyCpu32BitPreferred that I just wasn't able to find.
There was a problem hiding this comment.
These are stored in CorHeader flags:
https://source.dot.net/#System.Reflection.Metadata/System/Reflection/PortableExecutable/CorHeader.cs,1f6cfc9c2185aaf4,references
There was a problem hiding this comment.
Filed #51941 to make sure we get to this. Thanks
Currently cases(edit: now are all passing.)X86andAnyCpu32BitPreferredare failing.I can't quite figure out how to implement GetPlatform to make all these values round trip. In particular struggling to figure out how to distinguish the AnyCpu case from the X86 case. It seems like when
Platform.AnyCpuis provided as an input, we translate it toMachine.Unknown:roslyn/src/Compilers/Core/Portable/Compilation/Compilation.cs
Lines 1971 to 1973 in b6f8504
However, when I try to read the Machine value back out of the PE later on, it ends up being
Machine.I386... I am really not sure what I'm missing or where the value is getting changed.@jaredpar for review.