Understanding assembly type from source#1529
Conversation
|
|
||
| try | ||
| { | ||
| using (var assemblyStream = File.Open(filePath, FileMode.Open, FileAccess.Read)) |
There was a problem hiding this comment.
done. Added API in FileHelper also.
TestPlatform.sln
Outdated
| EndProject | ||
| Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "vstest.console.PlatformTests", "test\vstest.console.PlatformTests\vstest.console.PlatformTests.csproj", "{8C068694-23A2-47A2-A0DD-DB82D0AF0142}" | ||
| EndProject | ||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleManagedApp", "test\TestAssets\ConsoleManagedApp\ConsoleManagedApp.csproj", "{A4AAB1DF-BAD4-4C75-A0FD-10EDC2F38106}" |
| using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
|
||
| [TestClass] | ||
| public class PEReaderHelperTests : IntegrationTestBase |
There was a problem hiding this comment.
Move this to common platform tests.
| <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion> | ||
| <ProjectName>Microsoft.TestPlatform.TestAsset.NativeCPP</ProjectName> | ||
| </PropertyGroup> | ||
| <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> |
There was a problem hiding this comment.
Why ConsoleNativeApp.cpp is binary file?
| <Filter>Source Files</Filter> | ||
| </ClCompile> | ||
| </ItemGroup> | ||
| </Project> No newline at end of file |
There was a problem hiding this comment.
Below files should not be binary files.
| { | ||
| var peHeaders = peReader.PEHeaders; | ||
| var corHeader = peHeaders.CorHeader; | ||
| var corHeaderStartOffset = peHeaders.CorHeaderStartOffset; |
There was a problem hiding this comment.
Add link to documentation in comment.
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities |
There was a problem hiding this comment.
Why is this class Singleton?
There was a problem hiding this comment.
Not required. Removed.
| /// Initializes a new instance of the <see cref="PEReaderHelper"/> class. | ||
| /// </summary> | ||
| /// <param name="fileHelper">File helper.</param> | ||
| public PEReaderHelper(FileHelper fileHelper) |
|
|
||
| try | ||
| { | ||
| using (var fileStream = fileHelper.GetStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) |
| } | ||
| catch (Exception ex) | ||
| { | ||
| EqtTrace.Warning("GetAssemblyTypeFromAssemblyMetadata: failed to determine assembly type: {0} for assembly: {1}", ex, filePath); |
There was a problem hiding this comment.
Nit: Keep message prefix to Classname.Method name.
|
|
||
| if (EqtTrace.IsInfoEnabled) | ||
| { | ||
| EqtTrace.Info("AssemblyMetadataProvider.GetAssemblyType: Determined assemblyType:'{0}' for source: '{1}'", assemblyType, filePath); |
There was a problem hiding this comment.
Nit: change the class name.
| <Import Project="$(TestPlatformRoot)scripts/build/TestPlatform.Settings.targets" /> | ||
| <PropertyGroup> | ||
| <TargetFrameworks>netcoreapp1.0;net451</TargetFrameworks> | ||
| <OutputType Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">Exe</OutputType> |
There was a problem hiding this comment.
Nit: this line is not required.
| <ItemGroup> | ||
| <ProjectReference Include="..\Microsoft.TestPlatform.TestUtilities\Microsoft.TestPlatform.TestUtilities.csproj" /> | ||
| <PackageReference Include="Microsoft.TestPlatform.TestAsset.NativeCPP"> | ||
| <Version>2.0.0</Version> |
There was a problem hiding this comment.
Please never upload nupkg with same version after changing the content. It will leads to different behavior based on user nuget cache.
There was a problem hiding this comment.
Not doing in this as we are only using it this nuget. Will update if happens in future changes
|
|
||
| try | ||
| { | ||
| using (var fileStream = this.fileHelper.GetStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) |
There was a problem hiding this comment.
Its share permission for other threads
|
|
||
| if (EqtTrace.IsInfoEnabled) | ||
| { | ||
| EqtTrace.Info("PEReaderHelper.GetAssemblyType: Determined assemblyType:'{0}' for source: '{1}'", assemblyType, filePath); |
There was a problem hiding this comment.
this should go in resources
There was a problem hiding this comment.
these are logs only.
| var corHeader = peHeaders.CorHeader; | ||
| var corHeaderStartOffset = peHeaders.CorHeaderStartOffset; | ||
|
|
||
| assemblyType = (corHeader != null && corHeaderStartOffset >= 0) ? |
There was a problem hiding this comment.
can you point the documentation for how to determine if the assembly is managed or native
There was a problem hiding this comment.
Documentation links added in above lines
Part 2 of RFC:
Contains changes for understanding assembly type from sources.