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

Re# doesn't play nicely with dynamic definition of namespace #14

Closed
OmegaExtern opened this issue Sep 23, 2016 · 30 comments
Closed

Re# doesn't play nicely with dynamic definition of namespace #14

OmegaExtern opened this issue Sep 23, 2016 · 30 comments

Comments

@OmegaExtern
Copy link

The following keep poping up across screen (also notice "Cannot resolve symbol"):
image

Though I do like idea of "dynamic definition of namespace", it is very annoying and clearly was not made to support Re#, apparently it was introduced in #2. Which is not the case with (original) UnmanagedExports NuGet package (where namespace is static).

@OmegaExtern OmegaExtern changed the title Re# doesn't play nicely with #2 Re# doesn't play nicely with dynamic definition of namespace Sep 23, 2016
@3F
Copy link
Owner

3F commented Sep 23, 2016

hmm, object model should be fully updated automatically... need to think

this only with Re# ?

@3F 3F added the support label Sep 23, 2016
@jonsq
Copy link

jonsq commented Sep 23, 2016

I'm brand new to this repo, but it looks like vb.net is having the same trouble? Using Visual Studio 2010 + .Net 4.0 + Nuget package version 1.3.0.

image

@3F
Copy link
Owner

3F commented Sep 23, 2016

:) strange, it's not reproduced for me at all.

Did I understand correctly that problem only with tips from IDE above and export works well ?

What after restarting IDE ? or reloading of projects/solution when it installed ?

@jonsq
Copy link

jonsq commented Sep 23, 2016

As far as I can tell, it's not causing any problems. Just instead of using the custom namespace, it's using that really long string.

image

@3F
Copy link
Owner

3F commented Sep 23, 2016

+jonsq

I see, thanks !

However it not reproduced for me :( need to think

my gif illustration here: #6 (comment)

All details about this here: Dynamic definitions of namespaces

What after restarting IDE ?

@OmegaExtern
Copy link
Author

OmegaExtern commented Sep 23, 2016

What after restarting IDE ? or reloading of projects/solution when it installed ?

Already tried. Nothing have changed.
A program compiles fine though.

One more thing, once that namespace (with DllExportAttribute class) is imported, it magically makes a program uncompilable:

CS0246: The type or namespace name 'D3F00FF1770DED978EC774BA389F2DC901F4' could not be found (are you missing a using directive or an assembly reference?)

Edit:

this only with Re# ?

Apparently it is not, now I don't know what to change the title to.

Edit 2:
Why over complicate stuff.. Seriously, make it simple and consistent with .NET Framework, just move DllExportAttribute class in the same namespace where DllImport class resides, which is: System.Runtime.InteropServices. That way it is static namespace, it may solve the other issue as well, save yourself time.
In my opinion, "dynamic definition of namespace" shouldn't have reached NuGet (as "stable"). Well, since it already did, I suggest to revert that change, and do what I have just said above (make it static namespace) -- before it hits more downloads!

@OmegaExtern
Copy link
Author

Installation log (I have used ExportedLibrary for dynamic namespace):

Attempting to gather dependency information for package 'DllExport.1.3.0' with respect to project 'ExportedLibrary', targeting '.NETFramework,Version=v4.6.1'
Attempting to resolve dependencies for package 'DllExport.1.3.0' with DependencyBehavior 'Lowest'
Resolving actions to install package 'DllExport.1.3.0'
Resolved actions to install package 'DllExport.1.3.0'
Adding package 'DllExport.1.3.0' to folder '...\packages'
Added package 'DllExport.1.3.0' to folder '...\packages'
Added package 'DllExport.1.3.0' to 'packages.config'
Executing script file '...\packages\DllExport.1.3.0\tools\install.ps1'...


Name                  : DllExportNamespace
UnevaluatedValue      : ExportedLibrary
IsEnvironmentProperty : False
IsGlobalProperty      : False
IsReservedProperty    : False
Xml                   : Microsoft.Build.Construction.ProjectPropertyElement
Predecessor           : 
IsImported            : False
EvaluatedValue        : ExportedLibrary
Project               : Microsoft.Build.Evaluation.Project

Name                  : DllExportNamespace
UnevaluatedValue      : ExportedLibrary
IsEnvironmentProperty : False
IsGlobalProperty      : False
IsReservedProperty    : False
Xml                   : Microsoft.Build.Construction.ProjectPropertyElement
Predecessor           : 
IsImported            : False
EvaluatedValue        : ExportedLibrary
Project               : Microsoft.Build.Evaluation.Project

defNS: (...\packages\DllExport.1.3.0\lib\net20\DllExport.dll); (ExportedLibrary)
1489
4
1457
The DllExport Library has been modified !
namespace: ExportedLibrary
Details here: https://github.com/3F/DllExport/issues/2


Successfully installed 'DllExport 1.3.0' to ExportedLibrary
========== Finished ==========

I have found a way-around this, that is, create own DllExportAttribute class and use it (seems like #2 has failed a lot)..

@3F
Copy link
Owner

3F commented Sep 23, 2016

seems like #2 has failed a lot

I see only report from #6 and also not for all. But, I already pushed changes for this - https://ci.appveyor.com/project/3Fs/dllexport/history, so probably it already fixed (I don't see any replies from this guys) -

when I will get a time for this project, I will start new release with this changes (+some changes from current issues)

For this issue:

! btw, please check this problem with latest changes from master - bcfa5cc

need to details, I will look it later because it also should be ok. The DllExport Library has been modified ! Therefore, the 'D3F00FF1770DED978EC774BA389F2DC901F4 cannot be at all (see 3 item)

The main problem how to reproduce it for me :(

@OmegaExtern
Copy link
Author

OmegaExtern commented Sep 23, 2016

btw, please check this problem with latest changes from master

Ok. I have just tested this with nightly build NuGet package (link). Restarted VS2015, and created an empty console application, and then installed NuGet package from local folder. Still, nothing have changed.
Here is installation log of this time (now I have used "System.Runtime.InteropServices" as dynamic namespace):

Attempting to gather dependency information for package 'DllExport.1.3.0' with respect to project 'ExportedLibrary', targeting '.NETFramework,Version=v4.6.1'
Attempting to resolve dependencies for package 'DllExport.1.3.0' with DependencyBehavior 'Lowest'
Resolving actions to install package 'DllExport.1.3.0'
Resolved actions to install package 'DllExport.1.3.0'
Adding package 'DllExport.1.3.0' to folder '...\packages'
Added package 'DllExport.1.3.0' to folder '...\packages'
Added package 'DllExport.1.3.0' to 'packages.config'
Executing script file '...\packages\DllExport.1.3.0\tools\install.ps1'...


Name                  : DllExportNamespace
UnevaluatedValue      : System.Runtime.InteropServices
IsEnvironmentProperty : False
IsGlobalProperty      : False
IsReservedProperty    : False
Xml                   : Microsoft.Build.Construction.ProjectPropertyElement
Predecessor           : 
IsImported            : False
EvaluatedValue        : System.Runtime.InteropServices
Project               : Microsoft.Build.Evaluation.Project

Name                  : DllExportNamespace
UnevaluatedValue      : System.Runtime.InteropServices
IsEnvironmentProperty : False
IsGlobalProperty      : False
IsReservedProperty    : False
Xml                   : Microsoft.Build.Construction.ProjectPropertyElement
Predecessor           : 
IsImported            : False
EvaluatedValue        : System.Runtime.InteropServices
Project               : Microsoft.Build.Evaluation.Project

set new namespace: (System.Runtime.InteropServices) - (...\packages\DllExport.1.3.0\lib\net20\DllE
xport.dll)
The DllExport Library has been modified !
namespace: System.Runtime.InteropServices
Details here: https://github.com/3F/DllExport/issues/2


Successfully installed 'DllExport 1.3.0' to ExportedLibrary
========== Finished ==========

Edit:
Moreover, I have just searched in Object Browser (with all components selected), and it couldn't find anything by searching "DllExportAttribute". Now, this is even more strange...

3F added a commit that referenced this issue Sep 30, 2016
@3F
Copy link
Owner

3F commented Sep 30, 2016

@OmegaExtern

just noticed your new edit 2 :)

just move DllExportAttribute class in the same namespace where DllImport

it already was in v1.1 ! but after short discussion with Robert I decided to provide more compatible solution.

He said simply:

What you should never, ever do is putting stuff in a general namespace like System.Runtime.InteropServices.

I wrote:

I do not think so :) ...

... and main part of my thoughts here as an my short explanation to Robert that DllExport it's special case.

with important note about problems that can be - DllExport & InteropServices it more likely a theoretical-potential problems, but yes, conflicts are possible. - That I said.

My final decision you already know, and mainly I like it more, because I want to use System.Runtime.InteropServices in my X projects, but not everyone likes it and wants to something other (that soundly)

bugs ?

bugs everywhere

_bugs everywhere

just to fix it :)

@3F
Copy link
Owner

3F commented Sep 30, 2016

I still can not reproduce your problems. I also tried in VM with different locale but no result. All works fine, damn :)

@OmegaExtern @jonsq

ok ! I already started new GUI configurator, that also affects on this feature.

gui_conf

So, please test it from develop branch - ba0da45

@3F 3F added the need info label Oct 3, 2016
@3F
Copy link
Owner

3F commented Oct 3, 2016

please report about result (latest changes: 00bede7 see binaries from CI)

@3F 3F modified the milestone: v1.4 Oct 4, 2016
@3F
Copy link
Owner

3F commented Oct 5, 2016

v1.4:

    * NEW: GUI Configurator with updated ddNS features.
    * OTHER: other possible changes and fixes.

reopen if needed

@OmegaExtern
Copy link
Author

OmegaExtern commented Oct 13, 2016

I'm back.
So, I installed fresh v1.4 package. Screenshot of settings:
image

Package Manager output:

Attempting to gather dependency information for package 'DllExport.1.4.0' with respect to project 'ExportedLibrary', targeting '.NETFramework,Version=v4.6.1'
Attempting to resolve dependencies for package 'DllExport.1.4.0' with DependencyBehavior 'Lowest'
Resolving actions to install package 'DllExport.1.4.0'
Resolved actions to install package 'DllExport.1.4.0'
  GET https://api.nuget.org/packages/dllexport.1.4.0.nupkg
  OK https://api.nuget.org/packages/dllexport.1.4.0.nupkg 83ms
Installing DllExport 1.4.0.
Adding package 'DllExport.1.4.0' to folder '...\packages'
Added package 'DllExport.1.4.0' to folder '...\packages'
Added package 'DllExport.1.4.0' to 'packages.config'
Executing script file '...\packages\DllExport.1.4.0\tools\init.ps1'...
Executing script file '...\packages\DllExport.1.4.0\tools\install.ps1'...
set new namespace: (ExportedLibrary) - (...\packages\DllExport.1.4.0\lib\net20\DllExport.dll)
binmod: lpos(1425); ident(32)
binmod: buffer(500); fullseq(534)

The DllExport Library has been modified !

namespace: 'ExportedLibrary' :: ...\packages\DllExport.1.4.0\lib\net20\DllExport.dll
Details here: https://github.com/3F/DllExport/issues/2
The Export configured for platform: x86
The Base for ordinals: 1
Successfully installed 'DllExport 1.4.0' to ExportedLibrary
========== Finished ==========

And apparently this issue is still a thing. Reopen it.

@3F
Copy link
Owner

3F commented Oct 13, 2016

:) holy hedgehogs

please attach all files from your packages\DllExport.1.4.0\lib\net20\:

  • DllExport.dll.ddNSi
  • DllExport.dll

and also check paths to dll in References in your project file (.csproj etc)

@3F 3F reopened this Oct 13, 2016
@3F 3F removed the need info label Oct 13, 2016
@OmegaExtern
Copy link
Author

Compressed in Zip file: net20.zip

@OmegaExtern
Copy link
Author

in your project file (.csproj etc)

Okay, maybe this would help:
In project file, "DllExportNamespace" seems to be invalid child element, however Re# doesn't say the same for "DllExportOrdinalsBase" (the latter seems to be valid).

See source for project file, here.

@3F
Copy link
Owner

3F commented Oct 13, 2016

still all works fine (14.0.25421.03 Update 3)

but I found possible problem in 0x007A7-0x007A8 however strange that VS works correctly for me -_-

I changed 2 bytes manually for your library, can you check:

  • Close VS IDE
  • replace DllExport.dll from me - mod_DllExport.zip
  • Open this project again

why you think that's invalid ?

...
<DllExportNamespace>ExportedLibrary</DllExportNamespace>
...

@3F
Copy link
Owner

3F commented Oct 14, 2016

by the way, again, you should not see sequence D3F00FF1770DED978E... at all, it's marker only, that can be updated for zero-based sequence that will be considered as a null-terminated string.

Therefore GAC ? I remembered this JamesNK/Newtonsoft.Json#647 or some other cache.
Can you also check this or something else ? if mod_DllExport.zip does not help

@OmegaExtern
Copy link
Author

14.0.25421.03 Update 3

Mine is 14.0.25425.01 Update 3. Your VS is older.
Re# is 2016.2.2 Build 106.0.20160913.91321.
For those who don't know, there is an option to disable the popup though, in options search for Show the Import namespace action using popup:
Show the Import namespace action using popup

I changed 2 bytes manually

Ok, 0x30 0x30 to 0x00 0x00 at location 0x7A7.

can you check

Ok. Finally:
image


So... Why the two bytes must be manually changed?

@OmegaExtern
Copy link
Author

why you think that's invalid ?

It is not me, it is Re# that reported it, see (even after above manual DllExport patch):
image

But, this doesn't really matter, right?

@3F
Copy link
Owner

3F commented Oct 14, 2016

Mine is 14.0.25425.01 Update 3. Your VS is older.

how about very older VS2010 from +jonsq ? just a note

Ok. Finally:

o_O I didn't understand - this works or not ?

Why the two bytes must be manually changed?

0x30 0x30 is not correct (for our case) for zero-based sequence that will be considered as a null-terminated string. see above

just a typo, later I will fix it ! Yes, 0x007A7-0x007A8 is also need to fix even if it not a reason of this ! yesterday I changed it manually because it was faster to check on your prepared project.

It is not me, it is Re# that reported it

it's warning of schema only - see xmlns

But, this doesn't really matter, right?

yes, for this issue it should not be related at all. And mainly this as part of full identifier to work with data via Cecil

@OmegaExtern
Copy link
Author

OmegaExtern commented Oct 14, 2016

I didn't understand - this works or not ?

Yes, your manual patch worked (see screenshot?).

@3F
Copy link
Owner

3F commented Oct 14, 2016

Yes, your manual patch worked

Good !

How about Object Browser ?

and note for 0x30 0x30 is not correct for zero-based ... I mean like for our case, well I think you understood me :)

@OmegaExtern
Copy link
Author

How about Object Browser ?

I have checked it already, and I could not find "ExportedLibrary" project nor anything about "DllExport". I have selected to search all components and still nothing... Possible VS bug?

3F added a commit that referenced this issue Oct 15, 2016
…ails in #14

+ also fixed possible problem with null for MSBuild RemoveProperty
@3F
Copy link
Owner

3F commented Oct 15, 2016

@OmegaExtern

  • ca2d68b solves problem with 0x30 0x30, as I said just a typo: sizeof(UInt16) -> sizeof(UInt16) * 2
  • 38c5388 I also added Cecil variant for ddNS features. Now you can try both variant with GUI Configurator. Or set msbuild property DllExportDDNSCecil as true

And I tested both variant for VS2010 v10.0.30319.1 (without SP1) in VM

in general, try this 54263f9 ...

@3F 3F modified the milestones: v1.5, v1.4 Oct 19, 2016
@3F 3F added the need info label Oct 20, 2016
@OmegaExtern
Copy link
Author

I am waiting for nightly build, or is this the build d17e335?
If that's build d17e335, then you didn't solve it:
image

If it is not build d17e335, please upload it; I can't be bothered to compile this from source code..

@3F
Copy link
Owner

3F commented Oct 25, 2016

amazing o_o
I was waiting for the results of latest changes i.e. the d17e335 should include all fixes for this.

Did you check both type of changes - Cecil and Direct-Mod ? this is for both options ?

@OmegaExtern
Copy link
Author

Ok, this is weird, but there's some sense. It happens with both, Cecil and Direct-Mod.
So, I have reloaded a project and it fixed itself. Well, well, well, unload project (before NuGet package is installed, or before a project file is modified), then load project (after NuGet package is installed, or after a project file is modified).
I sure that will fix it, like 100% sure.

@3F
Copy link
Owner

3F commented Oct 25, 2016

@OmegaExtern

just for checking: the any install/remove operation for this package will load our assemblies into main domain of VS !

Before, I used this to avoid problem with loading of .net assemblies:

powershell -Command "Import-Module (Join-Path $ToolsPath Configurator.dll); Set-Configuration -Dll $asmpath"

it was simply, but now I need to provide via -Command a complex objects (EnvDTE.Project & Microsoft.Build.Evaluation.ProjectCollection), and seems it's not possible (I'm not sure, I do not use powershell so often) like -ProjectDTE $project -ProjectsMBE $gpc etc.

of course I can prepare all this inside like in my other plugin (that contains complex support of EnvDTE & MS Build.Evaluation) , but I don't want hard impl. for DllExport

Therefore, the other easy way to use through temp assemblies:

$dllConf = Get-TempPathToConfiguratorIfNotLoaded 'net.r_eg.DllExport.Configurator.dll' "$toolsPath"
if($dllConf) {
    Import-Module $dllConf; 
}

Set-Configuration -MetaLib "$metaLib" -InstallPath "$installPath" -ToolsPath "$toolsPath" -ProjectDTE $project -ProjectsMBE $gpc;

ah yes, I also thought about this but for common solution I have no time yet. later

So ! if you already have installed package, to full upgrade on new version, please restart IDE if [remove] button is clicked before.

3F added a commit that referenced this issue Nov 4, 2016
    * FIXED: Fixed problem with white-space chars in path: `Cannot find path '<any full path with spaces>' because it does not exist ...`
    * FIXED: Fixed typo with fullseq (ddNS) - incorrect `0x30 0x30` ~0x007A7-0x007A8  /details in #14
    * FIXED: Possible problem with NullReferenceException when removing package.
    * FIXED: Fixed problem with old NS data when we try to install package for project A, then for project B
    * NEW: Implemented 'Generate .exp + .lib via MS Library Manager' #9
           GUI Configurator + MSBuild property: `DllExportGenExpLib`

    * NEW: Added support of unmanaged-export for Executable Modules (.exe) #18
    * NEW: Cecil variant for ddNS features /#14, #2
    * NEW: Added our custom IL Assembler as option to fix incorrect 0x13 / 0x11 opcodes. #17
           GUI Configurator + MSBuild property: `DllExportOurILAsm`
           It should help for users of Fody projects, etc.
           Fody/Fody#271

           IlAsm 4.5.1 https://github.com/3F/coreclr
           based on 4.5.22220.0 / coreclr 1.0.4
           changelog of our coreclr for this release: https://github.com/3F/coreclr/blob/master/changelog.txt

    * CHANGED: Updated scripts of installing/removing package for more correct loading of our assemblies.
@3F 3F closed this as completed Nov 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants