Bug 21426 - Xaml generated code should be located next to the .xaml file
Summary: Xaml generated code should be located next to the .xaml file
Status: RESOLVED INVALID
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Xamarin.Forms ()
Version: 3.1
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-07-18 05:46 UTC by Kaj Bonfils
Modified: 2014-07-18 06:11 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description Kaj Bonfils 2014-07-18 05:46:38 UTC
The .g.cs is generated in the obj folder. This causes the contents to invisible to Visual studio, which causes InitializeComponent to be unrecognized by the editor. 

Any controls that are named in the XAML file (e.g. <Label x:Name="Foo" />) causes a private member to be generated in the g.cs file, which can be used to access the control. This is not available to intellisence either.

This behaviour has been confirmed during a xamarin university session with Rene Ruppert.
Comment 1 Jason Smith [MSFT] 2014-07-18 05:49:03 UTC
Are you using Resharper? There is a known issue with Resharper and detected the .g.cs file. If you disable resharper it should work fine.

Please reopen if you are not using resharper, if you are please go chime in here: http://youtrack.jetbrains.com/issue/RSRP-415583 and here http://youtrack.jetbrains.com/issue/RSRP-265402
Comment 2 Kaj Bonfils 2014-07-18 05:57:57 UTC
Disabling Resharper fixes it.

But still: isn't it "Best Practice" to place generated code next to the file that generated it?  As far as my experience goes, this is normal behaviour in Visual Studio when using both WPF and Entity Framework. Its nice for the developer to actually be aware of what was generated. Transparency is nice :-)
Comment 3 Jason Smith [MSFT] 2014-07-18 06:09:35 UTC
actually no. The generated code is only supposed to go next to it *if* its code you would consider checking in. Further even if we put it next to it, we wouldn't add it to the csproj file since its generated at compile time from the .xaml file. This is precisely how its done with silverlight or wpf.
Comment 4 Kaj Bonfils 2014-07-18 06:11:34 UTC
All right. That makes sense. Thanks