Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Csproj format update, fixes #3944 #4383

Merged
merged 52 commits into from
Oct 18, 2018

Conversation

Vogel612
Copy link
Member

No description provided.

@Vogel612 Vogel612 added PR-Status: WIP Pull request is work-in-progress, more commits should be expected. technical-debt This makes development harder or is leftover from a PullRequest. Needs to be adressed at some point. labels Sep 20, 2018
@bclothier
Copy link
Contributor

Just few questions....

  1. Was it intentional to delete this inspection
  2. EasyHook files were apparently deleted. Is that intentional as well? I did not see a corresponding addition; only a PackageReference, and I am assuming we are now referencing the files in the packages folder which isn't a part of the git solution; but a bit unsure why files existed inside the projects originally.
  3. There were a number of conditions that were deleted that I don't think should be:
<Error Condition="!Exists('..\packages\Antlr4.CodeGenerator.4.6.4\build\Antlr4.CodeGenerator.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Antlr4.CodeGenerator.4.6.4\build\Antlr4.CodeGenerator.props'))" />
    <Error Condition="!Exists('..\packages\Antlr4.CodeGenerator.4.6.4\build\Antlr4.CodeGenerator.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Antlr4.CodeGenerator.4.6.4\build\Antlr4.CodeGenerator.targets'))" />

Judging from other diff, the <Error Condition="..." /> tag seems legal even in the new csproj format. There were a number of projects that had those error condition for both ANTLR and NUnit.

@Vogel612
Copy link
Member Author

Re 1: That inspection had been removed from the csproj files, but not from the git working tree. It uses old API for inspections and refers to resources that have been removed. The move to the new csproj format (which uses globbing to include files) just surfaced that mishap.

Re 2: EasyHook (as well as NLog.Schema and possibly other NuGet Packages) pushed parts of the content they should add to the /packages directory to the solution content. That behaviour is apparently not supported for PackageReference items. The changes in these cases were performed by the automatic NuGet package migration tool in VS. The tool produced a few warnings, but I haven't been able to spot any impact on the functionality in the final deployed assembly.

Re 3: Good spot, I'll make sure to reinstate these error conditions

@Vogel612 Vogel612 added the PR-Status: Conflicting PR can't be merged as it stands, conflicts must be resolved by the author. label Sep 23, 2018
@codecov
Copy link

codecov bot commented Sep 23, 2018

Codecov Report

Merging #4383 into next will decrease coverage by 6.9%.
The diff coverage is n/a.

@@            Coverage Diff            @@
##             next    #4383     +/-   ##
=========================================
- Coverage   63.76%   56.86%   -6.9%     
=========================================
  Files         933      944     +11     
  Lines       31299    32217    +918     
=========================================
- Hits        19955    18318   -1637     
- Misses      11344    13899   +2555
Impacted Files Coverage Δ
Rubberduck.Parsing/Symbols/AliasDeclaration.cs 0% <0%> (-100%) ⬇️
...crete/ImplicitDefaultMemberAssignmentInspection.cs 5.56% <0%> (-94.44%) ⬇️
Rubberduck.UnitTesting/UnitTesting/TestResult.cs 0% <0%> (-84.62%) ⬇️
Rubberduck.Parsing/ComReflection/ComTypeName.cs 0% <0%> (-61.9%) ⬇️
...bberduck.Parsing/Symbols/PropertyGetDeclaration.cs 39.29% <0%> (-58.93%) ⬇️
...bberduck.Parsing/Symbols/PropertyLetDeclaration.cs 46.15% <0%> (-51.92%) ⬇️
Rubberduck.UnitTesting/UnitTesting/ITestEngine.cs 0% <0%> (-50%) ⬇️
Rubberduck.UnitTesting/UnitTesting/TestEngine.cs 16.55% <0%> (-49.66%) ⬇️
...uck.Parsing/Symbols/ProceduralModuleDeclaration.cs 30.3% <0%> (-48.48%) ⬇️
...ubberduck.Parsing/Symbols/SubroutineDeclaration.cs 54.76% <0%> (-42.86%) ⬇️
... and 266 more

@Vogel612 Vogel612 force-pushed the csproj-format-update branch 5 times, most recently from 5bb7556 to e8d3c07 Compare September 26, 2018 22:39
@Vogel612 Vogel612 force-pushed the csproj-format-update branch 2 times, most recently from 13ac45e to e4b4c57 Compare October 2, 2018 21:20
@bclothier
Copy link
Contributor

I believe I have discovered the source of instability in the build process. I think this section in the Rubberduck.Core.csproj is wrong.

  <!--BEGIN XAML WORKAROUND SECTION -->
  <ItemGroup>
    <Compile Include="$(IntermediateOutputPath)**\*.g.cs" Visible="false" />
    <Page Include="**\*.xaml">
      <SubType>Designer</SubType>
      <Generator>MSBuild:Compile</Generator>
      <!-- <Generator>MSBuild:UpdateDesignTimeXaml</Generator>-->
    </Page>
    <Compile Update="**\*.xaml.cs">
      <SubType>Code</SubType>
      <DependentUpon>%(Filename)</DependentUpon>
    </Compile>
    <!-- Resources -->
    <EmbeddedResource Update="Properties\Resources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" />
    <Compile Update="Properties\Resources.Designer.cs" AutoGen="True" DependentUpon="Resources.resx" DesignTime="True" />
    <!-- Settings -->
    <None Update="Properties\Settings.settings" Generator="SettingsSingleFileGenerator" LastGenOutput="Settings.Designer.cs" />
    <Compile Update="Properties\Settings.Designer.cs" AutoGen="True" DependentUpon="Settings.settings" />
  </ItemGroup>
  <!-- END XAML WORKAROUND SECTION -->

With this setting, the obj folder in the Rubberduck.Core goes nuts. Even when Visual Studio is just sitting there doing nothing, you can see files being modified, added, deleted nonstop in the obj folder. I think this triggers a infinite recursion trying to resolve all types in the intermediate files.

I made the following changes:

    <!--<Compile Include="$(IntermediateOutputPath)**\*.g.cs" Visible="false" />-->
    <Page Include="**\*.xaml">
      <SubType>Designer</SubType>
      <Generator>MSBuild:Compile</Generator>
      <!-- <Generator>MSBuild:UpdateDesignTimeXaml</Generator>-->
    </Page>

With this change, the obj folder became stable, Visual Studio starts performing better and build is now more consistent. I have not tested whether I have broke the WPF, however. I inferred the settings from a SO thread.

With the build troubles out of the way, I was able to properly test and verify that yes, we must have [assembly: ComVisible(false)]; the default is to make it COM-visible, which causes the MIDL to pick up unwanted types and thus fail with an error about missing forward declarations for certain types.

Please confirm if you'd like my commit to be added or if there's some other preference to merge the changes.

// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

[assembly: CLSCompliant(false)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think we need this. From what I can tell, we don't emit any additional warnings without that setting. Because this impacts the project references (e.g. a CLS compliant project shouldn't reference a non-CLS compliant project), and this is the only time we have this, it's best to not have the attribute so we actually get warnings if this does become an issue.

<Resource Include="**\*.txt" />
<Resource Include="**\*.resx" />
<Resource Update="**\*.de.resx">
<DependentUpon>$([System.String]::Copy('%(Filename)').Replace('.de', '')).resx</DependentUpon>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a bit more fragile. What if we add new language? Do we have to go and add this everywhere we need i18n? Couldn't we replace .??.resex to .resx?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% clear on how wildcards work, but it might be worth a try to unify this, yea

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is easily my favorite feature of the new csproj format -- ability to standardize all projects. Love that! 👍

RubberduckBaseProject.csproj Show resolved Hide resolved
</PropertyGroup>

<ItemGroup>
<Analyzer Condition=" '$(AssemblyName)' != 'RubberduckCodeAnalysis' "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition need to include RubberduckTests and RubberduckCodeAnalysisTests; makes no sense to run the analyzers there. (note: fixed in my commit that's not pushed yet)

@Vogel612 Vogel612 force-pushed the csproj-format-update branch from aa75be5 to 966fc09 Compare October 5, 2018 21:40
@Vogel612
Copy link
Member Author

Vogel612 commented Oct 5, 2018

Reminder to self: check whether we can use some of the MSBuild community tasks to simplify our stuff even more: https://github.com/loresoft/msbuildtasks

@Vogel612 Vogel612 force-pushed the csproj-format-update branch from 32777c7 to 26d6e18 Compare October 7, 2018 13:47
@Vogel612
Copy link
Member Author

Vogel612 commented Oct 7, 2018

As it stands, this PR will utterly and completely break the UI. That's because when we're initializing compoents based on XAML, we have a System.Uri that looks a bit like this: "/Rubberduck.Core;V2.2.*;[...]".

The second part of that URI is parsed as a System.Version to determine the Assembly to load for the XAML. That's not possible because * is rather obviously not an integer. As such loading any XAML component will result in a FormatException. That means we either don't have a UI or even crash the host as it stands. That's what broke the test ignored in 9555bbb

I'll need some help figuring out a proper fix for this. I assume that dotnet/project-system#1467 is closely realated to this. A symptomatic fix could be to explicitly specify a non-wildcard version for Rubberduck.Core. I don't know whether that will break COM Registration or the deployment process though.

Opinions highly welcome.

<Choose>
<When Condition=" '$(AssemblyName)' == 'RubberduckTests' ">
<ItemGroup>
<Analyzer Include="$(SolutionDir)\RubberduckTestsCodeAnalysis\bin\RubberduckTestsCodeAnalysis.dll"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does not make sense - it seems to be saying that if the project is RubberduckTests, to add RubberduckTestsCodeAnalysis as an analyzer for that project. But the RubberduckTestsCodeAnalysis project is a test project testing the analzyer, not an analyzer project... Or am I misunderstanding?

@bclothier
Copy link
Contributor

Regarding the problem with the WPF URI -- this says the version is optional. Do we really need to have the version embedded in the URI? Seems to me that it'd simplify lot of things if we only cared about the resource name, regardless of the version?

@Vogel612
Copy link
Member Author

Vogel612 commented Oct 7, 2018

Reminder to self: get MSBump to put in versions: https://github.com/BalassaMarton/MSBump

This moves all NuGet references from the packages.config format
to the PackageReference format.

This was done through the migration tool shipped with VisualStudio.
The warnings around EasyHook have been ignored for now.
@Vogel612 Vogel612 force-pushed the csproj-format-update branch from 4159392 to c93864c Compare October 13, 2018 16:16
This changes the PostBuildEvent and PreBuildEvent previously used
to prepare the installer and the COM registration for dev build
to proper MSBuild Target definitions that hook into the buildprocess
Update path to TestAssemblies to not contain Configuration
Apparently XAML generation generates a resource URI with a version specifier of 'V2.2.*'.
This specifier cannot be parsed by System.Version resulting in an exception in the test.
So long as XAML generation isn't fully supported, we can't really fix that aside from
specifying a full version. For now ignoring the test is the easier workaround.
Drop XML preamble in shared project file to make sure the first line is
the root "Project" declaration.
Add Sdk to base project declaration, provoking MSB4011, but fixing
version patching.
@Vogel612 Vogel612 force-pushed the csproj-format-update branch from dc26ca3 to d63a5ef Compare October 14, 2018 11:04
@Vogel612 Vogel612 added PR-Status: Review Requested No more commits, PR is ready for the eyes that need to see it. and removed PR-Status: Conflicting PR can't be merged as it stands, conflicts must be resolved by the author. PR-Status: WIP Pull request is work-in-progress, more commits should be expected. labels Oct 14, 2018
@Vogel612
Copy link
Member Author

Okay I think I'm done now. For me locally running the BuildRegistry script still fails from within VisualStudio. I haven't attempted to run it in msbuild alone. If I run the exact command that VS should run in a powershell host it works as expected and correctly registers the build.

As such I'm assuming that VS is somehow at fault.

The problem with XAML has been symptomatically fixed, pending a more in-depth diagnosis of the underlying problem. I unfortunately am not remotely knowledgeable enough to find out where this goes wrong.

I have not included MSBump (yet?). Currently we're patching versions through AppVeyor, which works fine for AV. Locally the wildcard just goes to a generated buildnumber which is dependent on the timestamp. That way builds will properly generate different versions.

I have not verified that Fakes work as expected. Parsing, UnitTesting and similar things seem to work just as intended from cursory F5 testing. Unless there's something major, this is ready to merge from my side now.

Copy link
Member

@retailcoder retailcoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Massive props for the massive work here, @Vogel612 - this diff is awesome (negative 46.3K!!) and we're clearly all going to benefit from a leaner .csproj format.
Just needs clarification w/rt the AppVeyor build versioning, though. Looks like the appveyor.yml file handles it fine?

@retailcoder retailcoder merged commit 050c0a7 into rubberduck-vba:next Oct 18, 2018
@Vogel612 Vogel612 deleted the csproj-format-update branch November 25, 2018 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Status: Review Requested No more commits, PR is ready for the eyes that need to see it. technical-debt This makes development harder or is leftover from a PullRequest. Needs to be adressed at some point.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants